use new logmsg and set --show in tests

Also modify `logmsg` to output additional separator lines to make the
demarcation between tests even clearer.
This commit is contained in:
Kurtis Rader 2017-08-03 21:25:20 -07:00
parent ecf06f2eb4
commit 7619e62b70
11 changed files with 199 additions and 37 deletions

View file

@ -1,22 +1,52 @@
####################
# Test basic add and list of __abbr1 # Test basic add and list of __abbr1
####################
# Erasing one that doesn't exist should do nothing # Erasing one that doesn't exist should do nothing
abbr --erase: No abbreviation named NOT_AN_ABBR abbr --erase: No abbreviation named NOT_AN_ABBR
####################
# Adding existing __abbr1 should be idempotent # Adding existing __abbr1 should be idempotent
####################
# Replacing __abbr1 definition # Replacing __abbr1 definition
####################
# __abbr1 -s and --show tests # __abbr1 -s and --show tests
####################
# Test erasing __abbr1 # Test erasing __abbr1
####################
# Ensure we escape special characters on output # Ensure we escape special characters on output
####################
# Ensure we handle leading dashes in abbreviation names properly # Ensure we handle leading dashes in abbreviation names properly
####################
# Test that an abbr word containing spaces is rejected # Test that an abbr word containing spaces is rejected
abbr --add: Abbreviation 'a b c' cannot have spaces in the word abbr --add: Abbreviation 'a b c' cannot have spaces in the word
####################
# Test renaming # Test renaming
####################
# Test renaming a nonexistent abbreviation # Test renaming a nonexistent abbreviation
abbr --rename: No abbreviation named __abbr6 abbr --rename: No abbreviation named __abbr6
####################
# Test renaming to a abbreviation with spaces # Test renaming to a abbreviation with spaces
abbr --rename: Abbreviation 'g h i' cannot have spaces in the word abbr --rename: Abbreviation 'g h i' cannot have spaces in the word
####################
# Test renaming without arguments # Test renaming without arguments
abbr --rename: Requires exactly two arguments abbr --rename: Requires exactly two arguments
####################
# Test renaming with too many arguments # Test renaming with too many arguments
abbr --rename: Requires exactly two arguments abbr --rename: Requires exactly two arguments
####################
# Test renaming to existing abbreviation # Test renaming to existing abbreviation
abbr --rename: Abbreviation __abbr12 already exists, cannot rename __abbr11 abbr --rename: Abbreviation __abbr12 already exists, cannot rename __abbr11

View file

@ -1,25 +1,55 @@
####################
# Test basic add and list of __abbr1 # Test basic add and list of __abbr1
abbr -a -U -- __abbr1 'alpha beta gamma' abbr -a -U -- __abbr1 'alpha beta gamma'
####################
# Erasing one that doesn't exist should do nothing # Erasing one that doesn't exist should do nothing
abbr -a -U -- __abbr1 'alpha beta gamma' abbr -a -U -- __abbr1 'alpha beta gamma'
####################
# Adding existing __abbr1 should be idempotent # Adding existing __abbr1 should be idempotent
abbr -a -U -- __abbr1 'alpha beta gamma' abbr -a -U -- __abbr1 'alpha beta gamma'
####################
# Replacing __abbr1 definition # Replacing __abbr1 definition
abbr -a -U -- __abbr1 delta abbr -a -U -- __abbr1 delta
####################
# __abbr1 -s and --show tests # __abbr1 -s and --show tests
abbr -a -U -- __abbr1 delta abbr -a -U -- __abbr1 delta
abbr -a -U -- __abbr1 delta abbr -a -U -- __abbr1 delta
####################
# Test erasing __abbr1 # Test erasing __abbr1
####################
# Ensure we escape special characters on output # Ensure we escape special characters on output
abbr -a -U -- '~__abbr2' '$xyz' abbr -a -U -- '~__abbr2' '$xyz'
####################
# Ensure we handle leading dashes in abbreviation names properly # Ensure we handle leading dashes in abbreviation names properly
abbr -a -U -- --__abbr3 xyz abbr -a -U -- --__abbr3 xyz
####################
# Test that an abbr word containing spaces is rejected # Test that an abbr word containing spaces is rejected
####################
# Test renaming # Test renaming
abbr -a -U -- __abbr5 omega abbr -a -U -- __abbr5 omega
####################
# Test renaming a nonexistent abbreviation # Test renaming a nonexistent abbreviation
####################
# Test renaming to a abbreviation with spaces # Test renaming to a abbreviation with spaces
####################
# Test renaming without arguments # Test renaming without arguments
####################
# Test renaming with too many arguments # Test renaming with too many arguments
abbr -a -U -- __abbr8 omega abbr -a -U -- __abbr8 omega
####################
# Test renaming to existing abbreviation # Test renaming to existing abbreviation

View file

@ -1,5 +1,39 @@
####################
# Read with no vars is an error # Read with no vars is an error
read: Expected at least 1 args, got only 0 read: Expected at least 1 args, got only 0
####################
# Read with -a and anything other than exactly on var name is an error # 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 0
read: Expected 1 args, got 2 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 =

View file

@ -5,9 +5,10 @@
########### ###########
# Start by testing that invocation errors are handled correctly. # 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 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
read -a v1 v2 read -a v1 v2
read -a v1 read -a v1
@ -36,8 +37,7 @@ function print_vars --no-scope-shadowing
echo echo
end end
echo logmsg Test splitting input
echo '# Test splitting input'
echo 'hello there' | read -l one two echo 'hello there' | read -l one two
print_vars one two print_vars one two
echo 'hello there' | read -l one echo 'hello there' | read -l one
@ -53,8 +53,7 @@ print_vars one two three
echo -n 'a' | read -l one echo -n 'a' | read -l one
echo "$status $one" echo "$status $one"
echo logmsg Test splitting input with IFS empty
echo '# Test splitting input with IFS empty'
set -l IFS set -l IFS
echo 'hello' | read -l one echo 'hello' | read -l one
print_vars one print_vars one
@ -130,8 +129,7 @@ echo -ne 'foo\nbar\0baz\nquux' | while read -lza foo
print_vars foo print_vars foo
end end
echo logmsg Chunked read tests
echo '# chunked read tests'
set -l path /tmp/fish_chunked_read_test.txt set -l path /tmp/fish_chunked_read_test.txt
set -l longstr (seq 1024 | string join ',') set -l longstr (seq 1024 | string join ',')
echo -n $longstr > $path 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 echo reading the max amount of data with --nchars failed the length test
end end
echo '# Confirm reading non-interactively works (#4206 regression)' logmsg Confirm reading non-interactively works -- \#4206 regression
echo abc\ndef | ../test/root/bin/fish -i -c 'read a; read b; show a; show b' echo abc\ndef | ../test/root/bin/fish -i -c 'read a; read b; set --show a; set --show b'
### Test --delimiter (and $IFS, for now)
logmsg Test --delimiter '(and $IFS, for now)'
echo a=b | read -l foo bar echo a=b | read -l foo bar
echo $foo echo $foo
echo $bar echo $bar
echo Delimiter =
logmsg Delimiter =
echo a=b | read -l -d = foo bar echo a=b | read -l -d = foo bar
echo $foo echo $foo
echo $bar echo $bar
echo Delimiter empty
logmsg Delimiter empty
echo a=b | read -l -d '' foo bar baz echo a=b | read -l -d '' foo bar baz
echo $foo echo $foo
echo $bar echo $bar
echo $baz echo $baz
echo IFS empty string
logmsg IFS empty string
set -l IFS '' set -l IFS ''
echo a=b | read -l foo bar baz echo a=b | read -l foo bar baz
echo $foo echo $foo
echo $bar echo $bar
echo $baz echo $baz
echo IFS unset
logmsg IFS unset
set -e IFS set -e IFS
echo a=b | read -l foo bar baz echo a=b | read -l foo bar baz
echo $foo echo $foo
echo $bar echo $bar
echo $baz echo $baz
echo Delimiter =
logmsg Delimiter =
echo a=b | read -l -d = foo bar baz echo a=b | read -l -d = foo bar baz
echo $foo echo $foo
echo $bar echo $bar

View file

@ -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
2 2
1 1
@ -11,6 +17,7 @@ two]
two two
] ]
####################
# Test splitting input # Test splitting input
1 'hello' 1 'there' 1 'hello' 1 'there'
1 'hello there' 1 'hello there'
@ -20,6 +27,7 @@ two
1 'foo' 1 'bar' 1 ' baz' 1 'foo' 1 'bar' 1 ' baz'
0 a 0 a
####################
# Test splitting input with IFS empty # Test splitting input with IFS empty
1 'hello' 1 'hello'
1 'h' 1 'ello' 1 'h' 1 'ello'
@ -58,31 +66,53 @@ newline
2 'foo' 'bar' 2 'foo' 'bar'
2 'baz' 'quux' 2 'baz' 'quux'
# chunked read tests ####################
# Chunked read tests
Chunked reads test pass 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 # Confirm reading non-interactively works -- #4206 regression
b $a: not set in local scope
Delimiter empty $a: set in global scope, unexported, with 1 elements
a $a[0]: length=3 value=|abc|
= $a: not set in universal scope
b
IFS empty string $b: not set in local scope
a $b: set in global scope, unexported, with 1 elements
= $b[0]: length=3 value=|def|
b $b: not set in universal scope
IFS unset
####################
# Test --delimiter (and $IFS, for now)
a=b a=b
Delimiter = ####################
# Delimiter =
a
b
####################
# Delimiter empty
a
=
b
####################
# IFS empty string
a
=
b
####################
# IFS unset
a=b
####################
# Delimiter =
a a
b b

View file

@ -1,2 +1,7 @@
####################
# Verify behavior of `set --show` given an invalid var name # Verify behavior of `set --show` given an invalid var name
$argle bargle: invalid var name $argle bargle: invalid var name
####################
# Verify behavior of `set --show`

View file

@ -3,7 +3,7 @@
logmsg Verify behavior of `set --show` given an invalid var name logmsg Verify behavior of `set --show` given an invalid var name
set --show 'argle bargle' set --show 'argle bargle'
echo '# Verify behavior of `set --show`' logmsg Verify behavior of `set --show`
set -U var1 hello set -U var1 hello
set --show var1 set --show var1

View file

@ -1,4 +1,8 @@
####################
# Verify behavior of `set --show` given an invalid var name # Verify behavior of `set --show` given an invalid var name
####################
# Verify behavior of `set --show` # Verify behavior of `set --show`
$var1: not set in local scope $var1: not set in local scope
$var1: not set in global scope $var1: not set in global scope

View file

@ -1,9 +1,15 @@
####################
# Command sub just under the limit should succeed # Command sub just under the limit should succeed
####################
# Command sub at the limit should fail # Command sub at the limit should fail
fish: Too much data emitted by command substitution so it was discarded fish: Too much data emitted by command substitution so it was discarded
set b (string repeat -n 512 x) set b (string repeat -n 512 x)
^ ^
####################
# Command sub over the limit should fail # Command sub over the limit should fail
fish: Too much data emitted by command substitution so it was discarded fish: Too much data emitted by command substitution so it was discarded
@ -16,7 +22,11 @@ in function 'subme'
in command substitution in command substitution
called on standard input called on standard input
####################
# Make sure output from builtins outside of command substitution is not affected # Make sure output from builtins outside of command substitution is not affected
####################
# Same builtin in a command substitution is affected # Same builtin in a command substitution is affected
fish: Too much data emitted by command substitution so it was discarded fish: Too much data emitted by command substitution so it was discarded

View file

@ -1,19 +1,29 @@
####################
# Command sub just under the limit should succeed # Command sub just under the limit should succeed
$a: not set in local scope $a: not set in local scope
$a: set in global scope, unexported, with 1 elements $a: set in global scope, unexported, with 1 elements
$a[0]: length=511 value=|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| $a[0]: length=511 value=|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
$a: not set in universal scope $a: not set in universal scope
####################
# Command sub at the limit should fail # Command sub at the limit should fail
$b: not set in local scope $b: not set in local scope
$b: not set in global scope $b: not set in global scope
$b: not set in universal scope $b: not set in universal scope
####################
# Command sub over the limit should fail # Command sub over the limit should fail
$c: not set in local scope $c: not set in local scope
$c: set in global scope, unexported, with 0 elements $c: set in global scope, unexported, with 0 elements
$c: not set in universal scope $c: not set in universal scope
####################
# Make sure output from builtins outside of command substitution is not affected # Make sure output from builtins outside of command substitution is not affected
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
####################
# Same builtin in a command substitution is affected # Same builtin in a command substitution is affected

View file

@ -1,4 +1,9 @@
function logmsg function logmsg
echo
echo "####################"
echo "# $argv" echo "# $argv"
echo >&2
echo "####################" >&2
echo "# $argv" >&2 echo "# $argv" >&2
end end