Commit Graph

6433 Commits

Author SHA1 Message Date
Qi Xiao
0e2999dee8 Support using Elvish transcripts as tests.
- evaltest.TestTranscriptsInFS runs transcripts in .elv and .elvts files as
  tests.

- Extend the syntax of Elvish transcripts with headings and comments; the former
  is used to split a single .elvts file into multiple sessions.
2024-01-30 20:15:58 +00:00
Qi Xiao
d71afb4443 pkg/fsutil: Handle / as path separator on Windows.
Both / and \ are valid path separators on Windows; handle both of them.
2024-01-30 20:15:58 +00:00
Qi Xiao
b91c655085 pkg/edit: Fix unnecessary creation of variable in add-var implementation. 2024-01-30 20:15:58 +00:00
Qi Xiao
f1a4fd869b pkg/tt: Report the filename and line of failed test case. 2024-01-30 20:15:58 +00:00
Qi Xiao
f282768e3c pkg/testutil: Let Dir implement fs.FS. 2024-01-30 20:15:58 +00:00
Qi Xiao
27c3a40236 pkg/diff: Take string inputs, and add DiffNoHeader. 2024-01-30 20:15:58 +00:00
Tw
e6380c1e0d support big num for base cmd
Signed-off-by: Tw <tw19881113@gmail.com>
2024-01-30 19:55:24 +00:00
Kurtis Rader
3c666ef9cd Fix broken readline binding link
The primary purpose of this change is to fix a broken link to the
readline binding source. A secondary purpose is a baby step to
addressing issue #1719.

Related #1719
2024-01-23 09:56:26 +00:00
Qi Xiao
82d7730e59 pkg/mods/flag: Don't put addFlag in the init clause of if statement.
The pattern "if err := ...; err != nil" is popular in certain Go projects as it
saves one line of code, but Elvish's codebase only uses the init clause in an if
statement when the init clause is used to calculate something that's only used
in the condition or the if body. In this case addFlag has side effects that's
relevant outside the if block, so shouldn't be put in the init clause.
2024-01-23 09:53:05 +00:00
Kurtis Rader
38ced1a7a5 Detect invalid default flag value in flag:call
Fixes #1755
2024-01-23 09:52:23 +00:00
Qi Xiao
464cfb64c6 pkg/mods/os: Don't guard the mkdir workaround with GOOS check.
This behavior of mkdir is shared by all BSDs and macOS. Also expand the comment
a bit so that the reader don't have to read the Go issue.
2024-01-23 09:46:26 +00:00
Kurtis Rader
c6d78a528a Replace epm dependency on rm with os:remove-all
Remove the `epm` dependency on `rm` with `os:remove-all` so it is slightly
easier to use the `epm` command on Windows.

There aren't any unit tests for this but I verified it worked by running
the following statements on my macOS and Windows systems:

    epm:install github.com/doubleagent/rivendell
    epm:uninstall github.com/doubleagent/rivendell

Related #1661
2024-01-22 22:04:59 +00:00
Qi Xiao
b1815eb33d pkg/mods/os: Work around a quirk of FreeBSD's mkdir in the test.
This fixes #1748.
2024-01-22 21:56:01 +00:00
Qi Xiao
8003693f47 website/tools: Fix the recording of "has_broken" in check-rellinks.py.
The bug led to the script not exiting with 1 when there were errors. Fix the
error too.
2024-01-22 17:24:27 +00:00
Qi Xiao
bf40c51b6e website/tools: Generalize the check for slashes in check-rellinks.py.
Also:

- Clean up the script a bit, adding more comments.

- Report line and column number of offending links.

- Fix the (more minor) issues found by the new checks.
2024-01-22 17:20:02 +00:00
Qi Xiao
c1b403e46a website: Remove the dependency on SQLite3 CLI for generating docset.
Python bundles SQLite3, so just use that.
2024-01-22 16:16:56 +00:00
Kurtis Rader
3f4fbff260 Provide more info for an invalid doc link
Make it more obvious why a documentation reference link is invalid when
the URL path incorrectly includes a trailing slash. This would have
saved me an hour of debugging when I was working on a change that
included a reference like this one:

    [`edit:histlist:start`](../ref/edit.html/#edit:histlist:start)

Fixes #1749
2024-01-22 15:20:50 +00:00
Qi Xiao
fef5049716 pkg/eval: Simplify how exception tracebacks are written.
*Exception.Show used to work differently when the traceback contains one frame
vs more frames. Harmonize how they work, and consistent with how parse errors
and compilation errors are shown.
2024-01-16 12:50:59 +00:00
Qi Xiao
cfe4c0051d pkg/diag: Remove Complain and Complainf
The former is unused, and the latter is only used from pkg/edit/config_api.go.
Subsume the logic into ShowError, and use that from pkg/edit/config_api.go.
2024-01-16 11:09:57 +00:00
Qi Xiao
5775c8b3ed pkg/diag: Rework API and presentation of Context and Error.
- Change Context to export all its fields.

- Include end position in Context, and include it in Show.

- Remove the Type field from Error, and express it using an ErrorTag type
  parameter instead.

- Make {Pack Unpack}CognateErrors type-safe with the new ErrorTag mechanism, and
  rename them to just {Pack Unpack}Errors.
2024-01-16 11:04:52 +00:00
Qi Xiao
76e2d3cb61 Fix test on Windows.
A Windows test case was missed when changing the pkg/tt API.
2024-01-11 16:36:52 +00:00
Qi Xiao
6dfa4f623b .github/workflows: Fix step condition.
Expressions that start with ! must use ${{ }} explicitly:
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idif
2024-01-11 16:31:41 +00:00
Qi Xiao
36e1272fd7 .github/workflows: Clean up workflow definitions.
- Fix the cache key used in check_website.yml. It was blindly copied from ci.yml
  and contained matrix parameters that are not present in this workflow.

- Simplify the derivation of OS_TYPE used for tagging coverages to use a ternary
  expression.

- Simplify the condition for uploading coverages by introducing a new "old-go"
  matrix parameter.
2024-01-11 15:44:50 +00:00
Qi Xiao
6e36058d0a pkg/tt: Improve API.
- Use reflection to derive function name.

- Take test cases as variadic arguments, instead of requiring them to be wrapped
  in a Table.

- Support naming test cases.

- Run test cases as subtests with t.Run.
2024-01-11 15:42:43 +00:00
Qi Xiao
82b32d4ace website/tools/mkdsidx.py: Fix use of quotes in generated SQL.
The script used to emit double-quoted strings, which is not standard SQL
syntax and support for it in SQLite been disabled by default since 3.41.0
(https://www.sqlite.org/changes.html).
2024-01-11 00:03:32 +00:00
Qi Xiao
6a4204dec5 Bump Go version in CI tasks for checking binaries. 2024-01-10 23:41:51 +00:00
Qi Xiao
d013121af6 Require Go >= 1.20, and bump CI environment versions.
Also:

- Fix new deprecations in Go 1.20.

- Remove the unused .gitlab-ci.yml.
2024-01-10 22:28:18 +00:00
Qi Xiao
ff97d08cd7 pkg/mods/math: Fix examples of ceil to actually use ceil.
This fixes #1747.
2024-01-10 21:31:42 +00:00
Qi Xiao
8d8e5ae841 pkg/mods/{readlinebinding -> readline-binding}.
We now assume that the directory name under pkg/mods match exactly with the
Elvish module name in several places, and this mismatch broke website building.

Go allows dashes in directory names; it just forbids them in the package name
and there's actually no requirement that the directory name and the package name
be the same.
2024-01-09 13:52:16 +00:00
Qi Xiao
d7b6600dff Upgrade dependencies. 2024-01-09 13:45:32 +00:00
Qi Xiao
e74cda7bc3 website/cmd/md2html: Reduce dependency on Elvish packages.
This command used to depend on pkg/mods/doc to access the embedded .elv, which
in turn depends on all the packages that implement builtin modules. The latter
set of packages depends on almost all the Elvish packages transitively. As a
result, almost any change in any Elvish package will trigger a rebuild of this
command and the whole website.

This commit minimizes the dependency on Elvish packages by having it read the
.elv files during runtime instead (enabled by
9112eb1ab2).

Additionally:

- Move HighlightCodeBlock, needed by website/cmd/md2html, from pkg/mods/doc
  to pkg/elvdoc. Moving it is necessary to completely remove the dependency of
  website/cmd/md2html on pkg/mods/doc.

- Remove the dependency of pkg/edit/highlight on pkg/eval. It only uses
  eval.UnpackCompilationErrors; move this work to the supplied Check function.
  This removes the transitive dependency of website/cmd/md2html on pkg/eval.

- Augment website/tools/md-deps to recognize @module lines and add dependency on
  the corresponding .elv files.
2024-01-09 13:36:57 +00:00
Qi Xiao
1cfe72a692 website/cmd/md2html: Fix [foo]() (unqualified) outside builtin.html.
This syntax has been documented to have an implicit destination of
builtin.html#foo, but it never worked correctly outside builtin.html itself.

Also do some minor cleanups of the package, including removing bogus package
godocs that were inherited from the previous version where the components were
separate programs.
2024-01-08 22:45:28 +00:00
Qi Xiao
9112eb1ab2 Simplify how .elv files are embedded for builtin documentation.
Instead of having each individual module embed their .elv files and collect all
of them in pkg/mods/doc, have a single embed.FS at pkg that includes everything,
and use that pkg/mods/doc.

Implement a function that extracts all module elvdocs, and put it in pkg/elvdoc.
2024-01-08 16:44:35 +00:00
Qi Xiao
791b4857e1 pkg/eval/evaltest: Fix the bytes output error message. 2024-01-08 15:44:14 +00:00
Qi Xiao
e583ed0c3c pkg/md: Minor wording updates to godoc. 2024-01-04 16:39:45 +00:00
Qi Xiao
2481b755ff pkg/mods/os: Replace use of ld with os:stat in a test. 2024-01-04 11:52:05 +00:00
Qi Xiao
a780ff71a9 pkg/mods/os: Fix test on Windows. 2024-01-04 11:51:06 +00:00
Qi Xiao
f2fe6af218 CONTRIBUTING.md: Describe my role more accurately.
"Project lead" is quite vague. Make it clear that I'm the only person with
direct commit access.
2024-01-04 11:44:25 +00:00
Qi Xiao
d5e66c23bb website/README.md: Use elvish-transcript as the tag for a ttyshot example. 2024-01-03 22:13:31 +00:00
Qi Xiao
cf9ec15fa6 Implement os:chmod.
This supersedes #1730.
2024-01-03 22:02:57 +00:00
Qi Xiao
266e01d474 Reformat os.md to placate the style checker 2024-01-03 12:05:00 +00:00
Wyatt Campbell
a1a56e9789 Changed os reference documentation to use follow-symlink instead of old eval-symlinks 2024-01-03 12:05:00 +00:00
Qi Xiao
66dc7c9bf0
Merge pull request #1740 from krader1961/issue-1738-key-down
Fix edit:insert:binding regression
2024-01-03 11:48:57 +00:00
Qi Xiao
d86b61cac9 Fix broken links in d.elv files. 2024-01-02 19:38:14 +00:00
Qi Xiao
8e67588090 pkg/eval: Remove unused toFloat64. 2024-01-02 19:34:31 +00:00
Qi Xiao
4fd1b9525f Document deprecation of eawk and removal of float64 in release notes. 2024-01-02 19:33:37 +00:00
Qi Xiao
1865db6542 Merge branch 'merge-eawk-sep' 2024-01-02 15:11:55 +00:00
Qi Xiao
7d38243540 Remove float64, and deprecate eawk from 0.20.0. 2024-01-02 15:11:38 +00:00
Qi Xiao
e4564688bf Rename eawk -> re:awk.
Also rename &posix to &sep-posix, and add &sep-longest.

The original eawk name is documented as deprecated but doesn't emit deprecation
warnings during compilation yet; this will be fixed in the next commit.
2024-01-02 15:07:37 +00:00
Qi Xiao
e105493ac8 pkg/cli: Fix the height distribution algorithm to match the comment. 2023-12-31 21:19:32 +00:00