1 | #!/bin/sh
|
2 |
|
3 | cd "$(realpath "$(dirname "$0")")"
|
4 |
|
5 | mkdir -p _tmp/
|
6 |
|
7 | if [ $# -eq 0 ]
|
8 | then set -- "$PWD"/testdata/*/
|
9 | fi
|
10 |
|
11 | eval 'xargs_py() {' "$(realpath ./xargs.py)" '"$@";' '}'
|
12 |
|
13 | for test
|
14 | do
|
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
|
40 | done
|