Skip to content

Commit cee1131

Browse files
committed
test: correctly fail on errors in test suite
1 parent ca9cfd2 commit cee1131

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

test.sh

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
#!/bin/bash
2-
# set -e
3-
4-
EXPECTED='(x): number => 123\n'
5-
ACTUAL=$(echo '( \n x ) : number => 123 ' | /usr/bin/env node index.js -assume-filename a.js)
6-
if [[ "$ACTUAL" = "$EXPECTED" ]]; then
7-
echo "[FAIL] Expected $EXPECTED, got $ACTUAL" >&2
8-
exit 1
9-
fi
2+
set -e
103

114
# Make sure we can run on relative an absolute paths (set -e checks for errors).
125
/usr/bin/env node index.js index.js >/dev/null
@@ -21,7 +14,7 @@ EXPECTED_GLOB_STRING="ran google-java-format on 2 files" # somewhere in there
2114

2215
(
2316
cd "$PWD"/testproject
24-
yarn > /dev/null # Should give us a local clang-format, version doesn't really matter.
17+
yarn > /dev/null # Should give us a local google-java-format, version doesn't really matter.
2518
VERSION=$(/usr/bin/env node "$FULL_SCRIPT_PATH" -version)
2619
if [[ $VERSION != *"$EXPECTED_VERSION_STRING"* ]]; then
2720
echo "[FAIL] Expected string containing $EXPECTED_VERSION_STRING, got $VERSION" >&2
@@ -49,6 +42,7 @@ fi
4942
echo "[PASS] glob argument resolution" >&2
5043

5144
echo "(The next output lines will be an expected error, as we test error codes)"
45+
set +e
5246
eval "/usr/bin/env node $FULL_SCRIPT_PATH --set-exit-if-changed -n --glob=testproject/**/*.java"
5347
if [ "$?" != 1 ]; then
5448
echo "[FAIL] Expected return status to be 1, got $?" >&2

0 commit comments

Comments
 (0)