diff --git a/tests/abbr.err b/tests/abbr.err index ef1f24017..9b8a4b9d1 100644 --- a/tests/abbr.err +++ b/tests/abbr.err @@ -1,22 +1,52 @@ + +#################### # Test basic add and list of __abbr1 + +#################### # Erasing one that doesn't exist should do nothing abbr --erase: No abbreviation named NOT_AN_ABBR + +#################### # Adding existing __abbr1 should be idempotent + +#################### # Replacing __abbr1 definition + +#################### # __abbr1 -s and --show tests + +#################### # Test erasing __abbr1 + +#################### # Ensure we escape special characters on output + +#################### # Ensure we handle leading dashes in abbreviation names properly + +#################### # Test that an abbr word containing spaces is rejected abbr --add: Abbreviation 'a b c' cannot have spaces in the word + +#################### # Test renaming + +#################### # Test renaming a nonexistent abbreviation abbr --rename: No abbreviation named __abbr6 + +#################### # Test renaming to a abbreviation with spaces abbr --rename: Abbreviation 'g h i' cannot have spaces in the word + +#################### # Test renaming without arguments abbr --rename: Requires exactly two arguments + +#################### # Test renaming with too many arguments abbr --rename: Requires exactly two arguments + +#################### # Test renaming to existing abbreviation abbr --rename: Abbreviation __abbr12 already exists, cannot rename __abbr11 diff --git a/tests/abbr.out b/tests/abbr.out index 224b7cb4b..c468b15f6 100644 --- a/tests/abbr.out +++ b/tests/abbr.out @@ -1,25 +1,55 @@ + +#################### # Test basic add and list of __abbr1 abbr -a -U -- __abbr1 'alpha beta gamma' + +#################### # Erasing one that doesn't exist should do nothing abbr -a -U -- __abbr1 'alpha beta gamma' + +#################### # Adding existing __abbr1 should be idempotent abbr -a -U -- __abbr1 'alpha beta gamma' + +#################### # Replacing __abbr1 definition abbr -a -U -- __abbr1 delta + +#################### # __abbr1 -s and --show tests abbr -a -U -- __abbr1 delta abbr -a -U -- __abbr1 delta + +#################### # Test erasing __abbr1 + +#################### # Ensure we escape special characters on output abbr -a -U -- '~__abbr2' '$xyz' + +#################### # Ensure we handle leading dashes in abbreviation names properly abbr -a -U -- --__abbr3 xyz + +#################### # Test that an abbr word containing spaces is rejected + +#################### # Test renaming abbr -a -U -- __abbr5 omega + +#################### # Test renaming a nonexistent abbreviation + +#################### # Test renaming to a abbreviation with spaces + +#################### # Test renaming without arguments + +#################### # Test renaming with too many arguments abbr -a -U -- __abbr8 omega + +#################### # Test renaming to existing abbreviation diff --git a/tests/read.err b/tests/read.err index 457658c44..8fda0a2b3 100644 --- a/tests/read.err +++ b/tests/read.err @@ -1,5 +1,39 @@ + +#################### # Read with no vars is an error read: Expected at least 1 args, got only 0 + +#################### # Read with -a and anything other than exactly on var name is an error read: Expected 1 args, got 0 read: Expected 1 args, got 2 + +#################### +# Test splitting input + +#################### +# Test splitting input with IFS empty + +#################### +# Chunked read tests + +#################### +# Confirm reading non-interactively works -- #4206 regression + +#################### +# Test --delimiter (and $IFS, for now) + +#################### +# Delimiter = + +#################### +# Delimiter empty + +#################### +# IFS empty string + +#################### +# IFS unset + +#################### +# Delimiter = diff --git a/tests/read.in b/tests/read.in index a5d5affa0..ddd6dee07 100644 --- a/tests/read.in +++ b/tests/read.in @@ -5,9 +5,10 @@ ########### # Start by testing that invocation errors are handled correctly. -echo '# Read with no vars is an error' >&2 +logmsg Read with no vars is an error read -echo '# Read with -a and anything other than exactly on var name is an error' >&2 + +logmsg Read with -a and anything other than exactly on var name is an error read -a read -a v1 v2 read -a v1 @@ -36,8 +37,7 @@ function print_vars --no-scope-shadowing echo end -echo -echo '# Test splitting input' +logmsg Test splitting input echo 'hello there' | read -l one two print_vars one two echo 'hello there' | read -l one @@ -53,8 +53,7 @@ print_vars one two three echo -n 'a' | read -l one echo "$status $one" -echo -echo '# Test splitting input with IFS empty' +logmsg Test splitting input with IFS empty set -l IFS echo 'hello' | read -l one print_vars one @@ -130,8 +129,7 @@ echo -ne 'foo\nbar\0baz\nquux' | while read -lza foo print_vars foo end -echo -echo '# chunked read tests' +logmsg Chunked read tests set -l path /tmp/fish_chunked_read_test.txt set -l longstr (seq 1024 | string join ',') echo -n $longstr > $path @@ -206,34 +204,40 @@ if test (string length "$x") -ne $FISH_READ_BYTE_LIMIT echo reading the max amount of data with --nchars failed the length test end -echo '# Confirm reading non-interactively works (#4206 regression)' -echo abc\ndef | ../test/root/bin/fish -i -c 'read a; read b; show a; show b' -### Test --delimiter (and $IFS, for now) +logmsg Confirm reading non-interactively works -- \#4206 regression +echo abc\ndef | ../test/root/bin/fish -i -c 'read a; read b; set --show a; set --show b' + +logmsg Test --delimiter '(and $IFS, for now)' echo a=b | read -l foo bar echo $foo echo $bar -echo Delimiter = + +logmsg Delimiter = echo a=b | read -l -d = foo bar echo $foo echo $bar -echo Delimiter empty + +logmsg Delimiter empty echo a=b | read -l -d '' foo bar baz echo $foo echo $bar echo $baz -echo IFS empty string + +logmsg IFS empty string set -l IFS '' echo a=b | read -l foo bar baz echo $foo echo $bar echo $baz -echo IFS unset + +logmsg IFS unset set -e IFS echo a=b | read -l foo bar baz echo $foo echo $bar echo $baz -echo Delimiter = + +logmsg Delimiter = echo a=b | read -l -d = foo bar baz echo $foo echo $bar diff --git a/tests/read.out b/tests/read.out index 5d4bac441..0d6450c85 100644 --- a/tests/read.out +++ b/tests/read.out @@ -1,3 +1,9 @@ + +#################### +# Read with no vars is an error + +#################### +# Read with -a and anything other than exactly on var name is an error 2 2 1 @@ -11,6 +17,7 @@ two] two ] +#################### # Test splitting input 1 'hello' 1 'there' 1 'hello there' @@ -20,6 +27,7 @@ two 1 'foo' 1 'bar' 1 ' baz' 0 a +#################### # Test splitting input with IFS empty 1 'hello' 1 'h' 1 'ello' @@ -58,31 +66,53 @@ newline 2 'foo' 'bar' 2 'baz' 'quux' -# chunked read tests +#################### +# Chunked read tests Chunked reads test pass -# Confirm reading non-interactively works (#4206 regression) -$a count=1 -$a[1]=|abc| -$b count=1 -$b[1]=|def| -a=b -Delimiter = -a -b -Delimiter empty -a -= -b -IFS empty string -a -= -b -IFS unset +#################### +# Confirm reading non-interactively works -- #4206 regression +$a: not set in local scope +$a: set in global scope, unexported, with 1 elements +$a[0]: length=3 value=|abc| +$a: not set in universal scope + +$b: not set in local scope +$b: set in global scope, unexported, with 1 elements +$b[0]: length=3 value=|def| +$b: not set in universal scope + + +#################### +# Test --delimiter (and $IFS, for now) a=b -Delimiter = +#################### +# Delimiter = +a +b + +#################### +# Delimiter empty +a += +b + +#################### +# IFS empty string +a += +b + +#################### +# IFS unset +a=b + + + +#################### +# Delimiter = a b diff --git a/tests/set.err b/tests/set.err index 45484fa01..a6bbd2aee 100644 --- a/tests/set.err +++ b/tests/set.err @@ -1,2 +1,7 @@ + +#################### # Verify behavior of `set --show` given an invalid var name $argle bargle: invalid var name + +#################### +# Verify behavior of `set --show` diff --git a/tests/set.in b/tests/set.in index 8eb9809bd..b4fed0d36 100644 --- a/tests/set.in +++ b/tests/set.in @@ -3,7 +3,7 @@ logmsg Verify behavior of `set --show` given an invalid var name set --show 'argle bargle' -echo '# Verify behavior of `set --show`' +logmsg Verify behavior of `set --show` set -U var1 hello set --show var1 diff --git a/tests/set.out b/tests/set.out index 28a004f7f..b805dfb47 100644 --- a/tests/set.out +++ b/tests/set.out @@ -1,4 +1,8 @@ + +#################### # Verify behavior of `set --show` given an invalid var name + +#################### # Verify behavior of `set --show` $var1: not set in local scope $var1: not set in global scope diff --git a/tests/test_cmdsub.err b/tests/test_cmdsub.err index 1648a2365..cc56e58f2 100644 --- a/tests/test_cmdsub.err +++ b/tests/test_cmdsub.err @@ -1,9 +1,15 @@ + +#################### # Command sub just under the limit should succeed + +#################### # Command sub at the limit should fail fish: Too much data emitted by command substitution so it was discarded set b (string repeat -n 512 x) ^ + +#################### # Command sub over the limit should fail fish: Too much data emitted by command substitution so it was discarded @@ -16,7 +22,11 @@ in function 'subme' in command substitution called on standard input + +#################### # Make sure output from builtins outside of command substitution is not affected + +#################### # Same builtin in a command substitution is affected fish: Too much data emitted by command substitution so it was discarded diff --git a/tests/test_cmdsub.out b/tests/test_cmdsub.out index e795beea0..58b21bac1 100644 --- a/tests/test_cmdsub.out +++ b/tests/test_cmdsub.out @@ -1,19 +1,29 @@ + +#################### # Command sub just under the limit should succeed $a: not set in local scope $a: set in global scope, unexported, with 1 elements $a[0]: length=511 value=|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| $a: not set in universal scope + +#################### # Command sub at the limit should fail $b: not set in local scope $b: not set in global scope $b: not set in universal scope + +#################### # Command sub over the limit should fail $c: not set in local scope $c: set in global scope, unexported, with 0 elements $c: not set in universal scope + +#################### # Make sure output from builtins outside of command substitution is not affected aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + +#################### # Same builtin in a command substitution is affected diff --git a/tests/test_functions/logmsg.fish b/tests/test_functions/logmsg.fish index 74b8f364b..6db67c7b5 100644 --- a/tests/test_functions/logmsg.fish +++ b/tests/test_functions/logmsg.fish @@ -1,4 +1,9 @@ function logmsg + echo + echo "####################" echo "# $argv" + + echo >&2 + echo "####################" >&2 echo "# $argv" >&2 end