Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Keep the robustness tests to portable shell
An unquoted $cgitbin breaks in a checkout whose path holds a space,
and head -c and head -1 are not POSIX. The status of the disconnected
request is still read right after its pipeline, which assumes the
shell waits for the left side as dash, bash, ksh and busybox ash all
do.
| -rwxr-xr-x | tests/t0301-security.sh | 4 | |
| -rwxr-xr-x | tests/t0303-robustness.sh | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/tests/t0301-security.sh b/tests/t0301-security.sh index f7befe8..4626c2c 100755 --- a/tests/t0301-security.sh +++ b/tests/t0301-security.sh @@ -135,8 +135,8 @@ test_expect_success 'no page carries an inline handler' ' # upstream covers it. test_expect_success 'tree groups directories before files' ' cgit_rc seccgitrc "url=sec/tree/" >tmp && - dirline=$(grep -n "tree/zsub" tmp | head -1 | cut -d: -f1) && - fileline=$(grep -n "tree/afile" tmp | head -1 | cut -d: -f1) && + dirline=$(grep -n "tree/zsub" tmp | head -n 1 | cut -d: -f1) && + fileline=$(grep -n "tree/afile" tmp | head -n 1 | cut -d: -f1) && test -n "$dirline" && test -n "$fileline" && test "$dirline" -lt "$fileline" diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh index a6a439b..0a754d7 100755 --- a/tests/t0303-robustness.sh +++ b/tests/t0303-robustness.sh @@ -608,7 +608,7 @@ test_expect_success NO_VALGRIND 'a snapshot format whose compressor is missing a cgitbin=$(command -v cgit) && mkdir -p nobin && PATH="$PWD/nobin" CGIT_CONFIG="$PWD/xzrc" \ - QUERY_STRING="url=rob/snapshot/rob-master.tar.xz" $cgitbin >tmp && + QUERY_STRING="url=rob/snapshot/rob-master.tar.xz" "$cgitbin" >tmp && grep "^Status: 500" tmp && test $(grep -c "^Status:" tmp) = 1 ' @@ -651,7 +651,7 @@ test_expect_success 'the dumb transport serves an empty repository' ' test_expect_success 'the dumb transport sends a file with its size' ' git -C repos/rob repack -q -d && cgit_rc robrc "url=rob/objects/info/packs" >tmp && - pack=$(strip_headers <tmp | sed -n "s/^P //p" | head -1) && + pack=$(strip_headers <tmp | sed -n "s/^P //p" | head -n 1) && test -n "$pack" && cgit_rc robrc "url=rob/objects/pack/$pack" >tmp && grep "^Status: 200" tmp && @@ -697,7 +697,7 @@ test_expect_success 'a client that disconnects ends the request quietly' ' git add long.txt && git commit -m long ) && - { cgit_rc robrc "url=rob/tree/long.txt" 2>err; echo $? >status; } | head -c 1 >/dev/null && + { cgit_rc robrc "url=rob/tree/long.txt" 2>err; echo $? >status; } | test_copy_bytes 1 >/dev/null && test "$(cat status)" = 0 && ! grep -i "broken pipe" err && ! grep "die()" err |
