Skip to content

Commit 0c1bc3d

Browse files
authored
Stop tools tests on unexpected failures (#8545)
Signed-off-by: Christoph Knittel <ck@cca.io>
1 parent 1f72a65 commit 0c1bc3d

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

tests/tools_tests/test.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
15
shopt -s nullglob
26

37
for file in src/*.{res,resi}; do
48
output="$(dirname $file)/expected/$(basename $file).json"
59
../../_build/install/default/bin/rescript-tools doc $file > $output
610
# # CI. We use LF, and the CI OCaml fork prints CRLF. Convert.
7-
if [ "$RUNNER_OS" == "Windows" ]; then
11+
if [ "${RUNNER_OS:-}" == "Windows" ]; then
812
perl -pi -e 's/\r\n/\n/g' -- $output
913
fi
1014
done
1115

1216
for file in ppx/*.res; do
1317
output="src/expected/$(basename $file).jsout"
1418
../../cli/bsc.js -ppx "../../_build/install/default/bin/rescript-tools ppx" $file > $output
15-
if [ "$RUNNER_OS" == "Windows" ]; then
19+
if [ "${RUNNER_OS:-}" == "Windows" ]; then
1620
perl -pi -e 's/\r\n/\n/g' -- $output
1721
fi
1822
done
1923

2024
# Test format-codeblocks command
2125
for file in src/docstrings-format/*.{res,resi,md}; do
2226
output="src/expected/$(basename $file).expected"
23-
../../_build/install/default/bin/rescript-tools format-codeblocks "$file" --stdout > $output
24-
if [ "$RUNNER_OS" == "Windows" ]; then
27+
if [ "$(basename "$file")" == "FormatDocstringsTestError.res" ]; then
28+
if ../../_build/install/default/bin/rescript-tools format-codeblocks "$file" --stdout > "$output" 2>/dev/null; then
29+
echo "Expected format-codeblocks to fail for $file" >&2
30+
exit 1
31+
fi
32+
else
33+
../../_build/install/default/bin/rescript-tools format-codeblocks "$file" --stdout > "$output"
34+
fi
35+
if [ "${RUNNER_OS:-}" == "Windows" ]; then
2536
perl -pi -e 's/\r\n/\n/g' -- $output
2637
fi
2738
done
2839

2940
# Test extract-codeblocks command
3041
for file in src/docstrings-format/*.{res,resi,md}; do
3142
output="src/expected/$(basename $file).extracted.json.expected"
32-
../../_build/install/default/bin/rescript-tools extract-codeblocks "$file" --transform-assert-equal > $output
33-
if [ "$RUNNER_OS" == "Windows" ]; then
43+
if [ "$(basename "$file")" == "FormatDocstringsTestError.res" ]; then
44+
if ../../_build/install/default/bin/rescript-tools extract-codeblocks "$file" --transform-assert-equal > "$output" 2>/dev/null; then
45+
echo "Expected extract-codeblocks to fail for $file" >&2
46+
exit 1
47+
fi
48+
else
49+
../../_build/install/default/bin/rescript-tools extract-codeblocks "$file" --transform-assert-equal > "$output"
50+
fi
51+
if [ "${RUNNER_OS:-}" == "Windows" ]; then
3452
perl -pi -e 's/\r\n/\n/g' -- $output
3553
fi
3654
done
@@ -39,7 +57,7 @@ done
3957
for file in src/migrate/*.{res,resi}; do
4058
output="src/expected/$(basename $file).expected"
4159
../../_build/install/default/bin/rescript-tools migrate "$file" --stdout > $output
42-
if [ "$RUNNER_OS" == "Windows" ]; then
60+
if [ "${RUNNER_OS:-}" == "Windows" ]; then
4361
perl -pi -e 's/\r\n/\n/g' -- $output
4462
fi
4563
done

0 commit comments

Comments
 (0)