Commit Graph

6447 Commits

Author SHA1 Message Date
Qi Xiao
c9e26cc20f pkg/prog: Bump deprecation level to 20.
Also add support for setting deprecation level in transcript tests.
2024-02-06 14:16:10 +01:00
Qi Xiao
7e0b6ee8e6 tools/pre-push: Include cross-compilation check for tests too. 2024-02-01 15:02:39 +00:00
Qi Xiao
aea0e08202 pkg/mods/unix: Fix test on Windows. 2024-02-01 14:51:55 +00:00
Qi Xiao
cd621b10da CONTRIBUTING.md: Document how to mock dependencies. 2024-02-01 14:46:37 +00:00
Qi Xiao
d7fe04414b pkg/eval/evaltest: Import all builtin modules.
This removes the need for various "use-foo" setups for the standard library
modules - test code can just call "use foo" like normal Elvish code.
2024-02-01 14:46:37 +00:00
Qi Xiao
0afb509d29 Make all evaltest callsites external tests. 2024-02-01 14:02:05 +00:00
Qi Xiao
4bc73cb1f6 pkg/mods/unix: Fix test for FreeBSD.
This fixes #1763.
2024-02-01 11:21:33 +00:00
Qi Xiao
16ac1cce55 .cirrus.yml: Disable ASLR on FreeBSD so that the tests actually run.
go test -race is not compatible with ASLR, but a current Go bug causes the test
to still appear as successful: https://github.com/golang/go/issues/65425.

This commit should result in a test failure on Cirrus CI's FreeBSD runner,
because there's currently a FreeBSD-specific bug in a test case (#1763).
2024-02-01 11:14:00 +00:00
Qi Xiao
2ee156b6d2 pkg/mods/os: Set umask to 0 in mkdir &perm tests.
This fixes #1762.
2024-01-31 23:18:57 +00:00
Qi Xiao
b1815833a9 vscode: Simplify .gitignore. 2024-01-31 09:48:56 +00:00
Qi Xiao
d4f11db983 pkg/eval/evaltest: Remove the old testing framework. 2024-01-30 20:53:56 +00:00
Qi Xiao
27495be1b9 Fixup for #1760.
- Use standard error types.

- Support float64 that stores an integer.

- Don't incur unnecessary overhead for int arguments.
2024-01-30 20:28:01 +00:00
Qi Xiao
183927cffc Convert tests to transcript tests. 2024-01-30 20:21:39 +00:00
Qi Xiao
747a34aef1 pkg/eval/evaltest: Generate .elvts files from non-transcript tests.
This is done implicitly in evaltest.Run. This commit will be reverted after the
.elvts files are generated and cleaned up.
2024-01-30 20:15:58 +00:00
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