OILS / tools / xargs / xargs-test.sh View on Github | oilshell.org

40 lines, 34 significant
1#!/bin/sh
2
3cd "$(realpath "$(dirname "$0")")"
4
5mkdir -p _tmp/
6
7if [ $# -eq 0 ]
8then set -- "$PWD"/testdata/*/
9fi
10
11eval 'xargs_py() {' "$(realpath ./xargs.py)" '"$@";' '}'
12
13for test
14do
15 args="$test/args"
16 stdin="$test/stdin"
17 stdout="_tmp/$(basename "$test")_stdout"
18 stderr="_tmp/$(basename "$test")_stderr"
19 eval xargs $(cat "$args") <"$stdin" >"${stdout}_expected" 2>/dev/null &
20 eval xargs_py $(cat "$args") <"$test/stdin" >"${stdout}_actual" 2>"$stderr"
21 rc_actual=$?
22 wait %1
23 rc_expected=$?
24 if ! cmp -s "${stdout}_expected" "${stdout}_actual"
25 then
26 echo "!!! $(basename "$test") failed: files differ"
27 echo "--- EXPECTED ---"
28 cat "${stdout}_expected"
29 echo "---- ACTUAL ----"
30 cat "${stdout}_actual"
31 echo "----------------"
32 cat "$stderr"
33 elif [ $rc_expected != $rc_actual ]
34 then
35 echo "!!! $(basename "$test") failed: rcs differ"
36 echo "EXPECTED=$rc_expected ACTUAL=$rc_actual"
37 else
38 echo " $(basename "$test") ok"
39 fi
40done