Commit graph

748 commits

Author SHA1 Message Date
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
Fabian Homborg
f67a9f2ee7 Port another part of test1 to littlecheck
This time it's redirections
2020-02-08 18:21:05 +01:00
Fabian Homborg
5e6c9508e9 Port a part of test1 to littlecheck
Test1 is a grab bag of stuff, so we need to separate it.

This part is concerned with for-loops, so we move it to loops.fish
2020-02-08 17:49:02 +01:00
Fabian Homborg
ee8ca246f8 Port test8 to littlecheck
This one tests a bunch of separate stuff, so we put it into a few
different files.

The main, new one is "slices.fish", which tests various index expressions.
2020-02-08 15:55:10 +01:00
Fabian Homborg
22edf3213f Port "test4" to littlecheck
It has to do with scoping, so call it "scoping.fish".
2020-02-08 15:54:58 +01:00
Fabian Homborg
6daab9c41f Port while test to littlecheck
And we're gonna add more loop stuff, so port it to a file called "loop.fish"
2020-02-08 15:21:22 +01:00
Fabian Homborg
0ddbd8d318 Fix typo in bad options test
This had a stray `}`, which made one possible message:

    unknown option -- Z}

with a literal `}`, which broke on NetBSD, which has that
message.
2020-02-08 13:30:48 +01:00
Fabian Homborg
cdf6260d70 Port fish_opt tests to littlecheck
It's a wrapper for argparse, so just put it in argparse.fish.
2020-02-08 12:34:43 +01:00
Fabian Homborg
849f27912e Port parameter_expansion test to littlecheck
Just put it in expansion.fish.
2020-02-08 11:16:53 +01:00
Fabian Homborg
e9b4f5f0ab Replace references to ".../test/root/bin/fish" in the checks 2020-02-08 11:06:36 +01:00
Fabian Homborg
884f347be6 Port "test6" to littlecheck
It's related to `complete`, so put it in complete.fish
2020-02-08 10:55:59 +01:00
Fabian Homborg
109a8b07a7 Port "test5" to littlecheck
Put the switch-related stuff in switch.fish, and the wildcard-related
stuff in wildcard.fish.
2020-02-08 10:53:50 +01:00
Fabian Homborg
e3ccc310e2 Port read test to littlecheck
This was a tad annoying because of all the messing with variables, and
because I insisted on getting it all into the existing read.fish.
2020-02-08 10:38:43 +01:00
Fabian Homborg
bf7629462a Port some small tests to littlecheck 2020-02-08 10:38:11 +01:00
Fabian Homborg
8bd97d087d Port set test to littlecheck
Just add it to set.fish. There may be some duplicated ones here, but
that's for another time.
2020-02-08 09:58:27 +01:00
Fabian Homborg
0ddf04b637 Port contains_opt test to littlecheck
And make it one file.
2020-02-08 09:51:52 +01:00