From 53f1090b861cef6996ac8e54139c0fe64477d784 Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Thu, 25 Jun 2020 15:35:20 -0700 Subject: 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. --- Libraries/LibJS/Tests/run-tests.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Libraries') 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 -- cgit v1.2.3