Make test262 updater reusable in other repositories.
MODIFY
scripts/update-test262.sh
scripts/update-test262.sh
#!/bin/sh
+TEST_MATCH='flags:\s*\[[^]]*module[^[]*]'
+
+TEST_DIRS=(
+ '/test/language/module-code'
+ '/test/language/expressions/dynamic-import'
+)
+
# command path is not set on MacOS for security
LS=/bin/ls
GREP=/usr/bin/grep
@@ -11,7 +18,7 @@ GIT=/usr/local/bin/git
display_usage() {
echo "This updates the test262 test files."
echo "Given a clone of the test262 git repo, it copies all tests"
- echo "that validate conformance to TC39 module specifications."
+ echo "that validate conformance to TC39 specifications."
echo "\nUsage:\nupdate-test262 <path-to-test262-git-clone>\n"
}
@@ -31,7 +38,7 @@ if [ -z "$PATH" ]
fi
# check wheter we have the signature of a root test262 repo
-if [[ (! -e "$PATH"/README.md ) || (! -e "$PATH"/package.json) || (! -d "$PATH"/test ) || (! -d "$PATH"/harness ) ]]
+if [[ (! -e "$PATH/README.md" ) || (! -e "$PATH/package.json") || (! -d "$PATH/test" ) || (! -d "$PATH/harness" ) ]]
then
echo "Path provided not a test262 git clone."
exit 1
@@ -56,10 +63,16 @@ if [ "$($LS -A test262/test)" ]
# find all files matching `flags: [ module ]`
# copy archives in copy-pass mode, make directories, preserve modification time
echo "copying files..."
-$GREP -lr 'flags:\s*\[[^]]*module[^[]*]' "$PATH"/test | $CPIO -pdm --quiet test262
-# ensure module fixtures are also copied
-$FIND ../test262/test/language/module-code -name *.js | $CPIO -pdm --quiet test262
-$FIND ../test262/test/language/expressions/dynamic-import -name *.js | $CPIO -pdm --quiet test262
+
+# Copy by regexp
+$GREP -lr $TEST_MATCH "$PATH/test" | $CPIO -pdm --quiet test262
+
+# Copy by directory
+for DIR in "${TEST_DIRS[@]}"
+ do
+ $FIND "$PATH$DIR" -name *.js | $CPIO -pdm --quiet test262
+ done
+
COUNT=`$FIND test262/test -name *.js | $WC -l`
echo "$COUNT files copied."
@@ -68,4 +81,3 @@ ORIGIN=`(cd "$PATH"; $GIT config --get remote.origin.url)`
REVISION=`(cd "$PATH"; $GIT rev-parse HEAD)`;
echo "test262 remote url: $ORIGIN\ntest262 revision: $REVISION" > test262/test262-revision.txt
echo "test262/test262-revision.txt updated."
-

MODIFY
test262/README.md
test262/README.md
# Test262 subset
This directory contains a copy of the ECMAScript compliace tests (test262)
-relevant to modules.
+relevant to this package.
## Justification
@@ -37,9 +37,10 @@ The argument is the path to a directory containing a test262 git repo created us
git clone https://github.com/tc39/test262.git
```
-All tests that specify `flags: [ module ]` in their preamble will be copied across
-by the update script, as well as all tests and fixtures from `test262/test/language/module-code/`
-and from `test262/test/language/expressions/dynamic-import/`.
+All tests that specify `flags: [ <something> ]` in their preamble will be copied across
+by the update script, as well as all tests and fixtures from a selected set of paths.
+See `./scripts/update-test262.sh` for the selection criteria.
+
The file `test262/test262-revision.txt` will also be updated with the information relevant
to the version of test262 used. Make sure you commit that file along with the updated
tests.

Make test262 updater reusable in other repositories.