Skip to content

Commit b4b552c

Browse files
committed
Add comments to testcase.sh.
1 parent 268a57b commit b4b552c

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

tests/testcase.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,37 @@ set -ueo pipefail
44
# A simple testcase runner that runs a command, captures all its command-line
55
# outputs, and compares them against expected outputs.
66

7+
# Command-line parsing; this script is meant to be run from a # higher-level
8+
# script, so don't do anything fancy.
79
runwasi="$1"
810
clang="$2"
911
options="$3"
1012
input="$4"
1113

14+
# Compile names for generated files.
1215
wasm="$input.$options.wasm"
1316
stdout_observed="$input.$options.stdout.observed"
1417
stderr_observed="$input.$options.stderr.observed"
1518
exit_status_observed="$input.$options.exit_status.observed"
1619

20+
# Optionally load compiler options from a file.
1721
if [ -e "$input.options" ]; then
18-
file_options=$(cat "$inpit.options")
22+
file_options=$(cat "$input.options")
1923
else
2024
file_options=
2125
fi
2226

2327
echo "Testing $input..."
28+
29+
# Determine the input file to write to stdin.
2430
"$clang" $options $file_options "$input" -o "$wasm"
2531
if [ -e "$input.stdin" ]; then
2632
stdin="$input.stdin"
2733
else
2834
stdin="/dev/null"
2935
fi
3036

37+
# Run the test, capturing stdout, stderr, and the exit status.
3138
exit_status=0
3239
"$runwasi" "$wasm" \
3340
< "$stdin" \
@@ -36,6 +43,7 @@ exit_status=0
3643
|| exit_status=$?
3744
echo $exit_status > "$exit_status_observed"
3845

46+
# Determine the reference files to compare with.
3947
if [ -e "$input.stdout.expected" ]; then
4048
stdout_expected="$input.stdout.expected"
4149
else
@@ -52,6 +60,8 @@ else
5260
exit_status_expected=../exit_status_zero
5361
fi
5462

63+
# If there are any differences, diff will return a non-zero exit status, and
64+
# since this script uses "set -e", it will return a non-zero exit status too.
5565
diff -u "$stderr_expected" "$stderr_observed"
5666
diff -u "$stdout_expected" "$stdout_observed"
5767
diff -u "$exit_status_expected" "$exit_status_observed"

0 commit comments

Comments
 (0)