Commit Graph

5429 Commits

Author SHA1 Message Date
Kurtis Rader
659bd5fa68 unix:umask should accept int number type
Fixes #1356
2021-07-12 20:38:22 +01:00
Qi Xiao
ebf02e3a91 Fix build on Go 1.15. 2021-07-09 01:30:26 +01:00
Qi Xiao
be84cb0a86 Explicitly handle -h as an unsupported flag. 2021-07-09 01:16:19 +01:00
Qi Xiao
8f18fafde9 Fix Go version in GitHub Actions config. 2021-07-08 00:17:55 +01:00
Qi Xiao
671c76be00 Add a lint Makefile target and CI task.
Both run staticcheck and go vet (but not golint).

Also make some small changes necessary to make the codebase lint-free under
staticcheck.
2021-07-08 00:13:38 +01:00
Qi Xiao
d15218f11e Fixup for #1354. 2021-07-07 23:25:01 +01:00
Kurtis Rader
85c499f110 Lint cleanups
This change addresses issues reported by the `staticcheck` tool and a
couple reported by the `golint` tool. It also adds missing issue links
to a couple of entries in the release notes. This change deliberately
does not address these warnings since it is unclear whether the project
owner would prefer to suppress or address them:

    pkg/store/cmd.go:8:2: should not use dot imports (ST1001)
    pkg/store/db_store.go:10:2: should not use dot imports (ST1001)
    pkg/store/dir.go:8:2: should not use dot imports (ST1001)
2021-07-07 23:21:02 +01:00
Qi Xiao
4052789230 Add a vet target to Makefile, and a vet job to GitHub CI. 2021-07-03 20:38:49 +01:00
Qi Xiao
00c7205e81 Fixup for #1348. 2021-07-03 20:34:56 +01:00
Kurtis Rader
3ba0397c34 Add buildinfo and version vars
Introduce `builtin:buildinfo` and `builtin:version` vars. This also
changes the `-buildinfo -json` implementation to use the standard
encoding/json package rather than handcrafting the JSON string.

This also fixes three incorrect spellings of "overridden". Normally I would
do those in a separate change but since there are only three instances,
one of which one was legitimately part of this change, I decided to bundle
the other two.
2021-07-03 20:21:40 +01:00
Kurtis Rader
de9ae18fa8 Fix go vet error about unreachable code 2021-07-03 20:00:59 +01:00
Qi Xiao
fc887b2466 Expand the elvdoc for edit:notify. 2021-06-28 15:10:58 +01:00
Qi Xiao
75a3d5bfb3 Add back edit:notify.
Also correct the doc for return-{line eof}.
2021-06-28 15:09:39 +01:00
Qi Xiao
9981b2a777 Reduce the flakiness of TestPeach with some random jitter.
There was a recent failure of the test that checks peach is
nondeterministic: https://github.com/elves/elvish/runs/2926941131

The failure can be reproduced reliably when setting GOMAXPROCS=1.
However, GitHub Action's Windows runner has two CPU cores, which means
GOMAXPROCS should be 2. Presumably, during that particular one, one of
the cores is occupied by another process, so Go had to run the
goroutines in order on one CPU core.

Go's time.Sleep yields the current goroutine and allow other scheduled
goroutines to run on the same thread. As a result, adding a random
jitter guarantees nondeterminism in execution order, even if only one
CPU core is available to execute threads.

Also run the nondeterminism check in an infinite loop.
2021-06-28 00:46:27 +01:00
Qi Xiao
8c97ed2184 pkg/daemon: Don't depend on net.ErrClosed.
It was added in Go 1.16, but we still support building with Go 1.15.
2021-06-28 00:13:14 +01:00
Qi Xiao
3b390f0792 pkg/daemon: Be slightly less chatty in logs. 2021-06-27 23:57:01 +01:00
Qi Xiao
480bca8f34 Add a missing cleanup in progtest_test.go.
The missing cleanup is leaving some directories unremoved in the system temporary directory.
2021-06-27 23:35:43 +01:00
Qi Xiao
42867d56ba Remove the -bin flag.
Always determine it with os.Executable() instead.
2021-06-27 23:12:09 +01:00
Qi Xiao
7364eff3da Mark internal flags as such in their usage messages. 2021-06-27 22:58:12 +01:00
Qi Xiao
a12e1be189 Implement Hash for *big.Int and *big.Rat. 2021-06-27 17:01:12 +01:00
Qi Xiao
4afab8804b Fixup for #1342. 2021-06-27 16:41:07 +01:00
Kurtis Rader
3da541c719 Other float64 cases that should be generalized
While pondering issue #1340 I looked at the other `case float64:`
blocks. This change generalizes the few places that need it.

Fixes #1340
2021-06-27 16:32:38 +01:00
Kurtis Rader
d303c37987 Test more combinations of Text/Segment+num
This fixes the *Segment.Concat and RConcat methods to handle the new
number types. It also adds more tests of concatenation with the "Text"
and "Segment" types with number types.

Related #1340
2021-06-27 16:32:38 +01:00
Qi Xiao
3d49f02593 Document that "eq" requires values to have the same type to be considered equal.
This fixes #1288.
2021-06-27 01:54:31 +01:00
Qi Xiao
fc632556ca Document the reader-gone mechanism in language ref and release notes.
This fixes #952.
2021-06-27 01:29:14 +01:00
Qi Xiao
5fa39e1155 Fix the sequencing between closing pipes and setting readerGone.
For some reason this wrong sequencing was only discovered on FreeBSD, and the
test reliably pass on macOS (likely differences in scheduling algorithms).

Also make the bug a bit easier to reproduce on FreeBSD by using an external
command on the reader side. Builtin commands are too quick to execute.
2021-06-25 13:51:52 +01:00
Qi Xiao
78852916a0 Change new tests in str_test.go to use backquote for consistency. 2021-06-24 23:28:10 +01:00
Qi Xiao
82b9bddb15 Test almost all commands correctly bubble output errors.
Also make the helper thatOutputErrorIsBubbled more precise by matching for the
exact error that is thrown.
2021-06-24 23:24:43 +01:00
Qi Xiao
20274d3245 pkg/edit: Test edit builtins bubble output errors.
Two different strategies are used:

- For commands that don't actually depend on the editor (but happens to live
  inside the edit: module), their tests are changed to use the evaltest
  framework.

- For commands that do depend on the editor, a new helper
  testThatOutputErrorIsBubbled is used to test them.

Also fix a bug where edit:complete-getopt does not correctly bubble the
exception thrown from callbacks, and where matchers do not bubble output errors.
2021-06-24 22:46:49 +01:00
Qi Xiao
a3fe485b22 pkg/eval: Test that all value-outputting commands throw on write error. 2021-06-22 00:40:45 +01:00
Qi Xiao
ce08c4a7d5 Throw exception when writing values to a port without a value component.
This is done by generalizing the mechanism used to detect that the reader of
value output has terminated.
2021-06-22 00:35:30 +01:00
Qi Xiao
f4cb00e618 pkg/eval: Test that all byte-outputting commands throw on write error. 2021-06-21 23:39:24 +01:00
Qi Xiao
70cb56b568 Merge branch 'master' into reader-gone 2021-06-20 22:22:37 +01:00
Qi Xiao
75fc7eb839 Don't panic when plugin's Ns variable has wrong type. 2021-06-20 22:13:49 +01:00
Qi Xiao
30a93948d7 Add back link to internal API doc.
pkg.go.dev supports @master to get the latest (unpublished) version.
2021-06-20 22:08:01 +01:00
Qi Xiao
464bdf58d1 Fixup for #1338. 2021-06-20 22:05:18 +01:00
Kolby Crouch
917b6eeefc Add plugin support 2021-06-20 21:11:32 +01:00
Qi Xiao
a7c4bbb00f pkg/eval: Improve coverage for compile_value.go.
Most of the remaining untested lines have a dependency on fsutil.GetHome.
2021-06-20 19:14:12 +01:00
Qi Xiao
4776c16b2f Add more test for special forms.
Plus some minor test-related changes.
2021-06-20 18:18:45 +01:00
Diego Zamboni
7672fa5952 Completer API: syntax of edit:complex-candidate
Removed use of no-longer-existing &display-suffix and &style options,
and pointed to the documentation for details.
2021-06-20 16:57:39 +01:00
Qi Xiao
a8626bce1b Fixup for #1339
- Use explict ./ for consistency when invoking the script

- Rename script to "prune-cover.sh"

- Build ignore pattern in temporary file, and use grep -f to read it

- Use grep -F for correctness (path can contain dots)

- Add comment in .codecov.yml
2021-06-20 16:39:36 +01:00
Kurtis Rader
c64e2ebfa9 make cover now ignores same files as Codecov
Running `make cover` includes code in its report that is explicitly
excluded from the https://codecov.io/gh/elves/elvish/ report. This change
causes both reports to include/exclude the same source files.
2021-06-20 16:18:28 +01:00
Qi Xiao
6e75f3468c Move API of pkg/store into pkg/storedefs.
This makes the nodaemon entrypoint not depend on boltdb at all, reducing its
size by 100KB (on darwin-arm64).
2021-06-19 01:54:00 +01:00
Qi Xiao
d6464280f2 Remove direct dependency of pkg/shell on the daemon implementation.
The dependency is injected via a field in shell.Program.

Also add an alternative entrypoint, cmd/nodaemon/elvish, which does not include
the daemon server or client.
2021-06-19 01:43:30 +01:00
Qi Xiao
cfb6134236 Remove daemon:spawn.
The daemon module has never been documented and is not used by any code on GitHub:
https://github.com/search?q=%22use+daemon%22+extension%3Aelv&type=Code&ref=advsearch&l=&l=
arch&l=&l=
2021-06-19 01:07:29 +01:00
Qi Xiao
27eec7c8ee Reorganize the daemon module.
* Move client, spawning and activation code into pkg/daemon/client.

* Move API types into pkg/daemon/daemondefs.
2021-06-19 01:06:11 +01:00
Qi Xiao
6ced40733c pkg/eval: Fix EPIPE on Windows.
The syscall package exposes an EPIPE on Windows, but it's not what Windows APIs
return. The error number 232 is what is semantically EPIPE.
2021-06-18 00:45:25 +01:00
Qi Xiao
f3c08d78b2 cmd/examples/win_tty: Only show keyboard events and in a nicer format. 2021-06-18 00:29:24 +01:00
Qi Xiao
53dbece608 Fix style. 2021-06-18 00:16:20 +01:00
Qi Xiao
657b73122f Change all builtin commands writing value output to surface ReaderGone.
Also replace (*Frame).OutputChan with (*Frame).ValueOutput, which returns a
small interface for writing to the value output that is also aware when the
reader is gone.
2021-06-18 00:14:59 +01:00