Permalink
Browse files

Use argv.py instead of argv in spec tests (#129)

  • Loading branch information...
Yorwba authored and andychu committed May 29, 2018
1 parent dbc0bcc commit 704495489c0b3a40a3539915002cf1391f9aaa9e
Showing with 16 additions and 16 deletions.
  1. +3 −3 spec/append.test.sh
  2. +6 −6 spec/builtin-io.test.sh
  3. +2 −2 spec/command-sub.test.sh
  4. +3 −3 spec/var-op-strip.test.sh
  5. +2 −2 spec/var-sub-quote.test.sh
View
@@ -91,13 +91,13 @@ f
f() {
# NOTE: mksh doesn't like a=() after keyword. Doesn't allow local arrays!
local x+=(a b)
argv "${x[@]}"
argv.py "${x[@]}"
y+=(c d)
argv "${y[@]}"
argv.py "${y[@]}"
readonly z+=(e f)
argv "${z[@]}"
argv.py "${z[@]}"
}
f
# stdout-json: "['a', 'b']\n['c', 'd']\n['e', 'f']\n"
View
@@ -213,7 +213,7 @@ echo "[$x]"
### Read from empty file
echo -n '' > $TMP/empty.txt
read x < $TMP/empty.txt
argv "status=$?" "$x"
argv.py "status=$?" "$x"
# stdout: ['status=1', '']
# status: 0
@@ -264,14 +264,14 @@ echo $REPLY
echo 'one\ two' > $TMP/readr.txt
read escaped < $TMP/readr.txt
read -r raw < $TMP/readr.txt
argv "$escaped" "$raw"
argv.py "$escaped" "$raw"
# stdout: ['one two', 'one\\ two']
### read -r with other backslash escapes
echo 'one\ two\x65three' > $TMP/readr.txt
read escaped < $TMP/readr.txt
read -r raw < $TMP/readr.txt
argv "$escaped" "$raw"
argv.py "$escaped" "$raw"
# mksh respects the hex escapes here, but other shells don't!
# stdout: ['one twox65three', 'one\\ two\\x65three']
# BUG mksh/zsh stdout: ['one twoethree', 'one\\ twoethree']
@@ -282,7 +282,7 @@ tmp=$TMP/$(basename $SH)-readr.txt
echo -e 'one\\\ntwo\n' > $tmp
read escaped < $tmp
read -r raw < $tmp
argv "$escaped" "$raw"
argv.py "$escaped" "$raw"
# stdout: ['onetwo', 'one\\']
# N-I dash stdout: ['-e onetwo', '-e one\\']
@@ -293,14 +293,14 @@ two three-\
four five-\
six
EOF
argv "$x" "$y" "$z"
argv.py "$x" "$y" "$z"
# stdout: ['one-two', 'three-four five-six', '']
### read -r with \n
echo '\nline' > $TMP/readr.txt
read escaped < $TMP/readr.txt
read -r raw < $TMP/readr.txt
argv "$escaped" "$raw"
argv.py "$escaped" "$raw"
# dash/mksh/zsh are bugs because at least the raw mode should let you read a
# literal \n.
# stdout: ['nline', '\\nline']
View
@@ -70,12 +70,12 @@ argv.py $(echo 'hi there') "$(echo 'hi there')"
### Command Sub trailing newline removed
s=$(python -c 'print "ab\ncd\n"')
argv "$s"
argv.py "$s"
# stdout: ['ab\ncd']
### Command Sub trailing whitespace not removed
s=$(python -c 'print "ab\ncd\n "')
argv "$s"
argv.py "$s"
# stdout: ['ab\ncd\n ']
### Command Sub and exit code
@@ -70,16 +70,16 @@ echo ${v#?} # ? is a glob that stands for one character
### Bug fix: Test that you can remove everything with glob
s='--x--'
argv "${s%%-*}" "${s%-*}" "${s#*-}" "${s##*-}"
argv.py "${s%%-*}" "${s%-*}" "${s#*-}" "${s##*-}"
## STDOUT:
['', '--x-', '-x--', '']
## END
### Test that you can remove everything with const
s='abcd'
argv "${s%%abcd}" "${s%abcd}" "${s#abcd}" "${s##abcd}"
argv.py "${s%%abcd}" "${s%abcd}" "${s#abcd}" "${s##abcd}"
# failure case:
argv "${s%%abcde}" "${s%abcde}" "${s#abcde}" "${s##abcde}"
argv.py "${s%%abcde}" "${s%abcde}" "${s#abcde}" "${s##abcde}"
## STDOUT:
['', '', '', '']
['abcd', 'abcd', 'abcd', 'abcd']
@@ -105,12 +105,12 @@ argv.py "${Unset:-"a b" c}"
# stdout: ['a b c']
### part_value tree with multiple words
argv ${a:-${a:-"1 2" "3 4"}5 "6 7"}
argv.py ${a:-${a:-"1 2" "3 4"}5 "6 7"}
# stdout: ['1 2', '3 45', '6 7']
### part_value tree on RHS
v=${a:-${a:-"1 2" "3 4"}5 "6 7"}
argv "${v}"
argv.py "${v}"
# stdout: ['1 2 3 45 6 7']
### Var with multiple words: no quotes

0 comments on commit 7044954

Please sign in to comment.