| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
usage() { |
| 4 |
[ "${1-}" ] && { to=2; >&$to printf "Error: %s\n" "$1"; } || to=1 |
| 5 |
>&$to echo "Usage: ${0##*/} [OPTIONS] test-file | test-dir" |
| 6 |
>&$to echo "Run test-262 ES5 test file or directory (at the test262 dir)." |
| 7 |
>&$to echo " -s Print source code of failed tests." |
| 8 |
>&$to echo " -p Print every test name before running it" |
| 9 |
>&$to echo " -f Display full paths and full stack trace when possible" |
| 10 |
>&$to echo " -l file.js Load file.js after the harness and before the test (up to one)" |
| 11 |
>&$to echo " -m MUJS MUJS is [path/to/]mujs binary to test" |
| 12 |
>&$to echo " Default is $(dirname "$0")/../build/release/mujs or mujs at \$PATH" |
| 13 |
>&$to echo " -b Don't skip known bad (crashing/hanging) tests" |
| 14 |
>&$to echo " -B Run only known bad tests" |
| 15 |
exit $((to-1)) |
| 16 |
} |
| 17 |
|
| 18 |
KNOWN_BAD=" |
| 19 |
--hang-with-sta.js: |
| 20 |
S15.1.3.2_A2.5_T1.js |
| 21 |
S15.1.3.1_A2.5_T1.js |
| 22 |
|
| 23 |
--Hang-(or-taking-more-than-few-seconds): |
| 24 |
15.4.4.18-3-14.js |
| 25 |
15.4.4.20-3-14.js |
| 26 |
S15.4.4.10_A3_T2.js |
| 27 |
S15.4.4.10_A3_T1.js |
| 28 |
15.4.4.19-3-29.js |
| 29 |
15.4.4.19-3-28.js |
| 30 |
15.4.4.19-3-8.js |
| 31 |
15.4.4.19-3-14.js |
| 32 |
S15.4.4.8_A3_T3.js |
| 33 |
15.4.4.22-3-9.js |
| 34 |
15.4.4.22-3-7.js |
| 35 |
15.4.4.22-3-25.js |
| 36 |
15.4.4.22-3-14.js |
| 37 |
15.4.4.21-3-14.js |
| 38 |
15.4.4.15-3-28.js |
| 39 |
15.4.4.15-3-14.js |
| 40 |
15.4.4.15-3-7.js |
| 41 |
15.4.4.15-3-25.js |
| 42 |
15.4.4.15-3-9.js |
| 43 |
" |
| 44 |
|
| 45 |
SKIP_KNOWN=yes # "yes": skip bad "no": don't skip "neg": run only bad |
| 46 |
PRINT_ALL= |
| 47 |
EXTRA_ARGS= |
| 48 |
mujs= lopt= |
| 49 |
|
| 50 |
while getopts bBfhl:ps o; do |
| 51 |
case $o in |
| 52 |
h) usage ;; |
| 53 |
b) SKIP_KNOWN=no ;; |
| 54 |
B) SKIP_KNOWN=neg ;; |
| 55 |
p) PRINT_ALL=yes ;; |
| 56 |
s) EXTRA_ARGS="$EXTRA_ARGS -s" ;; |
| 57 |
f) EXTRA_ARGS="$EXTRA_ARGS -f" ;; |
| 58 |
l) [ "$OPTARG" ] && lopt=$OPTARG || usage "empty file for -l" ;; |
| 59 |
m) mujs=$OPTARG;; |
| 60 |
*) usage "unknown option -$o" ;; |
| 61 |
esac |
| 62 |
done |
| 63 |
shift $((OPTIND-1)) |
| 64 |
[ $# = 1 ] || usage "expecting one file/dir" |
| 65 |
|
| 66 |
BAD= |
| 67 |
if [ "$SKIP_KNOWN" != no ]; then |
| 68 |
for b in $KNOWN_BAD; do |
| 69 |
BAD="$BAD $b " |
| 70 |
done |
| 71 |
fi |
| 72 |
|
| 73 |
find_root() { |
| 74 |
ROOT=$1 |
| 75 |
n=0 |
| 76 |
while ! [ -e "$ROOT"/test/harness/sta.js ]; do |
| 77 |
ROOT=$ROOT/.. |
| 78 |
n=$((n+1)) |
| 79 |
[ $n -lt 10 ] || usage "can't find test-suite root" |
| 80 |
done |
| 81 |
} |
| 82 |
|
| 83 |
if [ -d "$1" ]; then |
| 84 |
find_root "$1" |
| 85 |
|
| 86 |
if [ "$ROOT" = "$1" ]; then |
| 87 |
FILES_CMD='find "$1/test/suite" -name "*.js" | sort -V' |
| 88 |
else |
| 89 |
FILES_CMD='find "$1" -name "*.js" | sort -V' |
| 90 |
fi |
| 91 |
else |
| 92 |
find_root "$(dirname "$1")" |
| 93 |
FILES_CMD='printf "%s\n" "$1"' |
| 94 |
fi |
| 95 |
|
| 96 |
if ! [ "$mujs" ]; then |
| 97 |
# try to use a recently built mujs rather than a global one |
| 98 |
mujs=$(dirname "$0")/../build/release/mujs |
| 99 |
[ -e "$mujs" ] || mujs=mujs |
| 100 |
fi |
| 101 |
jsharness=$(dirname "$0")/test262-harness.js |
| 102 |
|
| 103 |
total=0 |
| 104 |
skipped=0 |
| 105 |
failed=0 |
| 106 |
|
| 107 |
eval "$FILES_CMD" | ( |
| 108 |
while IFS= read -r f && [ "$f" ]; do |
| 109 |
total=$((total+1)) |
| 110 |
base=${f##*/} |
| 111 |
|
| 112 |
case $BAD in *" $base "*) bad=yes;; *) bad=no;; esac |
| 113 |
|
| 114 |
case $bad-$SKIP_KNOWN in |
| 115 |
yes-yes) |
| 116 |
skipped=$((skipped+1)) |
| 117 |
printf "[Skipping: $base]\n\n" |
| 118 |
;; |
| 119 |
no-neg) # not known bad and running only bad - don't print anything |
| 120 |
skipped=$((skipped+1)) |
| 121 |
;; |
| 122 |
*) |
| 123 |
[ "$PRINT_ALL" ] && echo "Testing: $f" |
| 124 |
if ! "$mujs" -- "$jsharness" $EXTRA_ARGS ${lopt:+-l "$lopt"} "$ROOT" "$f" 2>&1; then |
| 125 |
failed=$((failed+1)) |
| 126 |
echo |
| 127 |
fi |
| 128 |
esac |
| 129 |
done |
| 130 |
|
| 131 |
if [ $total -gt 1 ]; then |
| 132 |
printf "Total: $total\n" |
| 133 |
printf "Pass: %${#total}s\n" $((total - skipped - failed)) |
| 134 |
printf "Skip: %${#total}s\n" $skipped |
| 135 |
printf "Fail: %${#total}s\n" $failed |
| 136 |
fi |
| 137 |
|
| 138 |
[ "$failed" = 0 ] |
| 139 |
) |