1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

tests/io.sh: don't abort entire suite on failure

src/cmd/ksh93/tests/io.sh:
- 16 tests for the 'redirect' builtin used the ((arithmetic
  command)) to check the result. This does not tolerate the result
  being a non-number, such as the empty string, which may occur on
  test failure. So use [[ ... -eq ArithExpression ]] to check these
  results instead; it simply returns false, failing gracefully.
This commit is contained in:
Martijn Dekker 2020-06-12 11:34:10 +02:00
parent d8eba9d112
commit 802ea67afb

View file

@ -223,8 +223,8 @@ for ((i=0; i < 62; i++))
do printf "%.39c\n" ${x:i:1} do printf "%.39c\n" ${x:i:1}
done > $tmp/seek done > $tmp/seek
if redirect 3<> $tmp/seek if redirect 3<> $tmp/seek
then (( $(3<#) == 0 )) || err_exit "not at position 0" then [[ $(3<#) -eq 0 ]] || err_exit "not at position 0"
(( $(3<# ((EOF))) == 40*62 )) || err_exit "not at end-of-file" [[ $(3<# ((EOF))) -eq 40*62 ]] || err_exit "not at end-of-file"
redirect 3<# ((40*8)) || err_exit "absolute seek fails" redirect 3<# ((40*8)) || err_exit "absolute seek fails"
read -u3 read -u3
[[ $REPLY == +(i) ]] || err_exit "expected iiii..., got $REPLY" [[ $REPLY == +(i) ]] || err_exit "expected iiii..., got $REPLY"
@ -244,7 +244,7 @@ then (( $(3<#) == 0 )) || err_exit "not at position 0"
[[ $REPLY == +(d) ]] || err_exit "expected ddd..., got $REPLY" [[ $REPLY == +(d) ]] || err_exit "expected ddd..., got $REPLY"
redirect 3># ((EOF)) redirect 3># ((EOF))
print -u3 -f "%.39c\n" ^ print -u3 -f "%.39c\n" ^
(( $(3<# ((CUR-0))) == 40*63 )) || err_exit "not at extended end-of-file" [[ $(3<# ((CUR-0))) -eq 40*63 ]] || err_exit "not at extended end-of-file"
redirect 3<# ((40*62)) redirect 3<# ((40*62))
read -u3 read -u3
[[ $REPLY == +(^) ]] || err_exit "expected ddd..., got $REPLY" [[ $REPLY == +(^) ]] || err_exit "expected ddd..., got $REPLY"
@ -269,7 +269,7 @@ done > $tmp/seek
if redirect {n}<> $tmp/seek if redirect {n}<> $tmp/seek
then { redirect {n}<#((EOF)) ;} 2> /dev/null || err_exit '{n}<# not working' then { redirect {n}<#((EOF)) ;} 2> /dev/null || err_exit '{n}<# not working'
if $SHELL -c '{n}</dev/null' 2> /dev/null if $SHELL -c '{n}</dev/null' 2> /dev/null
then (( $({n}<#) == 40*62)) || err_exit '$({n}<#) not working' then [[ $({n}<#) -eq 40*62 ]] || err_exit '$({n}<#) not working'
else err_exit 'not able to parse {n}</dev/null' else err_exit 'not able to parse {n}</dev/null'
fi fi
fi fi