Commit Graph

44 Commits

Author SHA1 Message Date
Qi Xiao
dd3950cec0 Use the new testutil.Set in more places. 2022-04-11 21:55:59 +01:00
Qi Xiao
0fa5ebac68 Prepare for 0.18.0 release.
The development is now considered to be targeting 0.19.0.
2022-03-18 22:11:35 +00:00
Qi Xiao
d3a31ae193 Revamp command-line flag doc.
- Document all flags, and remove doc for removed flags.

- Update in-code flag descriptions to be more consistent with the markdown doc.
2022-03-03 00:41:39 +00:00
Kurtis Rader
24cca36d7b Document all elvish CLI flags
There was a recent question for which the answer was to use the
`-compileonly` flag but the user didn't realize that because there was
no mention on https://elv.sh/ref/command.html. Similarly, other flags,
like `-decpreation-level`, would benefit from more verbiage than shown by
`elvish -help`.
2022-03-01 23:25:22 +00:00
Qi Xiao
33a04f8dc1 Revamp flag handling in pkg/prog.
Instead of putting all possible flags in prog.Flags, flags are now registered by
the individual subprograms. The 3 flags -sock, -db and -json are shared by
multiple subprograms and still handled by the prog package.

This new design allows separating the support for -cpuprofile into a separate
subprogram, which is no longer included by the default entry point, making the
binary slightly smaller. A new entrypoint "withpprof" is created.

Also include the LSP subprogram in the nodaemon entry point.
2022-02-05 14:52:29 +00:00
Qi Xiao
ffeb3ab963 Make the LSP server part of the Elvish binary.
Also add tests.
2022-02-05 11:34:14 +00:00
Qi Xiao
6a9931e662 Bump version and deprecation level
Now that v0.17-release has been branched, the HEAD build will show deprecations
intended for 0.17.0, and be considered a pre-release version of 0.18.0.
2021-12-06 00:30:36 +00:00
Qi Xiao
a25809893e Clean up flags
- Remove the now defunct -web and -port flags.

- Document that -json also works with -compileonly.
2021-10-23 13:04:26 +01:00
Qi Xiao
3bd132b53e pkg/daemon: Rewrite test to exercise the Program. 2021-09-12 23:18:37 +01:00
Qi Xiao
e0b824bbdf Improve coverage for "no suitable subprogram" error. 2021-09-12 14:23:29 +01:00
Qi Xiao
7ef7cb9f1b pkg/eval/evaltest: Clean up godoc and some minor API details. 2021-09-12 14:13:18 +01:00
Qi Xiao
b6d69d0b30 pkg/prog/progtest: Rewrite the progtest API.
The progtest package now provides a declarative framework, modelled after
pkg/eval/evaltest. Tests that use progtest are now much more concise.
2021-09-12 14:06:05 +01:00
Qi Xiao
be3431bbbf pkg/prog: Simplify the Program interface.
Instead of a separate ShouldRun method, use a special error value to signify
that a Program should not be run.
2021-09-12 00:40:35 +01:00
Qi Xiao
9076934395 Remove most uses of the ioutil package.
https://golang.org/doc/go1.16#ioutil
2021-08-23 00:36:26 +01:00
Qi Xiao
39a93d4788 Bump Version and DeprecationLevel. 2021-08-21 16:32:24 +01:00
Qi Xiao
1cc3faa15a Make use of (*testing.T).Cleanup in more places. 2021-08-06 23:49:11 +01:00
Qi Xiao
e9d328aa16 Make use of (*testing.T).Cleanup for test cleanups.
This allows turning the following pattern in tests:

  value, cleanup := setupSomething()
  defer cleanup()

into the following:

  value := setupSomething(t)
2021-08-06 23:21:23 +01:00
Qi Xiao
adf8066819 pkg/testutil: Make MustWriteFile easier to use.
The function now take a string for the file content, and always uses 0600 for
file permission.
2021-08-06 21:38:37 +01:00
Qi Xiao
cc61a9505a pkg/prog/progtest: Implement MustWriteFile in terms of testutil.MustWriteFile. 2021-08-06 21:31:05 +01:00
Qi Xiao
e035930e49 Merge branch 'master' into xdg-dir 2021-08-05 22:36:53 +01:00
Qi Xiao
ac3b7342c9 pkg/prog/progtest: Add TestExit for testing exit code. 2021-08-05 22:22:44 +01:00
Qi Xiao
c3083d0544 pkg/prog: Add a -rc flag.
This is added for easier integration testing, but can also be useful to actually use.
2021-08-05 22:17:08 +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
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
Kurtis Rader
df3e7a9268 Add a -i CLI option
POSIX shells have a `-i` short option to force interactive mode. Some
programs, such as the `script` command, assume that option is recognized
by the shell it spawns. There isn't any reason elvish shouldn't silently
ignore that option.

Resolves #1292
2021-04-20 16:15:22 -04:00
Qi Xiao
585509007e Update for 0.15.0 release.
* Rebrand NEXT-RELEASE.md to the release notes for 0.15.0, and publish it.

* Bump default deprecation level to 15.

* Add download links in website/get/prelude.md.
2021-01-30 11:26:39 +00:00
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Qi Xiao
47d9766f5c Control deprecation warnings with a number instead of a bool.
Previously, to avoid showing deprecation warnings for the next release when the
user is running on HEAD, a boolean CLI flag -show-deprecations is introduced,
and is set to false in the master branch. The idea is that release branches will
have this default to true, so people running released versions will see
deprecations.

However, this means that people running on HEAD will never see any deprecations
unless they use this CLI flag, which is not ideal. This commit replaces the flag
bool -show-deprecations with a numerical -deprecation-level flag, which requests
deprecations that are active as of release 0.X to be shown. The default value of
this flag will be the minor version number of the *last* release, so that people
running HEAD will see as many deprecation warnings as people running the last
release would. This number will be bumped just before releases.
2021-01-19 21:37:36 +00:00
Kurtis Rader
d241243fdf Ensure the daemon doesn't have fds open on the tty
The Elvish daemon should not inherit file descriptors open on the tty.
Make the daemon's stdin open on the null device and its stdout/stderr
open on a predictable file.

Fixes #1191
2021-01-16 23:18:38 +00:00
Kurtis Rader
9c7c9cf7d9 [cleanup] trivial golint suggested changes
As with commit #eb2a792 I acknowledge that `golint` recommendations are
controversial and should not automatically be acted on. Nonetheless,
this change fixes legitimate lint issues such as copy/paste cleanups,
style problems I introduced (`i += 1` versus `i++`) or method/var comments
that are not in the preferred form.
2020-12-25 01:11:33 +00:00
Qi Xiao
11898f763a pkg/util: Break into fsutil/ and logutil/. 2020-09-03 05:27:18 +01:00
Qi Xiao
48919bcb24 pkg/: Move test utilities from util/ to testutil/. 2020-09-03 04:55:16 +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
Qi Xiao
663b10d8e2 Suppress deprecations by default.
The behavior is controlled by a global flag that will be flipped for the release
branch. A flag is available to force deprecations to be shown or hidden.
2020-04-26 21:26:53 +01:00
Qi Xiao
905447eda5 pkg/prog: Improve error handling of CPU profile, and add tests.
This addresses #944.
2020-04-25 01:04:55 +01:00
Qi Xiao
e6c5ebfc23 pkg/prog: Add tests.
This addresses #944.
2020-04-25 00:57:35 +01:00
Qi Xiao
78cae6a695 pkg/prog/{shell,web} -> pkg/{shell,web}. 2020-04-25 00:12:18 +01:00
Qi Xiao
928949077b pkg/prog: Move all Program implementations into own packages.
This fixes #985.
2020-04-25 00:12:18 +01:00
Qi Xiao
5b88057c94 pkg/prog: Remove Main; expose Run.
This is to prepare moving all the Program implementations into their respective
packages.

This addresses #985.
2020-04-25 00:12:18 +01:00
Qi Xiao
be471ec761 pkg/program -> pkg/prog. 2020-04-25 00:12:18 +01:00