Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2015 the V8 project authors. All rights reserved. |
|
Michael Achenbach
2015/05/19 07:17:48
Please use shorter licence headers as in
https://c
bradn
2015/05/19 09:37:53
Done.
| |
| 2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
| 3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
| 4 # met: | 4 # met: |
| 5 # | 5 # |
| 6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
| 7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
| 8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
| 9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
| 10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
| 11 # with the distribution. | 11 # with the distribution. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 | 28 |
| 29 import hashlib | 29 import hashlib |
| 30 import os | 30 import os |
| 31 import shutil | 31 import shutil |
| 32 import sys | 32 import sys |
| 33 import tarfile | 33 import tarfile |
| 34 import imp | |
| 34 | 35 |
| 35 from testrunner.local import testsuite | 36 from testrunner.local import testsuite |
| 36 from testrunner.local import utils | 37 from testrunner.local import utils |
| 37 from testrunner.objects import testcase | 38 from testrunner.objects import testcase |
| 38 | 39 |
| 40 SIMDJS_ARCHIVE_REVISION = "07e2713e0c9ea19feb0732d5bd84770c87310d79" | |
| 41 SIMDJS_ARCHIVE_MD5 = "cf6bddf99f18800b68e782054268ee3c" | |
| 42 SIMDJS_URL = ( | |
| 43 "https://github.com/johnmccutchan/ecmascript_simd/archive/%s.tar.gz") | |
| 39 | 44 |
| 40 TEST_262_ARCHIVE_REVISION = "fbba29f" # This is the r365 revision. | 45 SIMDJS_SUITE_PATH = ["data", "src"] |
| 41 TEST_262_ARCHIVE_MD5 = "e1ff0db438cc12de8fb6da80621b4ef6" | |
| 42 TEST_262_URL = "https://github.com/tc39/test262/tarball/%s" | |
| 43 TEST_262_HARNESS = ["sta.js", "testBuiltInObject.js", "testIntl.js"] | |
| 44 | 46 |
| 45 | 47 |
| 46 class Test262TestSuite(testsuite.TestSuite): | 48 class SimdJsTestSuite(testsuite.TestSuite): |
| 47 | 49 |
| 48 def __init__(self, name, root): | 50 def __init__(self, name, root): |
| 49 super(Test262TestSuite, self).__init__(name, root) | 51 super(SimdJsTestSuite, self).__init__(name, root) |
| 50 self.testroot = os.path.join(root, "data", "test", "suite") | 52 self.testroot = os.path.join(self.root, *SIMDJS_SUITE_PATH) |
| 51 self.harness = [os.path.join(self.root, "data", "test", "harness", f) | 53 self.ParseTestRecord = None |
| 52 for f in TEST_262_HARNESS] | |
| 53 self.harness += [os.path.join(self.root, "harness-adapt.js")] | |
| 54 | |
| 55 def CommonTestName(self, testcase): | |
| 56 return testcase.path.split(os.path.sep)[-1] | |
| 57 | 54 |
| 58 def ListTests(self, context): | 55 def ListTests(self, context): |
| 59 tests = [] | 56 tests = [ |
|
Michael Achenbach
2015/05/19 07:17:48
This wraps another runner? Is there a way to get t
bradn
2015/05/19 09:37:53
Ah, good point.
I've changed it round to expose th
| |
| 60 for dirname, dirs, files in os.walk(self.testroot): | 57 testcase.TestCase(self, 'shell_test_runner'), |
| 61 for dotted in [x for x in dirs if x.startswith(".")]: | 58 testcase.TestCase(self, 'benchmarks/run'), |
| 62 dirs.remove(dotted) | 59 ] |
| 63 if context.noi18n and "intl402" in dirs: | |
| 64 dirs.remove("intl402") | |
| 65 dirs.sort() | |
| 66 files.sort() | |
| 67 for filename in files: | |
| 68 if filename.endswith(".js"): | |
| 69 testname = os.path.join(dirname[len(self.testroot) + 1:], | |
| 70 filename[:-3]) | |
| 71 case = testcase.TestCase(self, testname) | |
| 72 tests.append(case) | |
| 73 return tests | 60 return tests |
| 74 | 61 |
| 75 def GetFlagsForTestCase(self, testcase, context): | 62 def GetFlagsForTestCase(self, testcase, context): |
| 76 return (testcase.flags + context.mode_flags + self.harness + | 63 return (testcase.flags + context.mode_flags + |
| 64 [os.path.join(self.root, "harness-adapt.js")] + | |
| 65 ["--harmony"] + | |
| 77 [os.path.join(self.testroot, testcase.path + ".js")]) | 66 [os.path.join(self.testroot, testcase.path + ".js")]) |
| 78 | 67 |
| 79 def GetSourceForTest(self, testcase): | 68 def GetSourceForTest(self, testcase): |
| 80 filename = os.path.join(self.testroot, testcase.path + ".js") | 69 filename = os.path.join(self.testroot, testcase.path + ".js") |
| 81 with open(filename) as f: | 70 with open(filename) as f: |
| 82 return f.read() | 71 return f.read() |
| 83 | 72 |
| 84 def IsNegativeTest(self, testcase): | 73 def IsNegativeTest(self, testcase): |
| 85 return "@negative" in self.GetSourceForTest(testcase) | 74 return False |
| 86 | 75 |
| 87 def IsFailureOutput(self, output, testpath): | 76 def IsFailureOutput(self, output, testpath): |
| 88 if output.exit_code != 0: | 77 if output.exit_code != 0: |
| 89 return True | 78 return True |
| 90 return "FAILED!" in output.stdout | 79 return "FAILED!" in output.stdout |
| 91 | 80 |
| 92 def DownloadData(self): | 81 def DownloadData(self): |
| 93 revision = TEST_262_ARCHIVE_REVISION | 82 revision = SIMDJS_ARCHIVE_REVISION |
| 94 archive_url = TEST_262_URL % revision | 83 archive_url = SIMDJS_URL % revision |
| 95 archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision) | 84 archive_name = os.path.join( |
| 85 self.root, "ecmascript_simd-%s.tar.gz" % revision) | |
| 96 directory_name = os.path.join(self.root, "data") | 86 directory_name = os.path.join(self.root, "data") |
| 97 directory_old_name = os.path.join(self.root, "data.old") | 87 directory_old_name = os.path.join(self.root, "data.old") |
| 98 if not os.path.exists(archive_name): | 88 if not os.path.exists(archive_name): |
| 99 print "Downloading test data from %s ..." % archive_url | 89 print "Downloading test data from %s ..." % archive_url |
| 100 utils.URLRetrieve(archive_url, archive_name) | 90 utils.URLRetrieve(archive_url, archive_name) |
| 101 if os.path.exists(directory_name): | 91 if os.path.exists(directory_name): |
| 102 if os.path.exists(directory_old_name): | 92 if os.path.exists(directory_old_name): |
| 103 shutil.rmtree(directory_old_name) | 93 shutil.rmtree(directory_old_name) |
| 104 os.rename(directory_name, directory_old_name) | 94 os.rename(directory_name, directory_old_name) |
| 105 if not os.path.exists(directory_name): | 95 if not os.path.exists(directory_name): |
| 106 print "Extracting test262-%s.tar.gz ..." % revision | 96 print "Extracting ecmascript_simd-%s.tar.gz ..." % revision |
| 107 md5 = hashlib.md5() | 97 md5 = hashlib.md5() |
| 108 with open(archive_name, "rb") as f: | 98 with open(archive_name, "rb") as f: |
| 109 for chunk in iter(lambda: f.read(8192), ""): | 99 for chunk in iter(lambda: f.read(8192), ""): |
| 110 md5.update(chunk) | 100 md5.update(chunk) |
| 111 if md5.hexdigest() != TEST_262_ARCHIVE_MD5: | 101 print "MD5 hash is %s" % md5.hexdigest() |
| 102 if md5.hexdigest() != SIMDJS_ARCHIVE_MD5: | |
| 112 os.remove(archive_name) | 103 os.remove(archive_name) |
| 113 raise Exception("Hash mismatch of test data file") | 104 print "MD5 expected %s" % SIMDJS_ARCHIVE_MD5 |
| 105 raise Exception("MD5 hash mismatch of test data file") | |
| 114 archive = tarfile.open(archive_name, "r:gz") | 106 archive = tarfile.open(archive_name, "r:gz") |
| 115 if sys.platform in ("win32", "cygwin"): | 107 if sys.platform in ("win32", "cygwin"): |
| 116 # Magic incantation to allow longer path names on Windows. | 108 # Magic incantation to allow longer path names on Windows. |
| 117 archive.extractall(u"\\\\?\\%s" % self.root) | 109 archive.extractall(u"\\\\?\\%s" % self.root) |
| 118 else: | 110 else: |
| 119 archive.extractall(self.root) | 111 archive.extractall(self.root) |
| 120 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), | 112 os.rename(os.path.join(self.root, "ecmascript_simd-%s" % revision), |
| 121 directory_name) | 113 directory_name) |
| 122 | 114 |
| 123 | 115 |
| 124 def GetSuite(name, root): | 116 def GetSuite(name, root): |
| 125 return Test262TestSuite(name, root) | 117 return SimdJsTestSuite(name, root) |
| OLD | NEW |