From dc33c1afe1b40be281ff55385b2b255ad2a3befb Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Wed, 19 Jul 2017 22:20:28 -0700 Subject: [PATCH] change `show` test utility function Due to how various tests show the status of variables I decided to modify the `show` test utility function I recently added. --- tests/argparse.in | 4 ---- tests/argparse.out | 13 ------------- tests/read.in | 2 +- tests/read.out | 8 ++++---- tests/test_functions/show.fish | 16 +++++++++++++--- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/tests/argparse.in b/tests/argparse.in index 24b9f7979..da5c5f1dc 100644 --- a/tests/argparse.in +++ b/tests/argparse.in @@ -59,28 +59,24 @@ echo '# One arg and no matching flags' begin argparse h/help -- help set -l - show $argv end echo '# Five args with two matching a flag' begin argparse h/help -- help --help me -h 'a lot more' set -l - show $argv end echo '# Required, optional, and multiple flags' begin argparse 'h/help' 'a/abc=' 'd/def=?' 'g/ghk=+' -- help --help me --ghk=g1 --abc=ABC --ghk g2 --d -g g3 set -l - show $argv end echo '# --stop-nonopt works' begin argparse --stop-nonopt 'h/help' 'a/abc=' -- -a A1 -h --abc A2 non-opt 'second non-opt' --help set -l - show $argv end echo '# Implicit int flags work' diff --git a/tests/argparse.out b/tests/argparse.out index 79c13b377..71df1f721 100644 --- a/tests/argparse.out +++ b/tests/argparse.out @@ -1,16 +1,10 @@ # No args # One arg and no matching flags argv help -count=1 -|help| # Five args with two matching a flag _flag_h 2 _flag_help 2 argv 'help' 'me' 'a lot more' -count=3 -|help| -|me| -|a lot more| # Required, optional, and multiple flags _flag_a ABC _flag_abc ABC @@ -21,19 +15,12 @@ _flag_ghk 'g1' 'g2' 'g3' _flag_h 1 _flag_help 1 argv 'help' 'me' -count=2 -|help| -|me| # --stop-nonopt works _flag_a A2 _flag_abc A2 _flag_h 1 _flag_help 1 argv 'non-opt' 'second non-opt' '--help' -count=3 -|non-opt| -|second non-opt| -|--help| # Implicit int flags work _flag_val 123 argv 'abc' 'def' diff --git a/tests/read.in b/tests/read.in index 0fe31ec01..236c2ede8 100644 --- a/tests/read.in +++ b/tests/read.in @@ -193,4 +193,4 @@ if test (string length "$x") -ne $FISH_READ_BYTE_LIMIT 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' +echo abc\ndef | ../test/root/bin/fish -i -c 'read a; read b; show a; show b' diff --git a/tests/read.out b/tests/read.out index 88b445a40..015bb414e 100644 --- a/tests/read.out +++ b/tests/read.out @@ -59,7 +59,7 @@ newline # chunked read tests Chunked reads test pass # Confirm reading non-interactively works (#4206 regression) -count=1 -|abc| -count=1 -|def| +$a count=1 +$a[1]=|abc| +$b count=1 +$b[1]=|def| diff --git a/tests/test_functions/show.fish b/tests/test_functions/show.fish index d644bb3eb..8fe8e1888 100644 --- a/tests/test_functions/show.fish +++ b/tests/test_functions/show.fish @@ -1,4 +1,14 @@ -function show - echo count=(count $argv) - printf '|%s|\n' $argv +# Show information about the named var(s) passed to us. +function show --no-scope-shadowing + for v in $argv + if set -q $v + set -l c (count $$v) + printf '$%s count=%d\n' $v $c + for i in (seq $c) + printf '$%s[%d]=|%s|\n' $v $i $$v[1][$i] + end + else + echo \$$v is not set + end + end end