summaryrefslogtreecommitdiff
path: root/Libraries
diff options
context:
space:
mode:
authorMatthew Olsson <matthewcolsson@gmail.com>2020-06-25 15:35:20 -0700
committerAndreas Kling <kling@serenityos.org>2020-06-26 12:40:07 +0200
commit53f1090b861cef6996ac8e54139c0fe64477d784 (patch)
tree5530cf057dc07353d475bd959528a87d54d04021 /Libraries
parent981f40328700361e0f1da218cbd64b98463fce2f (diff)
downloadserenity-53f1090b861cef6996ac8e54139c0fe64477d784.zip
LibJS: run-test.sh emits test output if it is not "PASS"
Previously, debugging a test with console.log statements was impossible, because it would just cause the test to fail with no additional output. Now, if the output of a test is not "PASS", the output will be printed under the line where the test failed. Empty output will have a special message attached to it -- useful when a test author has forgotten to include `console.log("PASS")` at the end of a test.
Diffstat (limited to 'Libraries')
-rwxr-xr-xLibraries/LibJS/Tests/run-tests.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/Libraries/LibJS/Tests/run-tests.sh b/Libraries/LibJS/Tests/run-tests.sh
index 207dc950dc..a320797593 100755
--- a/Libraries/LibJS/Tests/run-tests.sh
+++ b/Libraries/LibJS/Tests/run-tests.sh
@@ -31,6 +31,22 @@ for f in *.js; do
fi
echo -ne "\033]9;${count};${test_count}\033\\"
echo "$f"
+
+ if [ "$result" != "PASS" ]; then
+ if [ -z "$result" ]; then
+ echo -e " \033[31;1mNo output. Did you forget 'console.log(\"PASS\");'?\033[0m"
+ else
+ readarray -t split_result <<< "$result";
+
+ echo -ne " \033[31;1mOutput:\033[0m: "
+ echo "${split_result[0]}";
+
+ for (( i = 1; i < ${#split_result[@]}; i++ )); do
+ echo " ${split_result[i]}"
+ done
+ fi
+ fi
+
(( ++count ))
done