Commit Graph

922 Commits

Author SHA1 Message Date
Fabian Homborg
87a1e4f8b9 Remove expect
This should remove the last bits of expect from the codebase.
2020-06-13 19:28:42 +02:00
Fabian Homborg
c6dffa226f Port history test to pexpect 2020-06-13 19:24:36 +02:00
Fabian Homborg
51e3258dbe Port histfile test to pexpect 2020-06-13 18:53:01 +02:00
Fabian Homborg
25a73a77bb Unset X-bit on tests
These files are not expected to be run directly.
2020-06-13 16:18:17 +02:00
Fabian Homborg
93c3aaf5f4 Port signals test to pexpect 2020-06-13 15:38:54 +02:00
Fabian Homborg
c11457f2db Port job_summary test to pexpect 2020-06-13 15:21:40 +02:00
Fabian Homborg
a6a1c6e775 Port read tests to expect
Note: This includes a super cheesy thing to print variable contents.
The expect version has one that's a bit more elaborate (featuring a
marker setup), but tbh that doesn't seem to be worth it.

If we do need it, we can add it, but it seems more likely we'd just do
`set -S`, or do it in a check instead.
2020-06-13 15:21:40 +02:00
Fabian Homborg
aafdaea2f9 Port wait test to pexpect 2020-06-13 15:21:40 +02:00
Fabian Homborg
15a789dda0 Fix fkr tests
I had fish_key_reader *installed*, so this worked for me.

But really we have the path in $fish_key_reader, so we want to use
that variable.
2020-06-08 23:19:57 +02:00
Fabian Homborg
f66edfdec2 Port generic.expect to pexpect
Removes a dumb workaround. Huzzah!
2020-06-08 22:57:46 +02:00
Fabian Homborg
339a5a2196 Port fkr expect to pexpect 2020-06-08 22:52:18 +02:00
Fabian Homborg
cbefdb775d tests: Sleep for a bit
Gosh dangit Travis
2020-06-08 18:49:03 +02:00
Fabian Homborg
83808929a7 Remove pipestatus expect test
This doesn't really do more than the check of the same name.
2020-06-08 17:34:43 +02:00
Fabian Homborg
10fbdd34e7 Reformat pexpects
These are now python scripts
2020-06-08 17:33:04 +02:00
Fabian Homborg
3c6055c3e0 Move exit test to pexpect
This needs some subprocess magic, but otherwise it's nicely straightforward.
2020-06-08 17:31:18 +02:00
Fabian Homborg
9d523c7589 Move complete test to pexpect 2020-06-08 17:16:09 +02:00
Fabian Homborg
927aa60349 Move bind_mode_events test to pexpect 2020-06-08 17:12:49 +02:00
Fabian Homborg
7076880da9 Move commandline test to pexpect 2020-06-08 17:09:29 +02:00
ridiculousfish
8a27873598 Remove redundant expect tests
With the new pexpect based framework, bind and pipeline expect tests can
be removed.

Amusingly the complete.fish check required the existence of bind.expect.
Fix the check at the same time.
2020-06-07 14:53:17 -07:00
ridiculousfish
4ae4314e63 Improve pexpect output
Make it easier to use pexpect and to understand its error messages.
Switch to a style in tests using bound methods, which makes them
less noisy to write.
2020-06-07 14:53:17 -07:00
ridiculousfish
3b7feb38e9 Add pexpect-based interactive testing framework
This adds a new interactive test framework based on Python's pexpect. This
is intended to supplant the TCL expect-based tests.

New tests go in `tests/pexpects/`. As a proof-of-concept, the
pipeline.expect test and the (gnarly) bind.expect test are ported to the
new framework.
2020-06-07 14:46:21 -07:00
Fabian Homborg
9d2bf248ee test: Add tests for error messages 2020-06-07 16:23:29 +02:00
Fabian Homborg
44184f68e4 Add status dirname and status basename convenience commands
There's a terrible number of fishscripts that start with

    set path (dirname (status filename))

And that's really just a bit boring.

So let's let it be

    set path (status dirname)
2020-06-04 18:23:32 +02:00
Fabian Homborg
90b01fd915 set: Show pathvariableness in --show 2020-06-01 15:51:10 +02:00
Fabian Homborg
9354dd6971 Add fish_add_path, a simple way to add to $PATH
This is a function you can either execute once, interactively, or
stick in config.fish, and it will do the right thing.

Some options are included to choose some slightly different behavior,
like setting $PATH directly instead of $fish_user_paths, or moving
already existing components to the front/back instead of ignoring
them, or appending new components instead of prepending them.

The defaults were chosen because they are the most safe, and
especially because they allow it to be idempotent - running it again
and again and again won't change anything, it won't even run the
actual `set` because it skips that if all components are already in.

Fixes #6960.
2020-05-29 20:51:05 +02:00
Fabian Homborg
7cb452c7e7 Computed variables are global
Variables like $status and $history showed up in all scopes, including
universal, when querying with `set -q` or `set -S`.

This makes it so they all only count as set in global scope, because
we already only allow assignment to electric variables in global scope.

Fixes #7032
2020-05-27 19:59:20 +02:00
Soumya
518170b299 Also call fish_job_summary for foreground sigint
The default implementation will not print any output in that case, but this provides users with additional flexibility when it comes to customising the shell's behaviour.
2020-05-19 20:39:10 +02:00
Soumya
324fa64114 Add fish_job_summary, called whenever a job ends, stops, or is signalled
This allows users to customise the behaviour of the shell by redefining the function. This is similar to how fish_title or fish_greeting behave, where the default implementation can be easily overridden.

The function receives as arguments the job id, command line, signal name and signal description.
2020-05-19 20:39:10 +02:00
Fabian Homborg
56f24f08d7 printf: Don't print an error if not given an argument 2020-05-18 20:48:36 +02:00
Johannes Altmanninger
e03c375ee3 Purge remnants of process expansion, document {fish,last}_pid 2020-05-16 11:58:12 +02:00
Johannes Altmanninger
49c5f96470 Use set -l to force use of a local variable
Bare set overwrites a global/universal variable if it exists.
2020-05-15 08:25:07 +02:00
Fabian Homborg
e390ee12c2 Disable flaky pipeline-pgroup test
This fails *a lot* on Travis, obscuring other tests.

As far as we can tell, a newline is somehow sneaking in here.

See #6693
2020-05-07 21:19:28 +02:00
ridiculousfish
82f2d86718 Thread pgroups into builtin_eval
Ensure that if eval is invoked as part of a pipeline, any jobs spawned
by eval will have the same pgroup as the parent job.

Partially fixes #6806
2020-04-26 11:05:50 -07:00
ridiculousfish
938b683895 Thread pgroups into command substitutions
Give string expansion an (optional) parent pgroup. This is threaded all
the way into eval(). This ensures that in a mixed pipeline like:

   cmd | begin ; something (cmd2) ; end

that cmd2 and cmd have the same pgroup.

Add a test to ensure that command substitutions inherit pgroups
properly.

Fixes #6624
2020-04-26 11:05:50 -07:00
Fabian Homborg
6990c44443 Shorten set --show output
Changes it from

```
$fish_color_user: not set in local scope
$fish_color_user: set in global scope, unexported, with 1 elements
$fish_color_user[1]: length=3 value=|080|
$fish_color_user: set in universal scope, unexported, with 1 elements
$fish_color_user[1]: length=7 value=|brgreen|

```

(with the trailing empty line - not just a newline)

to

```
$fish_color_user: set in global scope, unexported, with 1 elements
$fish_color_user[1]: |080|
$fish_color_user: set in universal scope, unexported, with 1 elements
$fish_color_user[1]: |brgreen|
```
2020-04-26 08:49:01 +02:00
Jason Nader
6a839519b9 string split: add --allow-empty flag to be used with --fields 2020-04-20 22:39:48 +02:00
Jason Nader
3bb86d3a61 string split --fields: handle multi-line/arg input 2020-04-20 22:39:48 +02:00
Johannes Altmanninger
23427f3168 Add test for ~ (togglecase-char and togglecase-selection) 2020-04-19 05:51:25 +02:00
ridiculousfish
3e8422f472 terminal_maybe_give_to_job to stop returning error on ENOTTY
Prior to this fix, if job control is enabled but stdin is not a tty, we
would return an error from terminal_maybe_give_to_job which would cause us
to avoid waiting for the job. Instead just return notneeded.

Fixes #6573.
2020-04-18 16:26:54 -07:00
Johannes Altmanninger
be36c96028 alias.fish: unbreak listing aliases without backslashes
The description for an alias which already has escape sequences will
use backslash escapes for quoting; usually `string escape` can simply
quote it.  Use a regex that accepts either escaping style.
2020-04-18 09:35:33 +02:00
Johannes Altmanninger
77d33a8eb9 Ignore SIGINT and SIGQUIT in non-interactive background processes
Fixes #6828
2020-04-07 22:18:15 +02:00
Fabian Homborg
f0f162f07e argparse test: Tighten regex against travis' shenanigans
Travis puts the commit message in an environment variable, so if it
contains the string `_flag` this would match TRAVIS_COMMIT_MESSAGE.

That happened in ca91c201c3, so the
tests failed.

We simply tighten the regex a little more, and make a commit message
that doesn't include the string.
2020-04-06 19:57:22 +02:00
Fabian Homborg
5dfaff4281 Make "." a builtin as well
Yeah, it's not going anywhere. This is one line in builtin.cpp vs 9
lines of script, most of which used to print an error that is never triggered.
2020-04-06 18:55:59 +02:00
Jason Nader
21bbd2ecb4 Return 1 if non-existent field is given 2020-04-04 15:30:09 +02:00
Jason Nader
1329a40e87 Allow simple ranges to be specified for --fields 2020-04-04 15:30:08 +02:00
Jason Nader
7cb1d3a646 Add string split --fields 2020-04-04 15:30:08 +02:00
Fabian Homborg
a29bc127ce Move the invocation checks to invocation.fish
These where separate files so we could use the %s substitution to run
that fish, but since discovering setting $fish that
workaround isn't necessary.
2020-04-04 13:31:48 +02:00
Fabian Homborg
d54609bd63 Skip interactive tests on github actions for now
Github actions doesn't run this in a terminal, so the `fish -i` tests won't really work.

But still, it might be nicer than Travis.
2020-04-04 13:31:48 +02:00
Soumya
61a9cdaa74 Add $fish_kill_signal to track the signal that terminated a command.
Set to `0` if the command exited normally.
2020-04-02 09:32:32 +02:00
Fabian Homborg
1c880e5888 tests: Specify which tests completed successfully
It's a bit weird to just see "All tests completed successfully" and
then another set of tests follows.
2020-03-28 18:41:44 +01:00
Fabian Homborg
917f26b1dd tests/interactive.fish: Match littlecheck's coloring
Littlecheck resets the color before the time, which looks a bit nicer.

But most of all, it's inconsistent.
2020-03-28 18:40:57 +01:00
Fabian Homborg
82977f07a0 test.fish: Remove mention of ".in" files 2020-03-28 18:29:21 +01:00
Fabian Homborg
3a1bc33cad tests: Remove leftover reference to "../test/root/bin/fish"
We have that in a variable now.
2020-03-28 15:46:47 +01:00
Johannes Altmanninger
6699a72e0e Handle child receiving SIGCONT
Fixes #6818
2020-03-27 20:30:58 +01:00
Soumya
96563d6eff jobs: suppress "No suitable job" if -q is given
This allows code of the form `if jobs -q $some_pid` in scripts to check whether a previously started job is still running. Previously this would return the correct value, but also print an error message.

The invalid argument errors will still be printed.
Added test cases for both.
2020-03-26 17:09:09 +01:00
Johannes Altmanninger
0a2eea4cc6 Invert test for implicit cd after builtin command
Because `command ./somedir/somecommand` is okay.

Fixes test failure from aa304cbd3d.

Child directories in $PATH are still not suggested, as was the main
intention of the commit that introduced the tests:
8a3cf144f Don't include child directories of $PATH in completions.
2020-03-24 22:02:27 +01:00
George Christou
a3436110c1
Add string sub --end (#6765) 2020-03-22 15:53:09 +01:00
Fabian Homborg
179d92452d Resurrect one last function
So *that's* where "r2l" is used!
2020-03-17 21:58:49 +01:00
Fabian Homborg
b7b09add95 Revert complete_directories change
Turns out my test dir wasn't as clean as it should have been.
2020-03-17 21:45:49 +01:00
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
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
Fabian Homborg
7c2d7387d0 Port complete_directories test to littlecheck 2020-02-08 09:48:41 +01:00
Fabian Homborg
2fa8ae161a Port jobs test to littlecheck 2020-02-08 09:47:14 +01:00
Fabian Homborg
0fab1ce8b4 Port locale test to littlecheck 2020-02-08 09:38:23 +01:00
Fabian Homborg
f8af262af7 Port some smaller tests to littlecheck 2020-02-08 09:31:49 +01:00
Fabian Homborg
eaf84c553d Port line-continuation test to littlecheck 2020-02-08 09:31:49 +01:00
Fabian Homborg
e40441f901 Port history tests to littlecheck 2020-02-07 20:53:20 +01:00
Fabian Homborg
15d2797ec1 Port pipestatus test to littlecheck 2020-02-07 20:49:42 +01:00
Fabian Homborg
fc884e9cf4 Port function.in test to littlecheck 2020-02-07 20:41:01 +01:00
Fabian Homborg
921fce3a51 math: Complain about unknown *function*, not *variable*
We removed variables from tinyexpr, so we shouldn't use that error.
2020-02-07 17:43:22 +01:00
ridiculousfish
bd06a9aa6c Retain leading spaces in non-expanding braces
This makes two changes:

1. Remove the 'brace_text_start' idea. The idea of 'brace_text_start' was
to prevent emitting `BRACE_SPACE` at the beginning or end of an item. But
we later strip these off anyways, so there is no apparent benefit. If we
are not doing brace expansion, this prevented emitting whitespace at the
beginning or end of an item, leading to #6564.

2. When performing brace expansion, only stomp the space character with
`BRACE_SPACE`; do not stomp newlines and tabs. This is because the fix in
came from a newline or tab literal, then we would have effectively
replaced a newline or tab with a space, so this is important for #6564 as
well. Moreover, it is not easy to place a literal newline or tab inside a
brace expansion, and users who do probably do not mean for it to be
stripped, so I believe this is a good change in general.

Fixes #6564
2020-02-04 11:49:12 -08:00
ridiculousfish
97c456a986 Improve support for job control in non-interactive scenarios
Avoid complaining about ENOTTY results from tcsetpgrp, and ensure we
ignore SIGTTOU the first time job control is enabled.
2020-01-30 15:18:10 -08:00
Fabian Homborg
e8000cfea9 Add Solaris' error message to a test
Just another version of the error. We still want to get a bug if it
ever triggers a *wrong* error, so we still list all the options
instead of going for `.*option:.*Z.*`.

Fixes #6554
2020-01-30 18:07:03 +01:00
Fabian Homborg
9cbd3d57a0 Tests: Don't remove a parent of $PWD
Solaris/OpenIndiana/Illumos `rm` checks that and errors out.

In these cases we don't actually need it to be a part of $PWD as
it's just for cleanup, so we `cd` out before.

See #5472
See 1ee57e9244
Fixes #6555
Fixes #6558
2020-01-30 17:34:48 +01:00
ridiculousfish
7a2a6d76f3 Migrate a test from C++ to littlecheck
This eliminates noisy warnings about tcsetpgrp when the tests are run
without a tty, as reported in #6539
2020-01-26 20:59:08 -08:00
Fabian Homborg
3bb15defbb
Replace debug() with flog
PR #6511 

Flog has the advantage of having *categories*, not severities, so it'll be easier to get output for a certain subsystem now.
2020-01-26 14:13:17 +01:00
ridiculousfish
38f4330683 Rationalize $status and errors
Prior to this fix, fish was rather inconsistent in when $status gets set
in response to an error. For example, a failed expansion like "$foo["
would not modify $status.

This makes the following inter-related changes:

1. String expansion now directly returns the value to set for $status on
error. The value is always used.

2. parser_t::eval() now directly returns the proc_status_t, which cleans
up a lot of call sites.

3. We expose a new function exec_subshell_for_expand() which ignores
$status but returns errors specifically related to subshell expansion.

4. We reify the notion of "expansion breaking" errors. These include
command-not-found, expand syntax errors, and others.

The upshot is we are more consistent about always setting $status on
errors.
2020-01-25 17:28:41 -08:00
ridiculousfish
8a9c39d433 Add a test for some 'status' subcommands 2020-01-25 14:10:45 -08:00
ridiculousfish
788f359cda Make the cd check more robust on macOS
macOS `mktemp -d` likes to return symlinks. Guard against that possibility.
That allows the test to succeed when run directly, instead of through the
build target.
2020-01-25 12:59:18 -08:00
Fabian Homborg
cf508ee228 tests/job-ids: Wait for job to die
It was possible to start the new job and execute `jobs` again before
the job died (or we noticed it did), so the test would fail.

To properly test, we need to ensure the job has been removed. `wait`
should do it.
2020-01-25 14:06:34 +01:00
ridiculousfish
b99546e7a0 Port cmdsub tests to littlecheck 2020-01-24 15:03:59 -08:00
ridiculousfish
2af710f7c0 Eliminate expand_result_t::wildcard_match
This was an internal implementation detail that all callers had to deal
with. Just get rid of it.
2020-01-22 11:49:59 -08:00
Jason Nader
1cafc4eff6 Amend comments incorrectly referring to sed 2020-01-22 17:40:31 +01:00
Fabian Homborg
65397d4f5e Fix tests
By changing to flog I inadvertently changed the warning text from "<W>
fish:" to "warning:".

Since that's also okay, let's leave it.
2020-01-19 15:07:06 +01:00
ridiculousfish
d38db1bc61 Add a test for deep command substitutions 2020-01-18 11:50:50 -08:00
Johannes Altmanninger
b18f605e4f Fix completions if previous arg is a variable
complete -C'echo $HOM ' would complete $HOM instead of a new token.
Fixes another regression introduced in
6fb7f9b6b - Fix completion for builtins with subcommands
2020-01-18 20:21:10 +01:00
Fabian Homborg
14fd4570d5 Test using more than 64 threads
See #6503
2020-01-18 10:43:59 +01:00