Commit graph

763 commits

Author SHA1 Message Date
Fabian Homborg
04bc16530c Ressurect a couple of test functions
Missed these, sorry!
2020-03-17 21:44:26 +01:00
Fabian Homborg
4d052da922 Remove classic ".in" test machinery
We have now entirely switched the script tests to littlecheck.

Note: This adjusts the complete_directories test, because it removes a
directory that was created before by a .in test. There's no real
change in behavior.

This does require the test directory be cleaned, or the tests will fail.

test_util gets to stay for a while longer, because it sets up the
testing env (locale and such).
2020-03-17 21:34:36 +01:00
Fabian Homborg
957526a283 Port "test9" to littlecheck
Just add it to basic.fish

This was the last .in test.
2020-03-17 21:19:41 +01:00
Fabian Homborg
fbf9d4e6f8 Port "test7" to littlecheck
Soon.
2020-03-17 20:57:45 +01:00
Fabian Homborg
e78db2bcb8 Port "test1" to littlecheck
This, together with the other testX, really just tests some basic
syntax. So let's just call it "basic".

Note that this file uses escaped newlines on purpose, so restyling it
would currently break it. I'm not sure what the best thing to do here is.
2020-03-17 20:48:40 +01:00
Fabian Homborg
2731bcec70 Port umask tests to littlecheck
This saves us from adding all these explanatory echoes.
2020-03-16 21:21:10 +01:00
Fabian Homborg
52b5afe2f8 Port expansion test to littlecheck
This one really is a lot easier to follow
2020-03-16 21:21:10 +01:00
Fabian Homborg
7e594e692c Port fish_indent tests to littlecheck 2020-03-16 21:21:10 +01:00
ridiculousfish
5f0c698601 Pass all check files to littlecheck at once
Instead of invoking littlecheck.py independently for each file, pass
all files at once. This amortizes the Python startup cost, and reduces
the total test time by ~15 seconds (!).
2020-03-15 18:16:14 -07:00
Fabian Homborg
aa629c5aca Reformat fish scripts with escaped newline changes to fish_indent 2020-03-15 21:01:11 +01:00
Fabian Homborg
7891973c9c fish_indent: Add check
This isn't quite the old-style test, but it checks some of the line
continuation stuff.

Note that littlecheck ignores leading whitespace, so testing the
actual indentation requires some more effort.
2020-03-15 21:01:11 +01:00
Fabian Homborg
cb16d9e741 fish_indent: Allow escaped newlines only for certain things
Things like

```fish
\
echo foo
```

or

```fish
echo foo; \
echo bar
```

are a formatting blunder and should be handled.

This makes it so the escaped newline is removed, and the
semicolon/token_type_end handling will then put the statements on
different lines.

One case this doesn't handle brilliantly is an escaped newline after a
pipe:

```fish
echo foo | \
cat
```

is turned into

```fish
echo foo | cat
```

which here works great, but in long pipelines can cause issues.

Pipes at the end of the line cause fish to continue parsing on the
next line, so this can just be written as

```fish
echo foo |
cat
```

for now.
2020-03-15 21:01:00 +01:00
ridiculousfish
3040486968 Use -S when invoking Python for littlecheck
This prevents needless imports. It speeds up the test time by ~2 seconds.
2020-03-09 15:08:33 -07:00
Fabian Homborg
9f984ee897 Reindent final check
This included some things in its string, so `fish_indent` would stomp
over it.
2020-03-09 19:46:43 +01:00
Fabian Homborg
9367d4ff71 Reindent functions to remove useless quotes
This does not include checks/function.fish because that currently
includes a "; end" in a message that indent would remove, breaking the test.
2020-03-09 19:46:43 +01:00
Fabian Homborg
b25f72f391 Teach fish_indent to remove useless quotes
This tries to see if quotes guard some expansion from happening. If it
detects a "weird" character it'll leave the quotes in place, even in
some cases where it might not trigger.

So

    for i in 'c' 'color'

turns into

    for i in c color

The rationale here is that these quotes are useless, wasting
space (and line length), but more importantly that they are
superstitions. They don't do anything, but look like they do.

The counter argument is that they can be kept in case of later
changes, or that they make the intent clear - "this is supposed to be
a string we pass".
2020-03-09 19:46:43 +01:00
ridiculousfish
5886b961d8 Send events more often for variable sets outside of builtin_set
When changing certain variables programmatically, ensure that events
are sent. Fixes #6653
2020-03-08 23:28:37 -07:00
ridiculousfish
29c2bce704 Use self-insert-notfirst on spaces during paste
This changes a5a643f854 to use the new self-insert-notfirst binding.
It also adds a test.
2020-03-07 13:31:55 -08:00
Norio Nomura
60fca97523 Add test to verify that the fish_postexec handler is called after SIGINT 2020-03-03 21:49:15 -08:00
ridiculousfish
17c569f6d5 Disable SIGINT handling expect test
The problem is that under TSAN, the timing of signals becomes very weird and
exposes some real race conditions. We will need to re-design how signal
event handlers work.
2020-03-03 18:15:24 -08:00
ridiculousfish
593c43663c Add a bit of a delay to signals.expect test
Unclear why this is needed.
2020-03-03 10:52:16 -08:00
ridiculousfish
b0c2eda3b4 Revert "Revert "Enable job-control in pipeline-pgroup test""
This reverts commit c9f450a93e.

Puts back job-control in this test.
2020-03-02 14:01:59 -08:00
ridiculousfish
1c5b1ff5c2 Correct a race condition in pipeline-pgroup test
This test launches two background processes and is sensitive to
interleaving of output. Fix it so that newlines are not output by
the background process.

Hopefully this fixes the flakiness of this test.
2020-03-02 14:00:57 -08:00
ridiculousfish
c9f450a93e Revert "Enable job-control in pipeline-pgroup test"
This reverts commit cdbf0a9d20.

Reverting until the tests pass consistently.
2020-03-01 23:35:53 -08:00
ridiculousfish
bc702ccb31 Fix interactive --on-signal INT handlers
f8ba0ac5bf introduced a bug where INT handlers would themselves be
cancelled, due to the signal. Defer processing handlers until the
parser is ready to execute more fish script.

Fixes the interactive case of #6649.
2020-03-01 13:31:59 -08:00
ridiculousfish
cdbf0a9d20 Enable job-control in pipeline-pgroup test
Otherwise it's not testing anything interesting
2020-02-29 18:00:19 -08:00
ridiculousfish
c5fa580948 Rationalize background-in-background procs
If a background process runs a fish function which launches another
background process, ensure that these background procs get different
pgroups. Add a test for it.
2020-02-29 15:07:09 -08:00
Johannes Altmanninger
706c1a838e Fix tests for 91fcb8c42c 2020-02-29 10:48:19 +01:00
Johannes Altmanninger
91fcb8c42c Revert "read: discard IFS delimiters before the last token"
See #6650.

This reverts commit 1410f938aa.
2020-02-29 09:53:53 +01:00
Fabian Homborg
22c0054c1e Add check to test all fish files with -n
This executes `fish --no-execute` a whole bunch of times in order to
find syntax errors in our fish scripts.

tests/ is exempt because it contains syntax errors on purpose.

This is a great idea in principle, but it takes ~4s on my system.
2020-02-26 19:15:50 +01:00
Fabian Homborg
70b8fb22e1 test: Reject nan/inf instead of crashing
I really don't want to get into the business of explaining to people
how nan != nan.

Fixes #6655.
2020-02-26 16:43:12 +01:00
Johannes Altmanninger
ccd3ac4f18 fixup test
only works interactively
2020-02-24 00:21:23 +01:00
Johannes Altmanninger
aa0e16b1a5 Skip variable assignments in status current command
Fixes #6635
2020-02-24 00:16:12 +01:00
Johannes Altmanninger
7ef7f93a90 List time as builtin, support time --help
`a=b time foo` will no longer call an external `time` command
(like it does in bash).

Fixes #6598
2020-02-23 23:42:57 +01:00
Fabian Homborg
5f9c33b50a Don't time --no-execute
This made some output for non-execution.

See #977.
2020-02-17 11:39:53 +01:00
Fabian Homborg
3f5c60e634 Silence some errors for fish --no-execute
It used to error out when a command wasn't known, even when it was a
function that would only be discovered via autoloading.

Now we just accept that a command doesn't exist when no-execute is
given - we're not gonna execute it anyway.

Also, in the same breath stop counting empty commands after expansion
and empty wildcard expansions as errors - these depend on runtime
values, so we can't verify them without executing.

Fixes #977.

(note that it still executes "time", but that's another commit)
2020-02-17 11:39:53 +01:00
Fabian Homborg
aba900a71f Reallow "2>>&1" as a redirection
Appending to an fd doesn't really make sense, but we allowed the
syntax previously and it was actually used.

It's not too harmful to allow it, so let's just do that again.

For the record: Zsh also allows it, bash doesn't.

Fixes #6614
2020-02-17 08:57:41 +01:00
Johannes Altmanninger
7517128b68 Update exports when an exported universal variable changes
Fixes #6612
2020-02-16 18:51:19 +01:00
Fabian Homborg
13b470af07 Readd ^&1 redirection
This was lost in 35671dd9f0.

Even tho we plan to drop caret redirection, while it's there it should
fully work.

Fixes #6591.
2020-02-14 20:28:46 +01:00
Fabian Homborg
0d2c11249e Ignore unreadable cwd error harder
Should fix the tests on macOS.
2020-02-14 20:09:07 +01:00
Fabian Homborg
f053cd27c6 Return glob ordering to pre-3.1 state
Glob ordering is used in a variety of places, including figuring out
conf.d and really needs to be stable.

Other ordering, like completions, is really just cosmetic and can
change if it makes for a nicer experience.

So we uncouple it by copying the wcsfilecmp from 3.0.2, which will
return the ordering to what it was in that release.

Fixes #6593
2020-02-14 19:06:19 +01:00
Fabian Homborg
7c879ed356 Let test for unreadable cwd work on macos
It has a different error. We don't care, we expect an error.
2020-02-14 18:34:07 +01:00
Fabian Homborg
ceba851d44 parser: Stop crashing when cwd isn't readable
Everything seems to be working, so instead of crashing just print an
error and return.

Fixes #6597
2020-02-14 17:57:07 +01:00
ridiculousfish
35a50d5aff Clean up the "press a key" prompt in fish_key_reader
No need for two newlines.
2020-02-13 01:08:35 -08:00
Fabian Homborg
6cccfa7cf4 tests/read: Make an error more useful
It would be nice to know what the length *is* if it's not the max.
2020-02-12 22:02:32 +01:00
Fabian Homborg
860394d1bd tests/pipestatus: Allow for command false to return 255
SOLAAAAAARIIIIIISSS!
2020-02-12 22:02:32 +01:00
Aaron Gyes
d556f04823 Revert "timer.cpp: use units like 'ms', etc. vs. "millis""
This reverts commit c01356ddd1.

Tests broken
2020-02-12 02:06:30 -08:00
Aaron Gyes
c01356ddd1 timer.cpp: use units like 'ms', etc. vs. "millis"
Change wording and omit '.00' decimal points in times
2020-02-12 01:53:48 -08:00
Johannes Altmanninger
be06f842a2 Allow to omit indices in index range expansions
Missing range limits in, say $PATH[..] default to the first/last
element, just like Python/Go/Rust slices.
2020-02-10 18:38:01 +01:00
ridiculousfish
6bf9ae9aeb Fix up --on-job-exit caller
The `function --on-job-exit caller` feature allows a command substitution
to observe when the parent job exits. This has never worked very well - in
particular it is based on job IDs, so a function that observes this will
run multiple times. Implement it properly.

Do this by having a not-recycled "internal job id".

This is only used by psub, but ensure it works properly none-the-less.
2020-02-08 16:23:25 -08:00