fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
30e6aa85e
master
1#RUN: %fish %s 2status -b 3and echo '"status -b" unexpectedly returned true at top level' 4 5begin 6status -b 7or echo '"status -b" unexpectedly returned false inside a begin block' 8end 9 10status -l 11and echo '"status -l" unexpectedly returned true for a non-login shell' 12 13status -i 14and echo '"status -i" unexpectedly returned true for a non-interactive shell' 15 16status is-login 17and echo '"status is-login" unexpectedly returned true for a non-login shell' 18 19status is-interactive 20and echo '"status is-interactive" unexpectedly returned true for a non-interactive shell' 21 22# We should get an error message about an invalid combination of flags. 23status --is-interactive --is-login 24#CHECKERR: status: is-interactive is-login: options cannot be used together 25 26# We should get an error message about an unexpected arg for `status 27# is-block`. 28status -b is-interactive 29#CHECKERR: status: is-block is-interactive: options cannot be used together 30# XXX this would be better if it referred to -b rather than what it is 31 32# Try to set the job control to an invalid mode. 33status job-control full1 34#CHECKERR: status job-control: Invalid job control mode 'full1' 35status --job-control=1none 36#CHECKERR: status: Invalid job control mode '1none' 37 38# Now set it to a valid mode. 39status job-control none 40 41status current-command| sed s/^/^/ 42# CHECK: ^fish 43 44# Check status -u outside functions 45status current-function 46#CHECK: Not a function 47 48function test_function 49status current-function 50end 51 52test_function 53#CHECK: test_function 54eval test_function 55#CHECK: test_function 56 57# Future Feature Flags 58status features| head -n3 59#CHECK: stderr-nocaret on 3.0 ^ no longer redirects stderr (historical, can no longer be changed) 60#CHECK: qmark-noglob on 3.0 ? no longer globs 61#CHECK: regex-easyesc on 3.1 string replace -r needs fewer \'s 62status test-feature stderr-nocaret 63echo $status 64#CHECK: 0 65status test-feature not-a-feature 66echo $status 67#CHECK: 2 68 69# Ensure $status isn't reset before a function is executed 70function echo_last 71echo $status 72end 73 74false 75echo_last 76echo $status #1 77#CHECK: 1 78#CHECK: 0 79 80# Verify that if swallows failure - see #1061 81if false 82end 83echo $status 84#CHECK: 0 85 86# Verify errors from writes - see #7857. 87if test -e /dev/full 88# Failed writes to stdout produce 1. 89echo foo> /dev/full 90if test $status -ne 1 91echo "Wrong status when writing to /dev/full" 92end 93 94# Here the builtin should fail with status 2, 95# and also the write should fail with status 1. 96# The builtin has precedence. 97builtin string --not-a-valid-option2> /dev/full 98if test $status -ne 2 99echo "Wrong status for failing builtin" 100end 101echo "Failed write tests finished" 102else 103echo "Failed write tests skipped" 104echo "write: skipped" 1>&2 105echo "write: skipped" 1>&2 106end 107# CHECK: Failed write tests {{finished|skipped}} 108# CHECKERR: write: {{.*}} 109# CHECKERR: write: {{.*}} 110 111function test-stack-trace-main 112status stack-trace 113end 114 115function test-stack-trace-other 116test-stack-trace-main 117end 118 119printf "%s\n" ( test-stack-trace-other | string replace\t '<TAB>' )[ 1..4] 120# CHECK: in function 'test-stack-trace-main' 121# CHECK: <TAB>called on line {{\d+}} of file {{.*}}/status.fish 122# CHECK: in function 'test-stack-trace-other' 123# CHECK: <TAB>called on line {{\d+}} of file {{.*}}/status.fish 124 125functions -c test-stack-trace-other test-stack-trace-copy 126printf "%s\n" ( test-stack-trace-copy | string replace\t '<TAB>' )[ 1..4] 127# CHECK: in function 'test-stack-trace-main' 128# CHECK: <TAB>called on line {{\d+}} of file {{.*}}/status.fish 129# CHECK: in function 'test-stack-trace-copy' 130# CHECK: <TAB>called on line {{\d+}} of file {{.*}}/status.fish 131 132status test-terminal-feature 133and should have failed on missing arg 134# CHECKERR: status test-terminal-feature: expected 1 arguments; got 0 135status test-terminal-feature1 2 136and should have failed on too many args 137# CHECKERR: status test-terminal-feature: expected 1 arguments; got 2 138status test-terminal-feature unrecognized-feature 139and should have failed on unrecognized feature 140# CHECKERR: status test-terminal-feature: unrecognized feature 'unrecognized-feature' 141status test-terminal-feature scroll-content-up 142and should have failed when running without a TTY 143 144status -L abc 145# CHECKERR: status: abc: invalid integer 146status -L9999999999999999999999 147# CHECKERR: status: Invalid level value '9999999999999999999999' 148 149status unknown-subcmd 150# CHECKERR: status unknown-subcmd: invalid subcommand 151 152status job-control abc cdf 153# CHECKERR: status job-control: expected 1 arguments; got 2 154 155status test-feature 156# CHECKERR: status test-feature: expected 1 arguments; got 0 157status test-feature one two 158# CHECKERR: status test-feature: expected 1 arguments; got 2 159 160status get-file 161# CHECKERR: status get-file: expected 1 arguments; got 0 162status get-file one two 163# CHECKERR: status get-file: expected 1 arguments; got 2 164 165if status buildinfo| string match -q"*localize-messages*" 166echo Skipped 167else 168set -l result"$ ( status language 2>&1 ) " 169if string match -q"fish was built with the `localize-messages` feature disabled. The `status language` command is unavailable." --" $result " 170echo Success 171else 172echo "Failed: $result " 173end 174end 175# CHECK: {{Skipped|Success}} 176 177if not { status buildinfo | string match -q"*localize-messages*" } 178echo Skipped 179else 180set -l result"$ ( status language foo 2>&1 ) " 181if string match -q"status language: foo: invalid subcommand" --" $result " 182echo Success 183else 184echo "Failed: $result " 185end 186end 187# CHECK: {{Skipped|Success}} 188 189status build-info other-arg 190# CHECKERR: status build-info: expected 0 arguments; got 1