Is there a way to run test262 in a browser (and especially in web workers)?

# Boris Zbarsky (9 years ago)

It looks like there used to be a ie.microsoft.com/testdrive/HTML5/WebWorkerTest262/Default.html but it's gone.

There also used to be a test262.ecmascript.org (linked from various places on the ecmascript.org wiki) but that's gone too.

Does anyone know whether this test is still available to be run outside of a shell, and especially in web workers, somewhere?

# saam barati (9 years ago)
# Leo Balter (9 years ago)

The current website needs an update. If it makes less painful to run the tests on a shell, you can try bterlson/eshost

# Boris Zbarsky (9 years ago)

On 3/17/16 11:42 AM, Leo Balter wrote:

The current website needs an update. If it makes less painful to run the tests on a shell, you can try bterlson/eshost

I'm specifically looking for a harness that will run the tests in a web worker, so I'm not sure that this helps me... ;)

# Andrea Giammarchi (9 years ago)

I have a little bash script that might help.

Let's say you have the folder ~/tests ... you can prepare the fodler as such.

# go into the folder
cd ~/tests

# prepare 2 dirs
mkdir tmp262
mkdir utils

# will take forever ...
git clone https://github.com/tc39/test262

Now, while it's bringing in test262 you can create a file in ~/tests/utils ... let's call it worker, and you can copy and paste the following in it:

#!/usr/bin/env bash

CURRENT="$(pwd)"
DIR="./"
if [ "${CURRENT:${#CURRENT}-6}" = "/utils" ]; then
  DIR="../"
fi

TMP262=${DIR}tmp262
TEST262=${TMP262}/test262.js

if [ ! -f "$1" ]; then
  mkdir -p $TMP262
  # avoid trailing comma
  echo "[{name:'',test:Object}" > ${TEST262}
  python2 ${DIR}test262/tools/packaging/test262.py --command "$0" --tests
"${DIR}test262/" $@
  echo "].forEach(function(o){console.log(o.name
);try{o.test()}catch(e){console.error(o.name,e)}});" >> ${TEST262}

else
  echo ",{name:'$1',test:function(){" >> ${TEST262}
  cat $1 >> ${TEST262}
  echo "}}" >> ${TEST262}

fi

At this point you can chmod +x ~/tests/utils/worker and once the git clone is complete, you can try with:

./utils/worker built-ins/Array/prototype/reduceRight/15.4.4.22-8-c-5

# or to have a full spec
./utils/worker RegExp

In few words you can pass any argument you could pass to the deprecated console runner.

The result is a file in ~/tests/tmp262/test262.js which is basically an array of tests. You can run these with pretty much any engine you want, hoping it's compatible with the test262 suite.

I know it's not perfect (also the only info it gets about the test at runtime is the tmp file name) but it does the job in some case.

Best