Commit 586deecb authored by littledan's avatar littledan Committed by Commit bot

[test] Process to locally develop and upstream test262 tests

This patch provides improved infrastructure for developing test262 tests
together with V8. It has three parts:
- The test262 test runner is updated to look for local versions of tests
  in the /test/test262/local-tests directory, which mirrors
  /test/test262/data. Additional tests can be added there and are run
  together with tests from upstream. Upstream tests can be locally
  updated by using the same name in local-tests; if a same-named test
  exists, then only the local version will be run. The local-tests
  directory is in the V8 repository, unlike the contents of the data
  directory, so tests can be added in the same patch as something else.
- The tool /test/test262/upstream-local-tests.sh is added to create
  a patch against the test262 respository based on a patch which changes
  the local-tests directory.
- The tool /test/test262/prune-local-tests.sh is added to remove
  redundant local tests on a test262 roll.

See design doc:
https://docs.google.com/document/d/16bj7AIDgZLv4WOsUEzQ5NzcEN9_xo095e88Pz8FC5rA/edit

Review-Url: https://codereview.chromium.org/2611793002
Cr-Commit-Position: refs/heads/master@{#42117}
parent b5606fe0
......@@ -29,6 +29,7 @@ def filter_git(tar_info):
with tarfile.open('data.tar', 'w') as tar:
tar.add('data', filter=filter_git)
tar.add('harness', filter=filter_git)
tar.add('local-tests')
# Workaround for GN. We can't specify the tarfile as output because it's
# not in the product directory. Therefore we track running of this script
......
......@@ -10,7 +10,8 @@ from itertools import chain
os.chdir(os.path.dirname(os.path.abspath(__file__)))
for root, dirs, files in chain(os.walk("data"), os.walk("harness")):
for root, dirs, files in chain(os.walk("data"), os.walk("harness"),
os.walk("local-tests")):
dirs[:] = [d for d in dirs if not d.endswith('.git')]
for name in files:
# These names are for gyp, which expects slashes on all platforms.
......
// Copyright 2012 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 12.1.1_1
description: Tests that the this-value is ignored in DateTimeFormat.
author: Norbert Lindenberg
includes: [testIntl.js]
---*/
testWithIntlConstructors(function (Constructor) {
var obj, newObj;
if (Constructor === Intl.DateTimeFormat) {
obj = new Constructor();
newObj = Intl.DateTimeFormat.call(obj);
if (obj !== newObj) {
$ERROR("Should have modified existing object.");
}
var key = Object.getOwnPropertySymbols(newObj)[0];
if (!(newObj[key] instanceof Intl.DateTimeFormat)) {
$ERROR("Should have installed a DateTimeFormat instance.");
}
return true;
}
// variant 1: use constructor in a "new" expression
obj = new Constructor();
newObj = Intl.DateTimeFormat.call(obj);
if (obj === newObj) {
$ERROR("DateTimeFormat object created with \"new\" was not ignored as this-value.");
}
// variant 2: use constructor as a function
obj = Constructor();
newObj = Intl.DateTimeFormat.call(obj);
if (obj === newObj) {
$ERROR("DateTimeFormat object created with constructor as function was not ignored as this-value.");
}
return true;
});
// Copyright 2012 Mozilla Corporation. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 11.1.1_1
description: Tests that the this-value is ignored in NumberFormat.
author: Norbert Lindenberg
includes: [testIntl.js]
---*/
testWithIntlConstructors(function (Constructor) {
var obj, newObj;
if (Constructor === Intl.NumberFormat) {
obj = new Constructor();
newObj = Intl.NumberFormat.call(obj);
if (obj !== newObj) {
$ERROR("Should have modified existing object.");
}
var key = Object.getOwnPropertySymbols(newObj)[0];
if (!(newObj[key] instanceof Intl.NumberFormat)) {
$ERROR("Should have installed a NumberFormat instance.");
}
return true;
}
// variant 1: use constructor in a "new" expression
obj = new Constructor();
newObj = Intl.NumberFormat.call(obj);
if (obj === newObj) {
$ERROR("NumberFormat object created with \"new\" was not ignored as this-value.");
}
// variant 2: use constructor as a function
obj = Constructor();
newObj = Intl.NumberFormat.call(obj);
if (obj === newObj) {
$ERROR("NumberFormat object created with constructor as function was not ignored as this-value.");
}
return true;
});
# Copyright 2016 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# usage: test/test262/prune-local-tests.sh
# This script removes redundant tests present in the local-tests directory
# when they are identical to upstreamed tests. It should be run as part of
# the test262 roll process.
find -f test/test262/local-tests | while read localpath; do
datapath=${localpath/local-tests/data}
if diff $localpath $datapath >/dev/null ; then
git rm $localpath || exit 1
fi
done
......@@ -100,10 +100,6 @@
###### END REGEXP SUBCLASSING SECTION ######
# https://code.google.com/p/v8/issues/detail?id=4360
'intl402/DateTimeFormat/12.1.1_1': [FAIL],
'intl402/NumberFormat/11.1.1_1': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=4895
'built-ins/TypedArrays/internals/DefineOwnProperty/detached-buffer': [FAIL],
'built-ins/TypedArrays/internals/DefineOwnProperty/detached-buffer-realm': [FAIL],
......
......@@ -27,6 +27,7 @@
import imp
import itertools
import os
import re
import sys
......@@ -47,6 +48,10 @@ TEST_262_NATIVE_FILES = ["detachArrayBuffer.js"]
TEST_262_SUITE_PATH = ["data", "test"]
TEST_262_HARNESS_PATH = ["data", "harness"]
TEST_262_TOOLS_PATH = ["harness", "src"]
TEST_262_LOCAL_TESTS_PATH = ["local-tests", "test"]
TEST_262_RELPATH_REGEXP = re.compile(
r'.*[\\/]test[\\/]test262[\\/][^\\/]+[\\/]test[\\/](.*)\.js')
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)),
*TEST_262_TOOLS_PATH))
......@@ -101,6 +106,8 @@ class Test262VariantGenerator(testsuite.VariantGenerator):
class Test262TestSuite(testsuite.TestSuite):
# Match the (...) in '/path/to/v8/test/test262/subdir/test/(...).js'
# In practice, subdir is data or local-tests
def __init__(self, name, root):
super(Test262TestSuite, self).__init__(name, root)
......@@ -109,11 +116,14 @@ class Test262TestSuite(testsuite.TestSuite):
self.harness = [os.path.join(self.harnesspath, f)
for f in TEST_262_HARNESS_FILES]
self.harness += [os.path.join(self.root, "harness-adapt.js")]
self.localtestroot = os.path.join(self.root, *TEST_262_LOCAL_TESTS_PATH)
self.ParseTestRecord = None
def ListTests(self, context):
tests = []
for dirname, dirs, files in os.walk(self.testroot):
testnames = set()
for dirname, dirs, files in itertools.chain(os.walk(self.testroot),
os.walk(self.localtestroot)):
for dotted in [x for x in dirs if x.startswith(".")]:
dirs.remove(dotted)
if context.noi18n and "intl402" in dirs:
......@@ -121,19 +131,20 @@ class Test262TestSuite(testsuite.TestSuite):
dirs.sort()
files.sort()
for filename in files:
if filename.endswith(".js") and not filename.endswith("_FIXTURE.js"):
fullpath = os.path.join(dirname, filename)
relpath = fullpath[len(self.testroot) + 1 : -3]
testname = relpath.replace(os.path.sep, "/")
case = testcase.TestCase(self, testname)
tests.append(case)
return tests
if not filename.endswith(".js"):
continue
if filename.endswith("_FIXTURE.js"):
continue
fullpath = os.path.join(dirname, filename)
relpath = re.match(TEST_262_RELPATH_REGEXP, fullpath).group(1)
testnames.add(relpath.replace(os.path.sep, "/"))
return [testcase.TestCase(self, testname) for testname in testnames]
def GetFlagsForTestCase(self, testcase, context):
return (testcase.flags + context.mode_flags + self.harness +
self.GetIncludesForTest(testcase) + ["--harmony"] +
(["--module"] if "module" in self.GetTestRecord(testcase) else []) +
[os.path.join(self.testroot, testcase.path + ".js")] +
[self.GetPathForTest(testcase)] +
(["--throws"] if "negative" in self.GetTestRecord(testcase)
else []) +
(["--allow-natives-syntax"]
......@@ -179,9 +190,14 @@ class Test262TestSuite(testsuite.TestSuite):
includes = []
return includes
def GetPathForTest(self, testcase):
filename = os.path.join(self.localtestroot, testcase.path + ".js")
if not os.path.exists(filename):
filename = os.path.join(self.testroot, testcase.path + ".js")
return filename
def GetSourceForTest(self, testcase):
filename = os.path.join(self.testroot, testcase.path + ".js")
with open(filename) as f:
with open(self.GetPathForTest(testcase)) as f:
return f.read()
def _ParseException(self, str):
......
# Copyright 2016 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# usage: test/test262/upstream-local-tests.sh
# This script takes the files which were modified in the test262 local-test
# directory (test/test262/local-tests) in the top patch of the v8 tree and
# creates a new patch in the local test262 checkout (test/test262/data).
# This patch could then hopefully be used for upstreaming tests.
# The script should be run from the top level directory of the V8 checkout.
git show | grep '+++ b/test/test262/local-tests' | while read test; do
path=${test:6}
datapath=${path/local-tests/data}
echo cp $path $datapath
cp $path $datapath
cd test/test262/data
git add ${datapath:18} || exit 1
cd ../../../
done
cd test/test262/data
git commit || exit 1
......@@ -359,6 +359,8 @@ class SourceProcessor(SourceFileProcessor):
'zlib.js']
IGNORE_TABS = IGNORE_COPYRIGHTS + ['unicode-test.js', 'html-comments.js']
IGNORE_COPYRIGHTS_DIRECTORY = "test/test262/local-tests"
def EndOfDeclaration(self, line):
return line == "}" or line == "};"
......@@ -374,7 +376,8 @@ class SourceProcessor(SourceFileProcessor):
if '\t' in contents:
print "%s contains tabs" % name
result = False
if not base in SourceProcessor.IGNORE_COPYRIGHTS:
if not base in SourceProcessor.IGNORE_COPYRIGHTS and \
not SourceProcessor.IGNORE_COPYRIGHTS_DIRECTORY in name:
if not COPYRIGHT_HEADER_PATTERN.search(contents):
print "%s is missing a correct copyright header." % name
result = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment