mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 06:41:14 -03:00
Port some smaller tests to littlecheck
This commit is contained in:
@@ -1,7 +1,13 @@
|
|||||||
|
#RUN: %fish %s
|
||||||
# Tests for the "builtin" builtin/keyword.
|
# Tests for the "builtin" builtin/keyword.
|
||||||
builtin -q string; and echo String exists
|
builtin -q string; and echo String exists
|
||||||
|
#CHECK: String exists
|
||||||
builtin -q; and echo None exists
|
builtin -q; and echo None exists
|
||||||
builtin -q string echo banana; and echo Some of these exist
|
builtin -q string echo banana; and echo Some of these exist
|
||||||
|
#CHECK: Some of these exist
|
||||||
builtin -nq string
|
builtin -nq string
|
||||||
|
#CHECKERR: builtin: Invalid combination of options,
|
||||||
|
#CHECKERR: --query and --names are mutually exclusive
|
||||||
echo $status
|
echo $status
|
||||||
|
#CHECK: 2
|
||||||
exit 0
|
exit 0
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
# vim: set filetype=fish:
|
#RUN: %fish %s
|
||||||
#
|
|
||||||
# Test the `functions` builtin
|
# Test the `functions` builtin
|
||||||
|
|
||||||
function f1
|
function f1
|
||||||
@@ -15,10 +14,8 @@ end
|
|||||||
# ==========
|
# ==========
|
||||||
# Verify that `functions --details` works as expected when given the name of a
|
# Verify that `functions --details` works as expected when given the name of a
|
||||||
# known function.
|
# known function.
|
||||||
set x (functions --details f1)
|
functions --details f1
|
||||||
if test "$x" != "stdin"
|
#CHECK: {{.*}}checks/functions.fish
|
||||||
echo "Unexpected output for 'functions --details f1': $x" >&2
|
|
||||||
end
|
|
||||||
|
|
||||||
# ==========
|
# ==========
|
||||||
# Verify that `functions --details` works as expected when given the name of an
|
# Verify that `functions --details` works as expected when given the name of an
|
||||||
@@ -82,3 +79,4 @@ or echo "Failed to find description 2" >&2
|
|||||||
# so this is the best we can do.
|
# so this is the best we can do.
|
||||||
functions --erase ls
|
functions --erase ls
|
||||||
type -t ls
|
type -t ls
|
||||||
|
#CHECK: file
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# Test psub behavior
|
#RUN: %fish %s
|
||||||
set -l filename (echo foo | psub --testing)
|
set -l filename (echo foo | psub --testing)
|
||||||
test -f $filename
|
test -f $filename
|
||||||
or echo 'psub is not a regular file' >&2
|
or echo 'psub is not a regular file' >&2
|
||||||
@@ -21,6 +21,9 @@ rm $filename
|
|||||||
cat (echo foo | psub)
|
cat (echo foo | psub)
|
||||||
cat (echo bar | psub --fifo)
|
cat (echo bar | psub --fifo)
|
||||||
cat (echo baz | psub)
|
cat (echo baz | psub)
|
||||||
|
#CHECK: foo
|
||||||
|
#CHECK: bar
|
||||||
|
#CHECK: baz
|
||||||
|
|
||||||
set -l filename (echo foo | psub)
|
set -l filename (echo foo | psub)
|
||||||
if test -e $filename
|
if test -e $filename
|
||||||
@@ -28,6 +31,7 @@ if test -e $filename
|
|||||||
else
|
else
|
||||||
echo 'psub file was deleted'
|
echo 'psub file was deleted'
|
||||||
end
|
end
|
||||||
|
#CHECK: psub file was deleted
|
||||||
|
|
||||||
# The --file flag is the default behavior.
|
# The --file flag is the default behavior.
|
||||||
if count (echo foo | psub -s .cc | string match -r '\.cc$') >/dev/null
|
if count (echo foo | psub -s .cc | string match -r '\.cc$') >/dev/null
|
||||||
@@ -35,6 +39,7 @@ if count (echo foo | psub -s .cc | string match -r '\.cc$') >/dev/null
|
|||||||
else
|
else
|
||||||
echo 'psub filename does not end with .cc'
|
echo 'psub filename does not end with .cc'
|
||||||
end
|
end
|
||||||
|
#CHECK: psub filename ends with .cc
|
||||||
|
|
||||||
# Make sure we get the same result if we explicitly ask for a temp file.
|
# Make sure we get the same result if we explicitly ask for a temp file.
|
||||||
if count (echo foo | psub -f -s .cc | string match -r '\.cc$') >/dev/null
|
if count (echo foo | psub -f -s .cc | string match -r '\.cc$') >/dev/null
|
||||||
@@ -42,6 +47,7 @@ if count (echo foo | psub -f -s .cc | string match -r '\.cc$') >/dev/null
|
|||||||
else
|
else
|
||||||
echo 'psub filename does not end with .cc'
|
echo 'psub filename does not end with .cc'
|
||||||
end
|
end
|
||||||
|
#CHECK: psub filename ends with .cc
|
||||||
|
|
||||||
set -l filename (echo foo | psub -s .fish)
|
set -l filename (echo foo | psub -s .fish)
|
||||||
if test -e (dirname $filename)
|
if test -e (dirname $filename)
|
||||||
@@ -49,6 +55,7 @@ if test -e (dirname $filename)
|
|||||||
else
|
else
|
||||||
echo 'psub directory was deleted'
|
echo 'psub directory was deleted'
|
||||||
end
|
end
|
||||||
|
#CHECK: psub directory was deleted
|
||||||
|
|
||||||
set -l diffs (comm -3 (__fish_print_help psub | psub) (psub -hs banana | psub))
|
set -l diffs (comm -3 (__fish_print_help psub | psub) (psub -hs banana | psub))
|
||||||
test -z "$diffs"
|
test -z "$diffs"
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#RUN: %fish %s
|
||||||
set -l max 9223372036854775807
|
set -l max 9223372036854775807
|
||||||
set -l close_max 9223372036854775806
|
set -l close_max 9223372036854775806
|
||||||
set -l min -9223372036854775807
|
set -l min -9223372036854775807
|
||||||
@@ -6,21 +7,37 @@ set -l diff_max 18446744073709551614
|
|||||||
|
|
||||||
# check failure cases
|
# check failure cases
|
||||||
random a
|
random a
|
||||||
|
#CHECKERR: random: Argument 'a' is not a valid integer
|
||||||
random $diff_max
|
random $diff_max
|
||||||
|
#CHECKERR: random: Argument '18446744073709551614' is not a valid integer
|
||||||
random -- 1 2 3 4
|
random -- 1 2 3 4
|
||||||
|
#CHECKERR: random: Too many arguments
|
||||||
random -- 10 -10
|
random -- 10 -10
|
||||||
|
#CHECKERR: random: END must be greater than START
|
||||||
random -- 10 $diff_max
|
random -- 10 $diff_max
|
||||||
|
#CHECKERR: random: Argument '18446744073709551614' is not a valid integer
|
||||||
random -- 1 1d
|
random -- 1 1d
|
||||||
random -- 1 1c 10
|
random -- 1 1c 10
|
||||||
|
#CHECKERR: random: Argument '1d' is not a valid integer
|
||||||
|
#CHECKERR: random: Argument '1c' is not a valid integer
|
||||||
random -- 10 10
|
random -- 10 10
|
||||||
|
#CHECKERR: random: END must be greater than START
|
||||||
random -- 1 - 10
|
random -- 1 - 10
|
||||||
|
#CHECKERR: random: Argument '-' is not a valid integer
|
||||||
random -- 1 -1 10
|
random -- 1 -1 10
|
||||||
|
#CHECKERR: random: Argument '-1' is not a valid integer
|
||||||
random -- 1 $min 10
|
random -- 1 $min 10
|
||||||
|
#CHECKERR: random: Argument '-9223372036854775807' is not a valid integer
|
||||||
random -- 1 0 10
|
random -- 1 0 10
|
||||||
|
#CHECKERR: random: STEP must be a positive integer
|
||||||
random -- 1 11 10
|
random -- 1 11 10
|
||||||
|
#CHECKERR: random: range contains only one possible value
|
||||||
random -- 0 $diff_max $max
|
random -- 0 $diff_max $max
|
||||||
|
#CHECKERR: random: range contains only one possible value
|
||||||
random choice
|
random choice
|
||||||
|
#CHECKERR: random: nothing to choose from
|
||||||
random choic a b c
|
random choic a b c
|
||||||
|
#CHECKERR: random: Too many arguments
|
||||||
|
|
||||||
function check_boundaries
|
function check_boundaries
|
||||||
if not test $argv[1] -ge $argv[2] -a $argv[1] -le $argv[3]
|
if not test $argv[1] -ge $argv[2] -a $argv[1] -le $argv[3]
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
# vim: set filetype=fish:
|
#RUN: %fish %s
|
||||||
|
|
||||||
status -b
|
status -b
|
||||||
and echo '"status -b" unexpectedly returned true at top level'
|
and echo '"status -b" unexpectedly returned true at top level'
|
||||||
|
|
||||||
@@ -22,36 +21,52 @@ and echo '"status is-interactive" unexpectedly returned true for a non-interacti
|
|||||||
|
|
||||||
# We should get an error message about an invalid combination of flags.
|
# We should get an error message about an invalid combination of flags.
|
||||||
status --is-interactive --is-login
|
status --is-interactive --is-login
|
||||||
|
#CHECKERR: status: Invalid combination of options,
|
||||||
|
#CHECKERR: you cannot do both 'is-interactive' and 'is-login' in the same invocation
|
||||||
|
|
||||||
# We should get an error message about an unexpected arg for `status
|
# We should get an error message about an unexpected arg for `status
|
||||||
# is-block`.
|
# is-block`.
|
||||||
status -b is-interactive
|
status -b is-interactive
|
||||||
|
#CHECKERR: status: Invalid combination of options,
|
||||||
|
#CHECKERR: you cannot do both 'is-block' and 'is-interactive' in the same invocation
|
||||||
|
|
||||||
# Try to set the job control to an invalid mode.
|
# Try to set the job control to an invalid mode.
|
||||||
status job-control full1
|
status job-control full1
|
||||||
|
#CHECKERR: status: Invalid job control mode 'full1'
|
||||||
status --job-control=1none
|
status --job-control=1none
|
||||||
|
#CHECKERR: status: Invalid job control mode '1none'
|
||||||
|
|
||||||
# Now set it to a valid mode.
|
# Now set it to a valid mode.
|
||||||
status job-control none
|
status job-control none
|
||||||
|
|
||||||
# Check status -u outside functions
|
# Check status -u outside functions
|
||||||
status current-function
|
status current-function
|
||||||
|
#CHECK: Not a function
|
||||||
|
|
||||||
function test_function
|
function test_function
|
||||||
status current-function
|
status current-function
|
||||||
end
|
end
|
||||||
|
|
||||||
test_function
|
test_function
|
||||||
|
#CHECK: test_function
|
||||||
eval test_function
|
eval test_function
|
||||||
|
#CHECK: test_function
|
||||||
|
|
||||||
logmsg Future Feature Flags
|
# Future Feature Flags
|
||||||
status features
|
status features
|
||||||
|
#CHECK: stderr-nocaret off 3.0 ^ no longer redirects stderr
|
||||||
|
#CHECK: qmark-noglob off 3.0 ? no longer globs
|
||||||
|
#CHECK: regex-easyesc off 3.1 string replace -r needs fewer \'s
|
||||||
status test-feature stderr-nocaret ; echo $status
|
status test-feature stderr-nocaret ; echo $status
|
||||||
|
#CHECK: 1
|
||||||
status test-feature not-a-feature ; echo $status
|
status test-feature not-a-feature ; echo $status
|
||||||
|
#CHECK: 2
|
||||||
|
|
||||||
logmsg 'Ensure $status isn\'t reset before a function is executed'
|
# Ensure $status isn't reset before a function is executed
|
||||||
function echo_last
|
function echo_last
|
||||||
echo $status
|
echo $status
|
||||||
end
|
end
|
||||||
|
|
||||||
false; echo_last; echo $status #1
|
false; echo_last; echo $status #1
|
||||||
|
#CHECK: 1
|
||||||
|
#CHECK: 0
|
||||||
30
tests/checks/vars_as_commands.fish
Normal file
30
tests/checks/vars_as_commands.fish
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#RUN: %fish %s
|
||||||
|
# Test that using variables as command names work correctly.
|
||||||
|
|
||||||
|
$EMPTY_VARIABLE
|
||||||
|
#CHECKERR: {{.*}}checks/vars_as_commands.fish (line {{\d+}}): The expanded command was empty.
|
||||||
|
#CHECKERR: $EMPTY_VARIABLE
|
||||||
|
#CHECKERR: ^
|
||||||
|
"$EMPTY_VARIABLE"
|
||||||
|
#CHECKERR: {{.*}}checks/vars_as_commands.fish (line {{\d+}}): The expanded command was empty.
|
||||||
|
#CHECKERR: "$EMPTY_VARIABLE"
|
||||||
|
#CHECKERR: ^
|
||||||
|
|
||||||
|
set CMD1 echo basic command as variable
|
||||||
|
$CMD1
|
||||||
|
#CHECK: basic command as variable
|
||||||
|
|
||||||
|
set CMD2 echo '(' not expanded again
|
||||||
|
$CMD2
|
||||||
|
#CHECK: ( not expanded again
|
||||||
|
|
||||||
|
# Test using variables with the builtin decorator
|
||||||
|
builtin $CMD1
|
||||||
|
#CHECK: basic command as variable
|
||||||
|
|
||||||
|
# Test implicit cd
|
||||||
|
set CMD3 /usr/bin
|
||||||
|
$CMD3 && echo $PWD
|
||||||
|
#CHECK: /usr/bin
|
||||||
|
|
||||||
|
exit 0
|
||||||
18
tests/checks/zero_based_array.fish
Normal file
18
tests/checks/zero_based_array.fish
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#RUN: %fish %s
|
||||||
|
echo $foo[0]
|
||||||
|
echo $foo[ 0 ]
|
||||||
|
echo $foo[ 00 ]
|
||||||
|
#CHECKERR: {{.*}}checks/zero_based_array.fish (line {{\d+}}): array indices start at 1, not 0.
|
||||||
|
#CHECKERR: echo $foo[0]
|
||||||
|
#CHECKERR: ^
|
||||||
|
#CHECKERR: {{.*}}checks/zero_based_array.fish (line {{\d+}}): array indices start at 1, not 0.
|
||||||
|
#CHECKERR: echo $foo[ 0 ]
|
||||||
|
#CHECKERR: ^
|
||||||
|
#CHECKERR: {{.*}}checks/zero_based_array.fish (line {{\d+}}): array indices start at 1, not 0.
|
||||||
|
#CHECKERR: echo $foo[ 00 ]
|
||||||
|
#CHECKERR: ^
|
||||||
|
|
||||||
|
# and make sure these didn't break
|
||||||
|
set -l foo one two three
|
||||||
|
echo $foo[001]
|
||||||
|
#CHECK: one
|
||||||
@@ -1 +0,0 @@
|
|||||||
file
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
foo
|
|
||||||
bar
|
|
||||||
baz
|
|
||||||
psub file was deleted
|
|
||||||
psub filename ends with .cc
|
|
||||||
psub filename ends with .cc
|
|
||||||
psub directory was deleted
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
random: Argument 'a' is not a valid integer
|
|
||||||
random: Argument '18446744073709551614' is not a valid integer
|
|
||||||
random: Too many arguments
|
|
||||||
random: END must be greater than START
|
|
||||||
random: Argument '18446744073709551614' is not a valid integer
|
|
||||||
random: Argument '1d' is not a valid integer
|
|
||||||
random: Argument '1c' is not a valid integer
|
|
||||||
random: END must be greater than START
|
|
||||||
random: Argument '-' is not a valid integer
|
|
||||||
random: Argument '-1' is not a valid integer
|
|
||||||
random: Argument '-9223372036854775807' is not a valid integer
|
|
||||||
random: STEP must be a positive integer
|
|
||||||
random: range contains only one possible value
|
|
||||||
random: range contains only one possible value
|
|
||||||
random: nothing to choose from
|
|
||||||
random: Too many arguments
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
status: Invalid combination of options,
|
|
||||||
you cannot do both 'is-interactive' and 'is-login' in the same invocation
|
|
||||||
status: Invalid combination of options,
|
|
||||||
you cannot do both 'is-block' and 'is-interactive' in the same invocation
|
|
||||||
status: Invalid job control mode 'full1'
|
|
||||||
status: Invalid job control mode '1none'
|
|
||||||
|
|
||||||
####################
|
|
||||||
# Future Feature Flags
|
|
||||||
|
|
||||||
####################
|
|
||||||
# Ensure $status isn't reset before a function is executed
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
Not a function
|
|
||||||
test_function
|
|
||||||
test_function
|
|
||||||
|
|
||||||
####################
|
|
||||||
# Future Feature Flags
|
|
||||||
stderr-nocaret off 3.0 ^ no longer redirects stderr
|
|
||||||
qmark-noglob off 3.0 ? no longer globs
|
|
||||||
regex-easyesc off 3.1 string replace -r needs fewer \'s
|
|
||||||
1
|
|
||||||
2
|
|
||||||
|
|
||||||
####################
|
|
||||||
# Ensure $status isn't reset before a function is executed
|
|
||||||
1
|
|
||||||
0
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
builtin: Invalid combination of options,
|
|
||||||
--query and --names are mutually exclusive
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
String exists
|
|
||||||
Some of these exist
|
|
||||||
2
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
fish: The expanded command was empty.
|
|
||||||
$EMPTY_VARIABLE
|
|
||||||
^
|
|
||||||
fish: The expanded command was empty.
|
|
||||||
"$EMPTY_VARIABLE"
|
|
||||||
^
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# Test that using variables as command names work correctly.
|
|
||||||
|
|
||||||
$EMPTY_VARIABLE
|
|
||||||
"$EMPTY_VARIABLE"
|
|
||||||
|
|
||||||
set CMD1 echo basic command as variable
|
|
||||||
$CMD1
|
|
||||||
|
|
||||||
set CMD2 echo '(' not expanded again
|
|
||||||
$CMD2
|
|
||||||
|
|
||||||
# Test using variables with the builtin decorator
|
|
||||||
builtin $CMD1
|
|
||||||
|
|
||||||
# Test implicit cd
|
|
||||||
set CMD3 /usr/bin
|
|
||||||
$CMD3 && echo $PWD
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
basic command as variable
|
|
||||||
( not expanded again
|
|
||||||
basic command as variable
|
|
||||||
/usr/bin
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
fish: array indices start at 1, not 0.
|
|
||||||
echo $foo[0]
|
|
||||||
^
|
|
||||||
fish: array indices start at 1, not 0.
|
|
||||||
echo $foo[ 0 ]
|
|
||||||
^
|
|
||||||
fish: array indices start at 1, not 0.
|
|
||||||
echo $foo[ 00 ]
|
|
||||||
^
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
echo $foo[0]
|
|
||||||
echo $foo[ 0 ]
|
|
||||||
echo $foo[ 00 ]
|
|
||||||
|
|
||||||
# and make sure these didn't break
|
|
||||||
set -l foo one two three
|
|
||||||
echo $foo[001]
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
one
|
|
||||||
Reference in New Issue
Block a user