1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/update-test262.sh Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,138 @@ 1.4 +#!/bin/sh 1.5 +# This Source Code Form is subject to the terms of the Mozilla Public 1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + 1.9 +# Abort when an error occurs. 1.10 +set -e 1.11 + 1.12 +# Updates the jstests copy of the test cases of Test262, the conformance test 1.13 +# suite for ECMA-262 and ECMA-402, ECMAScript and its Internationalization API. 1.14 + 1.15 +function usage() 1.16 +{ 1.17 + echo "Usage: update-test262.sh <URL of test262 hg> [clone | copy]" 1.18 + echo "" 1.19 + echo "The URL will most commonly be http://hg.ecmascript.org/tests/test262/ " 1.20 + echo "but may also be a local clone. Don't use a local clone when generating" 1.21 + echo "the final import patch"\!" test262/HG-INFO will record the wrong URL" 1.22 + echo "if you do so. Local cloning is only useful when editing this script to" 1.23 + echo "import a larger test262 subset." 1.24 + echo "" 1.25 + echo "If a local clone is specified, the optional clone/copy argument will" 1.26 + echo "either clone into a temporary directory, or directly copy from the" 1.27 + echo "clone's checkout. 'clone' semantics are the default." 1.28 + exit 1 1.29 +} 1.30 + 1.31 +if [ $# -lt 1 ]; then 1.32 + usage 1.33 +elif [ $# -eq 1 -o "$2" == "clone" ]; then 1.34 + # Beware! 'copy' support requires that the clone performed here *never* be 1.35 + # altered. If it were altered, those changes wouldn't appear in the final 1.36 + # set of changes as determined by the 'copy' path below. 1.37 + 1.38 + # Mercurial doesn't have a way to download just a part of a repository, or to 1.39 + # just get the working copy - we have to clone the entire thing. We use a 1.40 + # temporary test262 directory for that. 1.41 + unique_dir=`mktemp -d /tmp/test262.XXXX` || exit 1 1.42 + tmp_dir=${unique_dir}/test262 1.43 + 1.44 + # Remove the temporary test262 directory on exit. 1.45 + function cleanupTempFiles() 1.46 + { 1.47 + rm -rf ${unique_dir} 1.48 + } 1.49 + trap cleanupTempFiles EXIT 1.50 + 1.51 + echo "Feel free to get some coffee - this could take a few minutes..." 1.52 + hg clone $1 ${tmp_dir} 1.53 +elif [ "$2" == "copy" ]; then 1.54 + echo "Copying directly from $1; be sure this repository is updated to tip"\! 1.55 + tmp_dir="$1" 1.56 +else 1.57 + usage 1.58 +fi 1.59 + 1.60 +# Now to the actual test262 directory. 1.61 +js_src_tests_dir=`dirname $0` 1.62 +test262_dir=${js_src_tests_dir}/test262 1.63 +rm -rf ${test262_dir} 1.64 +mkdir ${test262_dir} 1.65 + 1.66 +# Copy over the test262 license. 1.67 +cp ${tmp_dir}/LICENSE ${test262_dir} 1.68 + 1.69 +# The test262 tests are in test/suite. The "bestPractice" tests cover non- 1.70 +# standard extensions, or are not strictly required by specs, so we don't 1.71 +# include them. The remaining tests are currently in "intl402" or "chNN" 1.72 +# directories (where NN is an ECMA-262 chapter number). This may change at 1.73 +# some point, as there is some dissatisfaction on test262-discuss with using 1.74 +# impermanent section numbering (across ES5, ES6, etc.) to identify what's 1.75 +# tested. 1.76 +# 1.77 +# The large quantity of tests at issue here, and the variety of things being 1.78 +# tested, motivate importing portions of test262 incrementally. So rather than 1.79 +# doing this: 1.80 +# 1.81 +# cp -r ${tmp_dir}/test/suite/ch* ${test262_dir} 1.82 +# 1.83 +# ...we instead individually import folders whose tests we pass. (Well, mostly 1.84 +# pass -- see the comment at the end of this script.) 1.85 +cp -r ${tmp_dir}/test/suite/ch06 ${test262_dir}/ch06 1.86 +cp -r ${tmp_dir}/test/suite/ch07 ${test262_dir}/ch07 1.87 +cp -r ${tmp_dir}/test/suite/ch08 ${test262_dir}/ch08 1.88 +cp -r ${tmp_dir}/test/suite/ch09 ${test262_dir}/ch09 1.89 +cp -r ${tmp_dir}/test/suite/ch10 ${test262_dir}/ch10 1.90 +cp -r ${tmp_dir}/test/suite/ch11 ${test262_dir}/ch11 1.91 +cp -r ${tmp_dir}/test/suite/ch12 ${test262_dir}/ch12 1.92 +cp -r ${tmp_dir}/test/suite/ch13 ${test262_dir}/ch13 1.93 +cp -r ${tmp_dir}/test/suite/ch14 ${test262_dir}/ch14 1.94 + 1.95 +# The test402 tests are in test/suite/intl402/. For now there are no 1.96 +# "bestPractice" tests to omit. The remaining tests are in chNN directories, 1.97 +# NN referring to chapters of ECMA-402. 1.98 +# 1.99 +# All intl402 tests are runnable, and only a few currently fail, so we import 1.100 +# them wildcard-style. 1.101 +mkdir ${test262_dir}/intl402 1.102 +cp -r ${tmp_dir}/test/suite/intl402/ch* ${test262_dir}/intl402 1.103 + 1.104 +# Copy over harness supporting files needed by the test402 tests. 1.105 +cp ${tmp_dir}/test/harness/sta.js ${js_src_tests_dir}/supporting/ 1.106 +cp ${tmp_dir}/test/harness/testBuiltInObject.js ${js_src_tests_dir}/supporting/ 1.107 +cp ${tmp_dir}/test/harness/testIntl.js ${js_src_tests_dir}/supporting/ 1.108 + 1.109 +# Create empty browser.js and shell.js in all test directories to keep 1.110 +# jstests happy. 1.111 +for dir in `find ${test262_dir} ${test262_dir}/ch* ${test262_dir}/intl402/ch* -type d -print` ; do 1.112 + touch $dir/browser.js 1.113 + touch $dir/shell.js 1.114 +done 1.115 + 1.116 +# Construct the test262 tests' jstests adapter files. 1.117 +cp ${js_src_tests_dir}/supporting/test262-browser.js ${test262_dir}/browser.js 1.118 +cat ${js_src_tests_dir}/supporting/sta.js ${js_src_tests_dir}/supporting/test262-shell.js > ${test262_dir}/shell.js 1.119 + 1.120 +# Restore the Intl tests' jstests adapter files. Loading include files into the 1.121 +# browser from a script so that they become synchronously available to that same 1.122 +# script is basically impossible. Instead, just concatenate all the scripts 1.123 +# together into one script loaded before the test executes. 1.124 +cat ${js_src_tests_dir}/supporting/test402-browser.js \ 1.125 + ${js_src_tests_dir}/supporting/testBuiltInObject.js \ 1.126 + ${js_src_tests_dir}/supporting/testIntl.js > ${test262_dir}/intl402/browser.js 1.127 +cp ${js_src_tests_dir}/supporting/test402-shell.js ${test262_dir}/intl402/shell.js 1.128 + 1.129 +# Keep a record of what we imported. 1.130 +echo "URL: $1" > ${test262_dir}/HG-INFO 1.131 +hg -R ${tmp_dir} log -r. >> ${test262_dir}/HG-INFO 1.132 + 1.133 +# Update for the patch. 1.134 +hg addremove ${js_src_tests_dir}/supporting 1.135 +hg addremove ${test262_dir} 1.136 + 1.137 +# The alert reader may now be wondering: what about test262 tests that we don't 1.138 +# pass? (And what about any test262 tests whose format we don't yet support?) 1.139 +# We explicitly disable all such tests in js/src/tests/jstests.list one by one. 1.140 +# This has the moderate benefit that if a bug is fixed, only that one file must 1.141 +# be updated, and we don't have to rerun this script.