Commit Graph

1469 Commits

Author SHA1 Message Date
Qi Xiao
bdf3ec6315 pkg/elvdoc: Keep track of which line each elvdoc block starts.
To simplify things, require that "#doc:" directives appear after the comment
block.
2024-02-18 10:23:15 +00:00
Qi Xiao
3387f454b7 pkg/elvdoc: Change the semantics of Entry.{Name Content}
The Name field now contains the qualified name, with the "$" prefix for variables.

The Content field no longer contains the usage text for functions. That is now
stored in a separate Fn field, and the FullContent method now returns what used
to be the Content field.
2024-02-17 18:43:11 +00:00
Qi Xiao
2c0cc610d8 pkg/strutil: Add JoinLines. 2024-02-17 18:43:11 +00:00
Qi Xiao
20b74b6950 pkg/transcript: Return parse result as a tree. 2024-02-17 17:57:06 +00:00
Qi Xiao
4229f88385 pkg/transcript: Minor refactoring. 2024-02-17 17:56:30 +00:00
Qi Xiao
5b1caa09b1 pkg/md: Add line number to Op. 2024-02-17 16:22:47 +00:00
Qi Xiao
d3e802e536 pkg/mods/math: Test some results at a lower precision.
This fixes the test on s390x.
2024-02-14 13:17:33 +00:00
Qi Xiao
1eb82fbc41 Require Go 1.21. 2024-02-10 17:44:46 +00:00
Qi Xiao
71a682629d Remove support for ~/.elvish. 2024-02-10 16:07:04 +00:00
Qi Xiao
56469f853b pkg/buildinfo: Bump VersionBase as v0.20.x has been branched.
Commits from this point now target v0.21.0.
2024-02-06 14:31:22 +01:00
Qi Xiao
6029a739ee pkg/buildinfo: Slightly simplify instruction for releasing. 2024-02-06 14:22:09 +01:00
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
aea0e08202 pkg/mods/unix: Fix test on Windows. 2024-02-01 14:51:55 +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
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
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
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
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
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
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
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
cf9ec15fa6 Implement os:chmod.
This supersedes #1730.
2024-01-03 22:02:57 +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