Commit Graph

636 Commits

Author SHA1 Message Date
Qi Xiao
93e28d846b Fixup for #1618.
- Simplify the matcher for compilation errors.

- Various stylistic fixes.
2022-11-20 16:39:01 +00:00
Kurtis Rader
358e52a7f5 Make testing compilation errors more deterministic
A year ago I submitted a change to replace AnyError with tests for specific
errors (see https://github.com/elves/elvish/commit/87656c99).  This does
something similar for DoesNotCompile. This ensures the test does what
is implied and makes correlating specific unit tests with compilation
errors easier.

This includes a couple of changes to compilation error messages to improve
readability (IMHO) but those are not the primary purpose of this change.

Related #1560
2022-11-20 16:33:29 +00:00
Qi Xiao
a18aec1ac8 Fixup for #1598.
- Let file:is-tty always take one argument.

- Revert change to eval.ByteOutput.

- Make sys.IsATTY take a FD instead, to avoid the need to use os.NewFile. Using
  os.NewFile can cause the Go runtime to start polling the file, which
  interferes with Elvish's terminal reader.
2022-11-20 16:21:10 +00:00
Kurtis Rader
23c83323b6 Implement file:is-tty
Resolves #1263
2022-11-20 16:03:34 +00:00
Qi Xiao
6c6797b4c1 Remove use of "e.g.," and "i.e.,".
Some of the uses are replaced by plain English phrases like "such as", and the
remaining have the trailing commas removed.
2022-11-20 15:44:29 +00:00
Qi Xiao
3a0b1242ac Fixup for #1591.
- Keep more metrics than just the minimal duration.

- Change default &min-time to 1s.

- Don't allow unitless value as &min-time.

- Rename &on-run to &on-run-end, and &min-iters to &min-runs.
2022-11-20 15:13:25 +00:00
Qi Xiao
27f6ab2aa1 pkg/eval/errs: Fix misleading message in OutOfRange.Error.
The method returns a message saying that there is no valid value if ValidHigh <
ValidLow. This was useful when these fields were numbers, but since they are now
strings this no longer works.
2022-11-20 15:11:57 +00:00
Kurtis Rader
eb1770f2b9 Add a benchmark command
Resolves #1586
2022-10-23 23:37:07 +01:00
Qi Xiao
3ff0e4bcd9 pkg/eval: Check whether variable name is empty when parsing lvalue.
This fixes #1560.
2022-10-03 04:34:05 +01:00
Kurtis Rader
e896ac3c0e
Improve some compilation errors (#1617)
Quote variable names appearing in some compilation errors to improve
the clarity of those errors.
2022-10-03 04:22:46 +01:00
Qi Xiao
f8f0f3e889 Fixup for #1588 2022-08-29 12:29:24 +01:00
Kurtis Rader
eed6a995dd
Support comparing booleans (#1588)
Fixes #1585
2022-08-29 12:25:54 +01:00
Kurtis Rader
a549dba0ba Add missing "usage" text for three commands
I noticed this when testing my `help` command and noticed that
`help builtin:` produced three lines of "usage" text that did not
include a function or variable name.
2022-08-29 12:10:31 +01:00
Qi Xiao
8cb125c911 Improve documentation for %. 2022-08-29 12:09:43 +01:00
Kurtis Rader
c6e10f12a2 Some minor documentation fixes
Mostly elimination of duplicated words but also a few other fixes such
as the output of commands such as `%`.
2022-08-29 12:04:59 +01:00
Qi Xiao
629cc9c85e Fix elvdoc for compact. 2022-08-29 11:08:19 +01:00
Qi Xiao
acf470f104 New "compact" command.
This fixes #1453.
2022-08-28 22:58:37 +01:00
Qi Xiao
181c4dde55 pkg/eval: Create builtin_fn_stream_test.go.
Tests for functions defined in builtin_fn_stream.go are moved there.
2022-08-28 22:08:00 +01:00
Qi Xiao
3dcfa88c8d Remove go1.18 build tags as 1.18 is required. 2022-08-08 12:29:33 +01:00
Qi Xiao
1b8ccdbdbc pkg/eval: Deduplicate range implementations with generics. 2022-08-08 12:28:47 +01:00
Qi Xiao
551e246d96 webiste/cmd/macros: Strip leading $ from anchor targets of @cf.
Also add previously missing $'s in @cf arguments. This doesn't matter for the
anchor target, but matters for the link text.
2022-08-08 00:09:17 +01:00
Qi Xiao
9794eecd68 Add new runtime module.
This module provides $runtime:{lib-dirs rc-path effective-rc-path}. It will
likely grow in future.

This fixes #1385.
2022-08-08 00:09:02 +01:00
Qi Xiao
2e788c846d Run gofmt.
https://tip.golang.org/doc/go1.19#go-doc
2022-08-07 22:30:11 +01:00
Qi Xiao
bd569f8132 pkg/eval: Add a note about the use of echo in after-chdir's example. 2022-08-07 22:25:47 +01:00
Qi Xiao
46008d111b Add -randseed to set RNG seed.
This is used in ttyshots to get deterministic outputs.

This command is prefixed with - since I'd like to eventually move rand and
randint into their own module, so this command will be moved too.
2022-08-07 11:32:52 +01:00
Qi Xiao
41fc578002 Merge branch 'ttyshot' 2022-08-04 23:41:11 +01:00
Qi Xiao
40275b97f1 Rewrite elvdoc for styled and styled-segment.
Also document the behavior of ignoring SGR state in the 0.19.0 release notes.
2022-07-24 14:44:16 +01:00
Qi Xiao
42c6c3b1aa pkg/ui: Make styled text context-insensitive, and remove the "default" color.
Styled text is not supposed to "inherit" the current SGR styling context when
written to the terminal. This has always been the intention, but not correctly
implemented. This commit fixes that for both styled segments and styled texts.
Tests are amended to account for the difference in the output.

With context insensitivity correctly implemented, there is now no need for a
"default" color. It is functionally equivalent to a lack of color.

The parsing of SGR still needs to be aware of the codes 39 (default foreground)
and 49 (default background), but these codes are now translated into FgDefault
and BgDefault, which resets the foreground and background color fields.
2022-07-24 14:31:02 +01:00
Qi Xiao
ed97664695 pkg/eval: Test the exit command by faking os.Exit. 2022-06-23 20:25:01 +01:00
Qi Xiao
e0292dd298 Get coverage on IsStructMap methods with a hack. 2022-06-20 22:08:19 +01:00
Qi Xiao
4afbb71c07 Move pkg/testutil/must.go to a new pkg/must. 2022-06-20 20:29:14 +01:00
Qi Xiao
d2c005df45 pkg/eval: Test import of module with invalid UTF-8. 2022-06-20 00:14:25 +01:00
Qi Xiao
786b679509 pkg/eval: Cover more tilde expansion errors. 2022-06-20 00:08:33 +01:00
Qi Xiao
6723b9a226 Use consistent pattern for mutating variables in tests.
- Use testutil.Set.

- Only export such variables to tests.
2022-06-19 23:56:18 +01:00
Qi Xiao
94e43cd2fd pkg/eval: Add tests for errors in tilde expansion. 2022-06-19 23:34:36 +01:00
Qi Xiao
6a1e7b3996 pkg/shell: Add more daemon-related tests.
Also:

- Remove duplicate code for closing daemon client.

- Avoid using (*testing.T).TempDir - it uses test name in the path, which can
  exceed the limit of the address when calling bind(2):
  https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_un.h.html#tag_13_6
7_04
2022-06-19 21:45:36 +01:00
Qi Xiao
75ee261fcb pkg/eval: Remove access methods for exported fields.
The exported fields are intended to be mutated directly.
2022-06-18 19:01:59 +01:00
Qi Xiao
d48b6f1843 pkg/eval/vals: Replace MakeListFromStrings with a generic MakeListSlice. 2022-06-17 16:50:38 +01:00
Qi Xiao
ae9e6d1565 Fixup for #1531.
- Fix the handling of actual occurrences of U+FFFD.

- Fix an existing bug of QuoteVariableName("$\n").
2022-06-11 21:26:32 +01:00
Kurtis Rader
d0f6858b95 Correctly encode strings with invalid UTF-8
In addition to fixing the encoding bugs standardize on \xNN notation for
bytes rather than \uNNNN; e.g., \x00 rather than \u0000.

Also, update the documentation for double-quoted strings to include the
\e sequence.

Fixes #1528
2022-06-11 20:42:06 +01:00
Qi Xiao
68bce3b4a4 Clarify error message when writing values to port not supporting it.
This fixes #1516.
2022-06-07 20:29:34 +01:00
Qi Xiao
f42c2dda61 Make init value of $f~ actually identical to $nop~.
This fixes #1519.
2022-06-07 20:20:00 +01:00
Qi Xiao
8b0c7fdb36 Fix some lint warnings found on Windows. 2022-06-05 22:01:16 +01:00
Qi Xiao
d4dd11a981 pkg/eval/vars: Deexport EnvVariable, use Unset/IsSet via interface 2022-06-05 21:47:51 +01:00
Qi Xiao
26a66284a9 Fixup for #1551. 2022-06-05 16:01:10 +01:00
Tw
d27610b3e4 Fix undefined temporary environment restoring issue
Close #1536

Signed-off-by: Tw <tw19881113@gmail.com>
2022-06-05 15:41:19 +01:00
Kurtis Rader
71cd3835bc Don't dot import pkg/tt
Qualified imports of pkg/tt outnumber unqualified (27 to 24). Improve
consistency, and clarity, by changing the dot (unqualified) imports of
that package symbols to qualified.
2022-06-04 23:39:19 +01:00
Kurtis Rader
f681a73a1d Don't dot import pkg/testutil
Qualified imports of pkg/testutil outnumber unqualified (55 to 7). Improve
consistency, and clarity, by changing the dot (unqualified) imports of
that package symbols to qualified.
2022-06-04 23:39:19 +01:00
Kurtis Rader
14321f9e82 Make parse.Source naming more consistent
Fixes #1545
2022-05-29 17:36:29 +01:00
Kurtis Rader
7bae8f2df7 Correctly handle [..=-1] list indexing
Fixes #1518
2022-05-22 20:38:16 +01:00