mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-15 09:27:38 +00:00
Port cmdsub tests to littlecheck
This commit is contained in:
parent
5bfb6fef76
commit
b99546e7a0
4 changed files with 67 additions and 92 deletions
67
tests/checks/cmdsub-limit.fish
Normal file
67
tests/checks/cmdsub-limit.fish
Normal file
|
@ -0,0 +1,67 @@
|
|||
# RUN: %fish %s
|
||||
|
||||
# This tests various corner cases involving command substitution. Most
|
||||
# importantly the limits on the amount of data we'll substitute.
|
||||
|
||||
set fish_read_limit 512
|
||||
|
||||
function subme
|
||||
set -l x (string repeat -n $argv x)
|
||||
echo $x
|
||||
end
|
||||
|
||||
# Command sub just under the limit should succeed
|
||||
set a (subme 511)
|
||||
set --show a
|
||||
#CHECK: $a: not set in local scope
|
||||
#CHECK: $a: set in global scope, unexported, with 1 elements
|
||||
#CHECK: $a[1]: length=511 value=|{{x{510}x}}|
|
||||
#CHECK: $a: not set in universal scope
|
||||
|
||||
# Command sub at the limit should fail
|
||||
set b (string repeat -n 512 x)
|
||||
set saved_status $status
|
||||
test $saved_status -eq 122
|
||||
or echo expected status 122, saw $saved_status >&2
|
||||
set --show b
|
||||
|
||||
#CHECK: $b: not set in local scope
|
||||
#CHECK: $b: not set in global scope
|
||||
#CHECK: $b: not set in universal scope
|
||||
#CHECKERR: {{.*}}: Too much data emitted by command substitution so it was discarded
|
||||
#CHECKERR:
|
||||
#CHECKERR: set b (string repeat -n 512 x)
|
||||
#CHECKERR: ^
|
||||
|
||||
|
||||
# Command sub over the limit should fail
|
||||
set c (subme 513)
|
||||
set --show c
|
||||
|
||||
#CHECK: $c: not set in local scope
|
||||
#CHECK: $c: set in global scope, unexported, with 1 elements
|
||||
#CHECK: $c[1]: length=0 value=||
|
||||
#CHECK: $c: not set in universal scope
|
||||
#CHECKERR: {{.*}}: Too much data emitted by command substitution so it was discarded
|
||||
#CHECKERR:
|
||||
#CHECKERR: set -l x (string repeat -n $argv x)
|
||||
#CHECKERR: ^
|
||||
#CHECKERR: in function 'subme' with arguments '513'
|
||||
#CHECKERR: called on line {{.*}}
|
||||
#CHECKERR: in command substitution
|
||||
#CHECKERR: called on line {{.*}}
|
||||
|
||||
# Make sure output from builtins outside of command substitution is not affected
|
||||
string repeat --max 513 a
|
||||
#CHECK: {{a{512}a}}
|
||||
|
||||
# Same builtin in a command substitution is affected
|
||||
echo this will fail (string repeat --max 513 b) to output anything
|
||||
set saved_status $status
|
||||
test $saved_status -eq 122
|
||||
or echo expected status 122, saw $saved_status >&2
|
||||
|
||||
#CHECKERR: {{.*}}: Too much data emitted by command substitution so it was discarded
|
||||
#CHECKERR:
|
||||
#CHECKERR: echo this will fail (string repeat --max 513 b) to output anything
|
||||
#CHECKERR: ^
|
|
@ -1,29 +0,0 @@
|
|||
|
||||
####################
|
||||
# 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
|
||||
|
||||
set -l x (string repeat -n $argv x)
|
||||
^
|
||||
in function 'subme' with arguments '513'
|
||||
in command substitution
|
||||
|
||||
####################
|
||||
# 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
|
||||
|
||||
echo this will fail (string repeat --max 513 b) to output anything
|
||||
^
|
|
@ -1,33 +0,0 @@
|
|||
# This tests various corner cases involving command substitution. Most
|
||||
# importantly the limits on the amount of data we'll substitute.
|
||||
|
||||
set fish_read_limit 512
|
||||
|
||||
function subme
|
||||
set -l x (string repeat -n $argv x)
|
||||
echo $x
|
||||
end
|
||||
|
||||
logmsg Command sub just under the limit should succeed
|
||||
set a (subme 511)
|
||||
set --show a
|
||||
|
||||
logmsg Command sub at the limit should fail
|
||||
set b (string repeat -n 512 x)
|
||||
set saved_status $status
|
||||
test $saved_status -eq 122
|
||||
or echo expected status 122, saw $saved_status >&2
|
||||
set --show b
|
||||
|
||||
logmsg Command sub over the limit should fail
|
||||
set c (subme 513)
|
||||
set --show c
|
||||
|
||||
logmsg Make sure output from builtins outside of command substitution is not affected
|
||||
string repeat --max 513 a
|
||||
|
||||
logmsg Same builtin in a command substitution is affected
|
||||
echo this will fail (string repeat --max 513 b) to output anything
|
||||
set saved_status $status
|
||||
test $saved_status -eq 122
|
||||
or echo expected status 122, saw $saved_status >&2
|
|
@ -1,30 +0,0 @@
|
|||
|
||||
####################
|
||||
# Command sub just under the limit should succeed
|
||||
$a: not set in local scope
|
||||
$a: set in global scope, unexported, with 1 elements
|
||||
$a[1]: 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 1 elements
|
||||
$c[1]: length=0 value=||
|
||||
$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
|
Loading…
Reference in a new issue