Skip to content

Commit

Permalink
LibJS: Reformat run-tests.sh output
Browse files Browse the repository at this point in the history
- Use emojis instead of the pass/fail text
- Fix the new version of the script to run inside Serenity
- Don't print erroneous output after 'Output:'; start on a newline
instead
- Skip 'run-tests.sh' while testing
  • Loading branch information
mattco98 authored and awesomekling committed Jul 3, 2020
1 parent d5beaa4 commit 6af3fff
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Libraries/LibJS/Tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,41 @@ test_count=0

GLOBIGNORE=test-common.js

test_files=$(find . -type f -name "*.js" | cut -c 3- | sort)
# FIXME: Support "find -name" in Serenity to remove the file name checks below
test_files=$(find . -type f | cut -b 3- | sort)

for f in $test_files; do
if [ "$f" = "test-common.js" ]; then
if [ "$f" = "test-common.js" ] || [ "$f" = "run-tests.sh" ]; then
continue
fi
(( ++test_count ))
done

for f in $test_files; do
if [ "$f" = "test-common.js" ]; then
if [ "$f" = "test-common.js" ] || [ "$f" = "run-tests.sh" ]; then
continue
fi
result="$("$js_program" "$@" -t "$f" 2>/dev/null)"
if [ "$result" = "PASS" ]; then
(( ++pass_count ))
echo -ne "( \033[32;1mPass\033[0m ) "
echo -ne " "
else
echo -ne "( \033[31;1mFail\033[0m ) "
echo -ne " "
(( ++fail_count ))
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"
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]}";
echo -e " \033[31;1mOutput:\033[0m "

for (( i = 1; i < ${#split_result[@]}; i++ )); do
echo " ${split_result[i]}"
for (( i = 0; i < ${#split_result[@]}; i++ )); do
echo " ${split_result[i]}"
done
fi
fi
Expand Down

0 comments on commit 6af3fff

Please sign in to comment.