michael@0: #!/bin/sh michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # Abort when an error occurs. michael@0: set -e michael@0: michael@0: # Updates the jstests copy of the test cases of Test262, the conformance test michael@0: # suite for ECMA-262 and ECMA-402, ECMAScript and its Internationalization API. michael@0: michael@0: function usage() michael@0: { michael@0: echo "Usage: update-test262.sh [clone | copy]" michael@0: echo "" michael@0: echo "The URL will most commonly be http://hg.ecmascript.org/tests/test262/ " michael@0: echo "but may also be a local clone. Don't use a local clone when generating" michael@0: echo "the final import patch"\!" test262/HG-INFO will record the wrong URL" michael@0: echo "if you do so. Local cloning is only useful when editing this script to" michael@0: echo "import a larger test262 subset." michael@0: echo "" michael@0: echo "If a local clone is specified, the optional clone/copy argument will" michael@0: echo "either clone into a temporary directory, or directly copy from the" michael@0: echo "clone's checkout. 'clone' semantics are the default." michael@0: exit 1 michael@0: } michael@0: michael@0: if [ $# -lt 1 ]; then michael@0: usage michael@0: elif [ $# -eq 1 -o "$2" == "clone" ]; then michael@0: # Beware! 'copy' support requires that the clone performed here *never* be michael@0: # altered. If it were altered, those changes wouldn't appear in the final michael@0: # set of changes as determined by the 'copy' path below. michael@0: michael@0: # Mercurial doesn't have a way to download just a part of a repository, or to michael@0: # just get the working copy - we have to clone the entire thing. We use a michael@0: # temporary test262 directory for that. michael@0: unique_dir=`mktemp -d /tmp/test262.XXXX` || exit 1 michael@0: tmp_dir=${unique_dir}/test262 michael@0: michael@0: # Remove the temporary test262 directory on exit. michael@0: function cleanupTempFiles() michael@0: { michael@0: rm -rf ${unique_dir} michael@0: } michael@0: trap cleanupTempFiles EXIT michael@0: michael@0: echo "Feel free to get some coffee - this could take a few minutes..." michael@0: hg clone $1 ${tmp_dir} michael@0: elif [ "$2" == "copy" ]; then michael@0: echo "Copying directly from $1; be sure this repository is updated to tip"\! michael@0: tmp_dir="$1" michael@0: else michael@0: usage michael@0: fi michael@0: michael@0: # Now to the actual test262 directory. michael@0: js_src_tests_dir=`dirname $0` michael@0: test262_dir=${js_src_tests_dir}/test262 michael@0: rm -rf ${test262_dir} michael@0: mkdir ${test262_dir} michael@0: michael@0: # Copy over the test262 license. michael@0: cp ${tmp_dir}/LICENSE ${test262_dir} michael@0: michael@0: # The test262 tests are in test/suite. The "bestPractice" tests cover non- michael@0: # standard extensions, or are not strictly required by specs, so we don't michael@0: # include them. The remaining tests are currently in "intl402" or "chNN" michael@0: # directories (where NN is an ECMA-262 chapter number). This may change at michael@0: # some point, as there is some dissatisfaction on test262-discuss with using michael@0: # impermanent section numbering (across ES5, ES6, etc.) to identify what's michael@0: # tested. michael@0: # michael@0: # The large quantity of tests at issue here, and the variety of things being michael@0: # tested, motivate importing portions of test262 incrementally. So rather than michael@0: # doing this: michael@0: # michael@0: # cp -r ${tmp_dir}/test/suite/ch* ${test262_dir} michael@0: # michael@0: # ...we instead individually import folders whose tests we pass. (Well, mostly michael@0: # pass -- see the comment at the end of this script.) michael@0: cp -r ${tmp_dir}/test/suite/ch06 ${test262_dir}/ch06 michael@0: cp -r ${tmp_dir}/test/suite/ch07 ${test262_dir}/ch07 michael@0: cp -r ${tmp_dir}/test/suite/ch08 ${test262_dir}/ch08 michael@0: cp -r ${tmp_dir}/test/suite/ch09 ${test262_dir}/ch09 michael@0: cp -r ${tmp_dir}/test/suite/ch10 ${test262_dir}/ch10 michael@0: cp -r ${tmp_dir}/test/suite/ch11 ${test262_dir}/ch11 michael@0: cp -r ${tmp_dir}/test/suite/ch12 ${test262_dir}/ch12 michael@0: cp -r ${tmp_dir}/test/suite/ch13 ${test262_dir}/ch13 michael@0: cp -r ${tmp_dir}/test/suite/ch14 ${test262_dir}/ch14 michael@0: michael@0: # The test402 tests are in test/suite/intl402/. For now there are no michael@0: # "bestPractice" tests to omit. The remaining tests are in chNN directories, michael@0: # NN referring to chapters of ECMA-402. michael@0: # michael@0: # All intl402 tests are runnable, and only a few currently fail, so we import michael@0: # them wildcard-style. michael@0: mkdir ${test262_dir}/intl402 michael@0: cp -r ${tmp_dir}/test/suite/intl402/ch* ${test262_dir}/intl402 michael@0: michael@0: # Copy over harness supporting files needed by the test402 tests. michael@0: cp ${tmp_dir}/test/harness/sta.js ${js_src_tests_dir}/supporting/ michael@0: cp ${tmp_dir}/test/harness/testBuiltInObject.js ${js_src_tests_dir}/supporting/ michael@0: cp ${tmp_dir}/test/harness/testIntl.js ${js_src_tests_dir}/supporting/ michael@0: michael@0: # Create empty browser.js and shell.js in all test directories to keep michael@0: # jstests happy. michael@0: for dir in `find ${test262_dir} ${test262_dir}/ch* ${test262_dir}/intl402/ch* -type d -print` ; do michael@0: touch $dir/browser.js michael@0: touch $dir/shell.js michael@0: done michael@0: michael@0: # Construct the test262 tests' jstests adapter files. michael@0: cp ${js_src_tests_dir}/supporting/test262-browser.js ${test262_dir}/browser.js michael@0: cat ${js_src_tests_dir}/supporting/sta.js ${js_src_tests_dir}/supporting/test262-shell.js > ${test262_dir}/shell.js michael@0: michael@0: # Restore the Intl tests' jstests adapter files. Loading include files into the michael@0: # browser from a script so that they become synchronously available to that same michael@0: # script is basically impossible. Instead, just concatenate all the scripts michael@0: # together into one script loaded before the test executes. michael@0: cat ${js_src_tests_dir}/supporting/test402-browser.js \ michael@0: ${js_src_tests_dir}/supporting/testBuiltInObject.js \ michael@0: ${js_src_tests_dir}/supporting/testIntl.js > ${test262_dir}/intl402/browser.js michael@0: cp ${js_src_tests_dir}/supporting/test402-shell.js ${test262_dir}/intl402/shell.js michael@0: michael@0: # Keep a record of what we imported. michael@0: echo "URL: $1" > ${test262_dir}/HG-INFO michael@0: hg -R ${tmp_dir} log -r. >> ${test262_dir}/HG-INFO michael@0: michael@0: # Update for the patch. michael@0: hg addremove ${js_src_tests_dir}/supporting michael@0: hg addremove ${test262_dir} michael@0: michael@0: # The alert reader may now be wondering: what about test262 tests that we don't michael@0: # pass? (And what about any test262 tests whose format we don't yet support?) michael@0: # We explicitly disable all such tests in js/src/tests/jstests.list one by one. michael@0: # This has the moderate benefit that if a bug is fixed, only that one file must michael@0: # be updated, and we don't have to rerun this script.