shithub: libmujs

Download patch

ref: 292415b62547c0bec95ee63d836cb536c1ee9c84
parent: d5f6b3b66ec630d2e15496c8343936e2ff6aa797
author: Avi Halachmi (:avih) <[email protected]>
date: Mon Apr 19 17:54:37 EDT 2021

test262: improve quoting, handle spaces at files/arguments

- Don't coalesce IFS nor interpret backslash at the output of `find'.
- The argument of -m and -l can now be arbitrary.
- The TC39 test262 path and/or files can now be arbitrary.

Previously any of those broke on IFS chars at the value.
Now the only issue is (unlikely) newline at filenames - from `find'.

--- a/tools/test262
+++ b/tools/test262
@@ -7,7 +7,7 @@
 	>&$to echo "  -s          Print source code of failed tests."
 	>&$to echo "  -p          Print every test name before running it"
 	>&$to echo "  -f          Display full paths and full stack trace when possible"
-	>&$to echo "  -l file.js  Load file.js after the harness and before the test"
+	>&$to echo "  -l file.js  Load file.js after the harness and before the test (up to one)"
 	>&$to echo "  -m MUJS     MUJS is [path/to/]mujs binary to test"
 	>&$to echo "                Default is $(dirname "$0")/../build/release/mujs or mujs at \$PATH"
 	>&$to echo "  -b          Don't skip known bad (crashing/hanging) tests"
@@ -45,7 +45,7 @@
 SKIP_KNOWN=yes  # "yes": skip bad  "no": don't skip  "neg": run only bad
 PRINT_ALL=
 EXTRA_ARGS=
-mujs=
+mujs= lopt=
 
 while getopts bBfhl:ps o; do
 	case $o in
@@ -55,7 +55,7 @@
 		p) PRINT_ALL=yes ;;
 		s) EXTRA_ARGS="$EXTRA_ARGS -s" ;;
 		f) EXTRA_ARGS="$EXTRA_ARGS -f" ;;
-		l) EXTRA_ARGS="$EXTRA_ARGS -l $OPTARG" ;;
+		l) [ "$OPTARG" ] && lopt=$OPTARG || usage "empty file for -l" ;;
 		m) mujs=$OPTARG;;
 		*) usage "unknown option -$o" ;;
 	esac
@@ -105,7 +105,7 @@
 failed=0
 
 eval "$FILES_CMD" | (
-	while read f && [ "$f" ]; do
+	while IFS= read -r f && [ "$f" ]; do
 		total=$((total+1))
 		base=${f##*/}
 
@@ -121,7 +121,7 @@
 			;;
 		*)
 			[ "$PRINT_ALL" ] && echo "Testing: $f"
-			if ! $mujs $jsharness $EXTRA_ARGS "$ROOT" $f 2>&1; then
+			if ! "$mujs" -- "$jsharness" $EXTRA_ARGS ${lopt:+-l "$lopt"} "$ROOT" "$f" 2>&1; then
 				failed=$((failed+1))
 				echo
 			fi