Commit graph

77 commits

Author SHA1 Message Date
Kevin Ballard
190712d4b0 Add a test harness for interactive behavior
Add a test harness that uses `expect` to drive Fish to test interactive
behavior.

Include some tests for `read`.
2014-09-07 23:56:59 -07:00
Kevin Ballard
efb1467e4e Cleanup fish tests a bit
Split `make test` into two targets `make test_low_level` and `make
test_fishscript`, primarily so fishscript tests can be rechecked quickly
after edits.

Reformat the test.fish file and update some of the code to be a little
more straightforward (e.g. `if not cmd` instead of `if cmd; else`).
2014-09-07 23:50:44 -07:00
Joseph Tannhuber
4acea72700 New -n option for read builtin
Usage: read -n nchars
Reads maximum of nchars characters. If nchars <= 0, there's no limit.
2014-09-03 22:48:37 -07:00
Kevin Ballard
1c4223889b Fix test output for complete -e tests
GNU sort behaves stupidly when LC_ALL is not C. This caused the test
output to be sorted wrong.
2014-09-02 15:52:56 -07:00
Kevin Ballard
90a4fd34d2 Add tests for the various complete -e changes 2014-09-02 15:30:58 -07:00
Kevin Ballard
7fce9e2411 Trim trailing newline on cmdsubst when IFS=''
When $IFS is empty, command substitution no longer splits on newlines.
However we still want to trim off a single trailing newline, as most
commands will emit a trailing newline and it makes it harder to work
with their output.
2014-08-29 12:48:45 -07:00
Kevin Ballard
130619d6b0 Fix $SHLVL
Due to being read-only, SHLVL wasn't being incremented properly for
recursive invocations of fish.
2014-08-29 12:22:35 -07:00
ridiculousfish
0b7735d279 Merge pull request #1630 from kballard/expand_variables_in_quoted_strings
Fix various expansions issues with variables
2014-08-23 16:13:25 -07:00
ridiculousfish
033373f078 Merge branch 'make_type_better' of github.com:kballard/fish-shell into kballard-make_type_better 2014-08-21 21:36:39 -07:00
Kevin Ballard
2974025010 Fix error span for invalid slice indexes
The span now properly points at the token that was invalid, rather than
the start of the slice.

Also fix the span for `()[1]` and `()[d]`, which were previously
reporting no source location at all.
2014-08-21 01:10:07 -07:00
Kevin Ballard
cc49042294 Parse slices even for empty variables
When a variable is parsed as being empty, parse out the slice and
validate the indexes anyway, behaving for slicing purposes as if the
variable had a single empty value.

Besides providing errors when expected, this also fixes the following:

    set -l foo
    echo "$foo[1]"

This used to print "[1]", now it properly prints nothing.
2014-08-20 22:09:32 -07:00
Kevin Ballard
3981b644d6 Fix double expansions ($$foo)
Double expansions of variables had the following issues:

* `"$$foo"` threw an error no matter what the value of `$foo` was.
* `set -l foo ''; echo $$foo` threw an error because of the expansion of
  `$foo` to `''`.

With this change, double expansion always works properly. When
double-expanding a multi-valued variable, in a double-quoted string the
first word of the inner expansion is used for the outer expansion, and
outside of a quoted string every word is used for the double-expansion
in each of the arguments.

    > set -l foo bar baz
    > set -l bar one two
    > set -l baz three four
    > echo "$$foo"
    one two baz
    > echo $$foo
    one two three four
2014-08-20 21:45:07 -07:00
ridiculousfish
52ae5f885e Improve history robustness against corrupt files
Fixes #1581
2014-07-29 14:42:03 -07:00
Kevin Ballard
973dd6ffbd read: Support arrays, character splitting
Enhance the `read` builtin to support creating an array with the --array
flag. With --array, only a single variable name is allowed and the
entire input is tokenized and placed into that variable as an array.

Also add custom behavior if IFS is empty or unset. In that event, split
the input on every character, instead of the previous behavior of doing
no splitting at all.
2014-07-14 00:46:38 -07:00
Kevin Ballard
cfa13ed84c Update tests for new type behavior
One of the tests was using `>/dev/null` to suppress the `type` output.
That needs to be `^/dev/null` now, but instead just go ahead and use the
new `-q` flag.
2014-07-13 19:11:29 -07:00
ridiculousfish
98297e5234 Teach while loops to not hang forever with no-execute
Fixes #1543
2014-07-11 11:28:10 -07:00
ridiculousfish
18c1b12741 Switch variable name in tests from foo to something less likely to be
used accidentally
2014-07-06 20:41:21 -07:00
ridiculousfish
b19f45e15d Add test for issue 1526 2014-07-06 18:12:18 -07:00
ridiculousfish
3cbace98a7 'echo -' should output a dash instead of treating it as options
Fixes #1459
2014-05-16 15:19:07 +08:00
Konrad Borowski
7f2c4cbf8a Move the empty function test to tests. 2014-05-06 12:31:44 +02:00
Konrad Borowski
91ebe12fc2 Add test for empty function name. 2014-05-06 12:18:09 +02:00
ridiculousfish
b01d09d704 Set the job property of block_t before expanding arguments associated
with the job, fixing psub. Fixes #1394
2014-04-02 00:32:08 -07:00
ridiculousfish
d232a0f951 Implement status -n (line number) with new parser 2014-03-01 16:04:13 -08:00
ridiculousfish
bc43409624 Expand the variable name as an ordinary parameter in for loops. Added
test for it too.
2014-02-21 18:20:51 -08:00
ridiculousfish
29ddb68da4 Tests and fix to allow return to work correctly within if statements. Closes #1297. 2014-02-12 01:39:06 -08:00
ridiculousfish
e632d39b1f Make if statements always return success at the end, matching other
shells. Fixes #1061.
2014-02-07 17:57:53 -08:00
ridiculousfish
699d78bcfe Make the test harness output file diffs on failure 2014-02-04 11:28:29 -08:00
David Adam
3106cffb65 Makefile/tests: use return values to communicate errors 2014-01-15 23:50:42 +08:00
ridiculousfish
d9056081e7 Added tests for piping an fd other than stdout 2014-01-13 02:49:41 -08:00
ridiculousfish
a9787b769f Support for implicit cd, no-exec, and the exit builtin. All tests now
pass (!). Error reporting still unsteady.
2013-12-29 16:23:26 -08:00
ridiculousfish
a42711e31c Support for break/continue with new parser execution 2013-12-28 22:52:06 -08:00
ridiculousfish
5cf59de676 Finish rewriting detect_errors to use new parser. All tests now pass (!) 2013-12-12 18:18:07 -08:00
ridiculousfish
e849beabba Initial work towards various IO cleanups with an eye to fixing https://github.com/fish-shell/fish-shell/issues/110 2013-08-19 18:06:24 -07:00
ridiculousfish
640118e781 Cleanup of code that decides whether or not to fork. Fix for issue where stderr may be output twice. 2013-06-16 23:26:43 -07:00
ridiculousfish
3ea8d83d3f Try to fix printf tests on Linux 2013-04-03 18:04:17 -07:00
Siteshwar Vashisht
3ac9621f87 Enabled test cases for unicode characters in printf builtin 2013-03-29 12:26:15 +05:30
ridiculousfish
b04e874e43 Teach fish how to push and pop blocks even in the face of no_exec. All tests finally pass.
https://github.com/fish-shell/fish-shell/issues/624
2013-03-25 16:06:12 -07:00
ridiculousfish
d146f578a4 Fix printf output to store \r instead of \n
Is git breaking line endings?
2013-03-24 15:58:24 -07:00
ridiculousfish
9394583f96 Implement actual error handling for builtin_printf. Fix the tests. 2013-03-24 15:58:24 -07:00
Siteshwar Vashisht
be7d02ebdd Added test cases for printf builtin 2013-03-03 00:45:34 +05:30
ridiculousfish
ad8d68dd43 Make subcommands modify $status, and make builtin_set not modify status unless it fails
https://github.com/fish-shell/fish-shell/issues/547
https://github.com/fish-shell/fish-shell/issues/214
2013-01-31 15:57:08 -08:00
Jan Kanis
640beafa8c fix a memory leak in profiling, add a profiling test 2013-01-14 01:38:05 +01:00
ridiculousfish
dc37a8079e Added a seq function that defers to the seq command if present
https://github.com/fish-shell/fish-shell/issues/137
2013-01-12 14:18:34 -08:00
Jan Kanis
9ee7b0a501 really fix bug in export status of universal vars; add tests for that bug 2013-01-02 23:31:30 -08:00
Jan Kanis
8a446f43ff include fixes and suggestions from code review 2012-12-22 18:38:28 +01:00
Jan Kanis
af3059ab2a Allow 'emit' to accept event arguments 2012-12-20 16:13:00 +01:00
Jan Kanis
1f0ae8b06d fixed #449, added test 2012-12-20 16:11:46 +01:00
ridiculousfish
bf27cb1f5e Further fixes to newline escaping
Addresses issue described in https://github.com/fish-shell/fish-shell/issues/347#issuecomment-10650443
2012-11-23 12:03:36 -08:00
ridiculousfish
90495f3ac5 Implement new newline-escaping behavior. Backslashes at the end of lines now essentially delete the newline, within normal text or double quotes. Backslashes are retained within single quotes.
Fixes https://github.com/fish-shell/fish-shell/issues/347
Fixes https://github.com/fish-shell/fish-shell/issues/52
2012-11-22 01:09:07 -08:00
ridiculousfish
e9d216bc84 Fixed recursive brace expansion
https://github.com/fish-shell/fish-shell/issues/399
2012-11-20 13:52:53 -08:00