Commit Graph

31 Commits

Author SHA1 Message Date
Qi Xiao
980cf009ca Parse comment blocks preceding var and fn declarations as doc comments.
Convert all .elv files (including .d.elv files) to use this new format.
2022-11-22 22:59:31 +00:00
Qi Xiao
4afbb71c07 Move pkg/testutil/must.go to a new pkg/must. 2022-06-20 20:29:14 +01:00
Qi Xiao
2506b578b9 pkg/shell: Test against XDG environment variables.
Also fix how $XDG_DATA_DIRS is handled.
2022-06-19 14:30:37 +01:00
Qi Xiao
2c30cf9806 Fix staticcheck errors on Windows. 2022-06-05 22:46:24 +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
Qi Xiao
3a3b8f5700 pkg/edit/complete: Change Complete to take an Evaler.
The PureEvaler abstraction made things unnecessarily complex; it's better to
just create a real Evaler for tests is pretty.

The Evaler has a new ReplaceBuiltin method to make it easier to construct the
expected test result.
2022-04-11 21:39:29 +01:00
Qi Xiao
51e4d97568 interface{} -> any now that Elvish requires Go 1.18. 2022-03-20 16:17:19 +00:00
Qi Xiao
f7cb556d9b Require Go 1.18.
- Run "go fix" to remove legacy build tags

- Use staticcheck@master until it has a release that supports Go 1.18

- Turn off autocrlf for Windows tasks
2022-03-20 15:28:23 +00:00
Qi Xiao
5b490475e7 pkg/testutil: ScaledMs -> Scaled, takes a time.Duration instead. 2021-10-05 01:02:54 +01:00
Qi Xiao
be56f72729 pkg/testutil: Add utility for setting umask during tests. 2021-09-12 14:42:06 +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
d0be34c227 Run gofmt with Go 1.17.
This has created a lot of //go:build lines.
2021-08-23 00:19:49 +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
cc47e8c12d pkg/testutil: Create parent dir in MustCreateEmpty and MustWriteFile.
Also refactor the implementations to use the Must function more.
2021-08-06 21:30:22 +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
Qi Xiao
3f0e89d223 pkg/eval/vals: Test expected panics in num.go. 2021-06-15 19:11:57 +01:00
Qi Xiao
3d078ec653 pkg/eval/mods/path: Skip symlink tests if unable to create symlinks.
Creating symlinks requires a special permission on Windows, which the
use may not have.

Also remove the support for symlinks in testutil.ApplyDir. Because of
this issue on Windows, any test that requires creating symlinks needs to
be broken out to an individual test case, meaning that symlinks can't be
created alongside other files, so there is less benefit of keeping it
inside the same Dir structure.
2021-05-08 13:22:21 +01:00
Qi Xiao
b80f9ed09e pkg/eval/mods/path: Fix test on Windows. 2021-05-08 02:32:42 +01:00
Kurtis Rader
12980c2719 Some golint cleanups 2021-04-05 15:31:53 +01:00
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Kurtis Rader
be712d5405
Introduce the path: module (#1203)
* Introduce the `path:` module

This is based on https://github.com/elves/elvish/pull/1084 by @kolbycrouch
submitted five months ago. It addresses all of the feedback on that
change and includes other documentation and unit test improvements. It
also includes a couple of extensions to the original P.R., such as a
`path:is-abs` command.

I decided to resurrect that change because I want better support for
filesystem path manipulation so that users can replace non-portable
external commands such as `realpath` and `find` with Elvish builtins. This
is a baby step towards that goal.

Related #849

* Add a `path:is-regular` command

This adds a `path:is-regular` command.  This is for symmetry with the
`path:is-dir` command and the glob `[type:regular]` modifier.

It also adds support for symlinks in the `testutil.Applydir` function
and change the path unit test to use it.

* Rename path:real to path:eval-symlinks
2021-01-16 23:21:33 +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
Kurtis Rader
a943dc764a Improve navigation mode corner cases
There are some Navigation mode corner cases whose current behavior is
surprising. Such as inserting a space before the filename when the space
isn't wanted or redundant. Also, selecting an empty directory and pressing
Enter should insert nothing rather than an empty string.

Fixes #1169
2020-11-07 13:17:00 -05:00
Qi Xiao
f3c2185dae pkg/eval/evaltest: Move Must* functions to the testutil package.
Also exclude those functions from test coverage calculation.
2020-09-04 21:57:20 +01:00
Qi Xiao
d27e7ee254 pkg/testutil: Remove InTestDirWithSetup. 2020-09-04 21:42:19 +01:00
Qi Xiao
b271a85279 pkg/eval/evaltest: Move InTempHome to pkg/testutil. 2020-09-03 06:55:14 +01:00
Qi Xiao
48919bcb24 pkg/: Move test utilities from util/ to testutil/. 2020-09-03 04:55:16 +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
Kurtis Rader
a4e539c823 Replace "ELVISH_TEST_TIME_SCALE" literals with a constant 2020-08-16 14:05:13 +01:00
Qi Xiao
770fd8e6c4 Scale all test timeouts with $ELVISH_TEST_TIME_SCALE. 2020-04-03 22:12:20 +01:00