Commit Graph

4783 Commits

Author SHA1 Message Date
Kurtis Rader
6c07af8dab Add randint command unit tests
This results in pkg/eval/builtin_fn_num.go having only
one untested statement and that is being discussed in
https://github.com/elves/elvish/issues/1099.

Related #1062
2020-08-16 16:57:41 +01:00
Kurtis Rader
5d78bab127 Add basic tests for the *-external builtins
This adds basic tests for three functions in pkg/eval/builtin_fn_cmd.go
that implement the `external`, `has-external`, and `search-external`
builtin commands. TBD is how to test those commands on MS Windows.

Related #1062
2020-08-16 16:54:33 +01:00
Kurtis Rader
1b200c4bd9 Validate a for loop corner case
This exercises the first failure condition in the `evalForVar` function.
Thus bringing coverage of pkg/eval/value_helper.go to 100%.

Related #1062
2020-08-16 16:52:47 +01:00
Kurtis Rader
28798ac053 Convert "XXX" to "TODO" comments
I stumbled across a comment that began with "XXX". It was clearly meant as
a "TODO" comment. This changes all such occurrences. However, a few "XXX"
comments are ambiguous and a better prefix might be "WARNING". The "TODO"
prefix at least ensures someone, eventually, looks into the situation
and either rewords the comment or fixes the problem. This change means
everyone can assume searching for "// TODO" will find all such comments
rather than requiring they also know to search for "// XXX".
2020-08-16 16:29:34 +01:00
Qi Xiao
d5df47f986 Deprecate has-{prefix suffix}. 2020-08-16 16:27:24 +01:00
Qi Xiao
9b754d44d8 Remove the path attribute of the output of src. 2020-08-16 16:23:01 +01:00
Qi Xiao
e28ba5d6cd Remove support for &display-suffix in edit:complex-candidate. 2020-08-16 16:21:29 +01:00
Qi Xiao
0c2d05f260 Remove support for using \ for line continuation. 2020-08-16 16:16:24 +01:00
Qi Xiao
bb24b63356 Remove builtin commands deprecated in v0.14.0. 2020-08-16 16:10:58 +01:00
Qi Xiao
2fb2c8e4a3 Fix the deprecation warnings for "ord" and "chr". 2020-08-16 16:02:48 +01:00
Qi Xiao
ba36492d16 .cirrus.yml: Bump test time scale to 20. 2020-08-16 15:50:46 +01:00
Qi Xiao
de64aa9db3 Release 0.14.1. 2020-08-16 14:40:38 +01:00
Qi Xiao
a90e8eb75d Revert "Eliminate sys.Ioctl"
Results in "failed to put myself in foreground" errors.

This reverts commit bea90271b0.
2020-08-16 14:23:37 +01:00
Kurtis Rader
bea90271b0 Eliminate sys.Ioctl
I started by writing tests for sys.Ioctl but after I had 100% coverage
of that function it occurred to me the function could be eliminated.

Related #1062
2020-08-16 14:14:48 +01:00
Qi Xiao
8f410a24be pkg/util: Move environment variable names to a new package.
Also document that this package should be broken up.
2020-08-16 14:12:48 +01:00
Qi Xiao
8aa9c26ba2 Small fixup for #1092.
* Call decSHLVL from execFn.

* Rephrase doc comment.
2020-08-16 14:08:48 +01:00
Kurtis Rader
30d1161ded Replace "USERNAME" literals with a constant 2020-08-16 14:05:13 +01:00
Kurtis Rader
a4e539c823 Replace "ELVISH_TEST_TIME_SCALE" literals with a constant 2020-08-16 14:05:13 +01:00
Kurtis Rader
947ac39876 Replace "XDG_RUNTIME_DIR" literals with a constant 2020-08-16 14:05:13 +01:00
Kurtis Rader
e04c503431 Replace "LS_COLORS" literals with a constant 2020-08-16 14:05:13 +01:00
Kurtis Rader
b9d515dd78 Replace "PATHEXT" literals with a constant 2020-08-16 14:05:13 +01:00
Kurtis Rader
b2c7746bf6 Replace "PATH" literals with a constant 2020-08-16 14:05:13 +01:00
Kurtis Rader
19f315e28a Replace "PWD" literals with a constant 2020-08-16 14:05:13 +01:00
Kurtis Rader
f656f9511b Replace "HOME" literals with a constant 2020-08-16 14:05:13 +01:00
Kurtis Rader
ade5fa6c76 Fix exec handling of $E:SHLVL
Fixes #1091
2020-08-16 14:05:13 +01:00
Qi Xiao
af92608f07 Document style guide for the doc comment of unexported types and functions. 2020-08-16 14:00:04 +01:00
Qi Xiao
239ce3ec0d pkg/eval/testutil.go: Expand the comments on the Throws* methods. 2020-08-16 13:51:48 +01:00
Qi Xiao
e2f08af91b Change slice syntax to use .. instead of :.
Also support ..= for closed-range slices, a la Rust.

The old syntax is still supported, but deprecated.

This fixes #669.
2020-08-15 22:52:50 +01:00
Qi Xiao
b2b18bff97 Bump minimal Go requirement to >= 1.14, now that 1.15 has been released. 2020-08-13 22:41:57 +01:00
Qi Xiao
0c72fcd5b1 Small fixup for #1081. 2020-08-13 22:14:16 +01:00
Gabriel Rauter
1124c10b56
Add str:from-utf8-bytes, str:to-utf8-bytes and move builtin ord and chr to str module (#1081)
* pkg/eval/str: move builtin ord and chr to str

Move builtin string function ord and chr to the str module and rename to
to str:to-codepoints and str:from-codepoints respectively as suggested
in #851.

* pkg/eval/str: add from-utf8-bytes & to-utf8-bytes

Add from-utf8-bytes and to-utf8-bytes functions to the str module. This
functions differ from their *-codepoints in that they handle utf8 bytes
instead of whole codepoints. Closes #851

* pkg/eval/str: range check for codepoint and bytes

str:from-codepoints
Add check if arguments codepoints are within valid unicode range, return
an OutOfRange error otherwise. Return a BadValue error if the codepoint
isn't valid. Add/change testcases.

str:from-utf8-bytes
Add check if byte arguments are within valid range, return an OutOfRange
error otherwise. Return a BadValue error if the byte sequence isn't a
valid UTF-8 sequence. Add/change testcases.

Add additional test if piping from str:to-codepoints/str:to-utf8-bytes
to str:from-codpoints/str:from-utf8-bytes returns the original input.
2020-08-13 21:56:28 +01:00
Qi Xiao
c42755892e Pin prettier version to 2.0.5 in both CI and CONTRIBUTING.md. 2020-08-11 18:57:10 +01:00
Kurtis Rader
082052b5a8 Document double-quoted string escape sequences 2020-08-11 16:07:58 +01:00
Kurtis Rader
fbd86925a9 Prevent I/O deadlocks during shell testing
If the shell outputs more data than can be buffered the test will
deadlock. I noticed this when working on issue #661. The tests I was
writing would deadlock because a tty can buffer significantly less data
than a pipe. Even using a pipe, which typically buffers 8 to 128 KiB, this
is theoretically a problem. So use a goroutine to capture the output as it
is generated rather than reading it all at once when the test terminates.
2020-08-11 15:58:20 +01:00
Kurtis Rader
3643f252f3 Verify stdout and stderr in shell tests
While working on my next commit, to prevent I/O deadlocks, I experienced
some problems because I had a syntax error in the Elvish code to generate
the output. That wasn't immediately obvious because I had copied another
test that only tested the stdout of the shell and the syntax error was
written to stderr. This change modifies existing tests to verify both
stdout and stderr have the expected content.

Note that there are three interactive tests for which we still do not
verify the content of stderr. That's because stderr for those tests only
contains a shell prompt whose content changes each time the test is run.
TBD is modifying the interactive tests to have a predictable prompt.
2020-08-11 15:58:20 +01:00
Kurtis Rader
3300c81c8b Document break, continue, and return
Since `break`, `continue`, and `return` are builtin commands, rather
than language keywords, they should be documented on the builtin module
reference page.
2020-08-04 23:08:41 +01:00
Kurtis Rader
a3f66b52af Document underscores in number literals 2020-08-01 23:08:11 +01:00
Kurtis Rader
eb2a792301 Fix some lint warnings
In addition to an uncontroversial spelling fix this addresses several,
related, warnings produced by the `golint` tool. In general I agree with
golint that unnecessary "else" blocks should be avoided. So this change
refactors those cases.

Note: I recognize that `golint` is deprecated (see
https://github.com/golang/go/issues/38968) since it is no longer being
maintained and there is controversy about its set of warnings. Nonetheless,
it appears that the warnings it emits for this project are all reasonable
and actionable with one potential exception: the naming of the `map_`
method in pkg/eval/compile_value.go.
2020-08-01 23:07:50 +01:00
Kurtis Rader
1b5ce7f265 Fix the handling of go test -race
The `test-race-works && go test -race || go test` formulation causes
tests to be run twice on platforms that support the `-race` option if
any test fails.

Fixes #1085
2020-08-01 23:05:59 +01:00
Qi Xiao
d2e7201163
Makefile: Simplify the "test" target.
* Call "go env" just once.

* Use grep -x to match whole line.
2020-07-27 12:24:28 +01:00
Qi Xiao
a77261e4ea Makefile: Run tests with -race only on platforms that support it.
This fixes #1075.
2020-07-25 17:03:49 +01:00
Kurtis Rader
5f0b72ab4f rephrase float64 description 2020-07-25 16:25:23 +01:00
Kurtis Rader
cff229d9fa Remove two obsolete TODO comments and resolve one 2020-07-25 16:25:23 +01:00
Kurtis Rader
9858d5a545 Add missing deprecation text for explode
Also, fix trivial typo in a comment as reported at
https://goreportcard.com/report/github.com/elves/elvish
2020-07-21 22:51:53 +01:00
Qi Xiao
eb25c882ae Allow failures in the gccgo task.
This fixes #1078.
2020-07-21 22:46:28 +01:00
Qi Xiao
e5e0446c5a Warn about deprecated syntax features in imported modules.
This fixes #1072.
2020-07-15 00:04:03 +01:00
Shengjing Zhu
45b12127f6 pkg/eval: Don't hardcode signal name in test
On gccgo signal name is capitalized.
2020-07-14 20:49:03 +01:00
Shengjing Zhu
b52ca6b530 pkg/eval/platform: Add workaround for failing test on gccgo 2020-07-14 20:49:03 +01:00
Shengjing Zhu
d9454b4f4a .cirrus.yml: Add gccgo support 2020-07-14 20:49:03 +01:00
Qi Xiao
c2c6254316 pkg/edit: Fix race conditions. 2020-07-14 20:43:11 +01:00