|
1 #!/bin/sh |
|
2 # This Source Code Form is subject to the terms of the Mozilla Public |
|
3 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
5 |
|
6 # Abort when an error occurs. |
|
7 set -e |
|
8 |
|
9 # Updates the jstests copy of the test cases of Test262, the conformance test |
|
10 # suite for ECMA-262 and ECMA-402, ECMAScript and its Internationalization API. |
|
11 |
|
12 function usage() |
|
13 { |
|
14 echo "Usage: update-test262.sh <URL of test262 hg> [clone | copy]" |
|
15 echo "" |
|
16 echo "The URL will most commonly be http://hg.ecmascript.org/tests/test262/ " |
|
17 echo "but may also be a local clone. Don't use a local clone when generating" |
|
18 echo "the final import patch"\!" test262/HG-INFO will record the wrong URL" |
|
19 echo "if you do so. Local cloning is only useful when editing this script to" |
|
20 echo "import a larger test262 subset." |
|
21 echo "" |
|
22 echo "If a local clone is specified, the optional clone/copy argument will" |
|
23 echo "either clone into a temporary directory, or directly copy from the" |
|
24 echo "clone's checkout. 'clone' semantics are the default." |
|
25 exit 1 |
|
26 } |
|
27 |
|
28 if [ $# -lt 1 ]; then |
|
29 usage |
|
30 elif [ $# -eq 1 -o "$2" == "clone" ]; then |
|
31 # Beware! 'copy' support requires that the clone performed here *never* be |
|
32 # altered. If it were altered, those changes wouldn't appear in the final |
|
33 # set of changes as determined by the 'copy' path below. |
|
34 |
|
35 # Mercurial doesn't have a way to download just a part of a repository, or to |
|
36 # just get the working copy - we have to clone the entire thing. We use a |
|
37 # temporary test262 directory for that. |
|
38 unique_dir=`mktemp -d /tmp/test262.XXXX` || exit 1 |
|
39 tmp_dir=${unique_dir}/test262 |
|
40 |
|
41 # Remove the temporary test262 directory on exit. |
|
42 function cleanupTempFiles() |
|
43 { |
|
44 rm -rf ${unique_dir} |
|
45 } |
|
46 trap cleanupTempFiles EXIT |
|
47 |
|
48 echo "Feel free to get some coffee - this could take a few minutes..." |
|
49 hg clone $1 ${tmp_dir} |
|
50 elif [ "$2" == "copy" ]; then |
|
51 echo "Copying directly from $1; be sure this repository is updated to tip"\! |
|
52 tmp_dir="$1" |
|
53 else |
|
54 usage |
|
55 fi |
|
56 |
|
57 # Now to the actual test262 directory. |
|
58 js_src_tests_dir=`dirname $0` |
|
59 test262_dir=${js_src_tests_dir}/test262 |
|
60 rm -rf ${test262_dir} |
|
61 mkdir ${test262_dir} |
|
62 |
|
63 # Copy over the test262 license. |
|
64 cp ${tmp_dir}/LICENSE ${test262_dir} |
|
65 |
|
66 # The test262 tests are in test/suite. The "bestPractice" tests cover non- |
|
67 # standard extensions, or are not strictly required by specs, so we don't |
|
68 # include them. The remaining tests are currently in "intl402" or "chNN" |
|
69 # directories (where NN is an ECMA-262 chapter number). This may change at |
|
70 # some point, as there is some dissatisfaction on test262-discuss with using |
|
71 # impermanent section numbering (across ES5, ES6, etc.) to identify what's |
|
72 # tested. |
|
73 # |
|
74 # The large quantity of tests at issue here, and the variety of things being |
|
75 # tested, motivate importing portions of test262 incrementally. So rather than |
|
76 # doing this: |
|
77 # |
|
78 # cp -r ${tmp_dir}/test/suite/ch* ${test262_dir} |
|
79 # |
|
80 # ...we instead individually import folders whose tests we pass. (Well, mostly |
|
81 # pass -- see the comment at the end of this script.) |
|
82 cp -r ${tmp_dir}/test/suite/ch06 ${test262_dir}/ch06 |
|
83 cp -r ${tmp_dir}/test/suite/ch07 ${test262_dir}/ch07 |
|
84 cp -r ${tmp_dir}/test/suite/ch08 ${test262_dir}/ch08 |
|
85 cp -r ${tmp_dir}/test/suite/ch09 ${test262_dir}/ch09 |
|
86 cp -r ${tmp_dir}/test/suite/ch10 ${test262_dir}/ch10 |
|
87 cp -r ${tmp_dir}/test/suite/ch11 ${test262_dir}/ch11 |
|
88 cp -r ${tmp_dir}/test/suite/ch12 ${test262_dir}/ch12 |
|
89 cp -r ${tmp_dir}/test/suite/ch13 ${test262_dir}/ch13 |
|
90 cp -r ${tmp_dir}/test/suite/ch14 ${test262_dir}/ch14 |
|
91 |
|
92 # The test402 tests are in test/suite/intl402/. For now there are no |
|
93 # "bestPractice" tests to omit. The remaining tests are in chNN directories, |
|
94 # NN referring to chapters of ECMA-402. |
|
95 # |
|
96 # All intl402 tests are runnable, and only a few currently fail, so we import |
|
97 # them wildcard-style. |
|
98 mkdir ${test262_dir}/intl402 |
|
99 cp -r ${tmp_dir}/test/suite/intl402/ch* ${test262_dir}/intl402 |
|
100 |
|
101 # Copy over harness supporting files needed by the test402 tests. |
|
102 cp ${tmp_dir}/test/harness/sta.js ${js_src_tests_dir}/supporting/ |
|
103 cp ${tmp_dir}/test/harness/testBuiltInObject.js ${js_src_tests_dir}/supporting/ |
|
104 cp ${tmp_dir}/test/harness/testIntl.js ${js_src_tests_dir}/supporting/ |
|
105 |
|
106 # Create empty browser.js and shell.js in all test directories to keep |
|
107 # jstests happy. |
|
108 for dir in `find ${test262_dir} ${test262_dir}/ch* ${test262_dir}/intl402/ch* -type d -print` ; do |
|
109 touch $dir/browser.js |
|
110 touch $dir/shell.js |
|
111 done |
|
112 |
|
113 # Construct the test262 tests' jstests adapter files. |
|
114 cp ${js_src_tests_dir}/supporting/test262-browser.js ${test262_dir}/browser.js |
|
115 cat ${js_src_tests_dir}/supporting/sta.js ${js_src_tests_dir}/supporting/test262-shell.js > ${test262_dir}/shell.js |
|
116 |
|
117 # Restore the Intl tests' jstests adapter files. Loading include files into the |
|
118 # browser from a script so that they become synchronously available to that same |
|
119 # script is basically impossible. Instead, just concatenate all the scripts |
|
120 # together into one script loaded before the test executes. |
|
121 cat ${js_src_tests_dir}/supporting/test402-browser.js \ |
|
122 ${js_src_tests_dir}/supporting/testBuiltInObject.js \ |
|
123 ${js_src_tests_dir}/supporting/testIntl.js > ${test262_dir}/intl402/browser.js |
|
124 cp ${js_src_tests_dir}/supporting/test402-shell.js ${test262_dir}/intl402/shell.js |
|
125 |
|
126 # Keep a record of what we imported. |
|
127 echo "URL: $1" > ${test262_dir}/HG-INFO |
|
128 hg -R ${tmp_dir} log -r. >> ${test262_dir}/HG-INFO |
|
129 |
|
130 # Update for the patch. |
|
131 hg addremove ${js_src_tests_dir}/supporting |
|
132 hg addremove ${test262_dir} |
|
133 |
|
134 # The alert reader may now be wondering: what about test262 tests that we don't |
|
135 # pass? (And what about any test262 tests whose format we don't yet support?) |
|
136 # We explicitly disable all such tests in js/src/tests/jstests.list one by one. |
|
137 # This has the moderate benefit that if a bug is fixed, only that one file must |
|
138 # be updated, and we don't have to rerun this script. |