Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2012 the V8 project authors. All rights reserved. |
| 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 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 if output.exit_code != 0: | 88 if output.exit_code != 0: |
| 89 return True | 89 return True |
| 90 return "FAILED!" in output.stdout | 90 return "FAILED!" in output.stdout |
| 91 | 91 |
| 92 def DownloadData(self): | 92 def DownloadData(self): |
| 93 revision = TEST_262_ARCHIVE_REVISION | 93 revision = TEST_262_ARCHIVE_REVISION |
| 94 archive_url = TEST_262_URL % revision | 94 archive_url = TEST_262_URL % revision |
| 95 archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision) | 95 archive_name = os.path.join(self.root, "tc39-test262-%s.tar.gz" % revision) |
| 96 directory_name = os.path.join(self.root, "data") | 96 directory_name = os.path.join(self.root, "data") |
| 97 directory_old_name = os.path.join(self.root, "data.old") | 97 directory_old_name = os.path.join(self.root, "data.old") |
| 98 | |
| 99 # Clobber if the test is in an outdated state, i.e. if there are any other | |
|
Michael Achenbach
2015/07/06 12:07:34
Copied from test262-es6
| |
| 100 # archive files present. | |
| 101 archive_files = [f for f in os.listdir(self.root) | |
| 102 if f.startswith("tc39-test262-")] | |
| 103 if (len(archive_files) > 1 or | |
| 104 os.path.basename(archive_name) not in archive_files): | |
| 105 print "Clobber outdated test archives ..." | |
| 106 for f in archive_files: | |
| 107 os.remove(os.path.join(self.root, f)) | |
| 108 | |
| 98 if not os.path.exists(archive_name): | 109 if not os.path.exists(archive_name): |
| 99 print "Downloading test data from %s ..." % archive_url | 110 print "Downloading test data from %s ..." % archive_url |
| 100 utils.URLRetrieve(archive_url, archive_name) | 111 utils.URLRetrieve(archive_url, archive_name) |
| 101 if os.path.exists(directory_name): | 112 if os.path.exists(directory_name): |
| 102 if os.path.exists(directory_old_name): | 113 if os.path.exists(directory_old_name): |
| 103 shutil.rmtree(directory_old_name) | 114 shutil.rmtree(directory_old_name) |
| 104 os.rename(directory_name, directory_old_name) | 115 os.rename(directory_name, directory_old_name) |
| 105 if not os.path.exists(directory_name): | 116 if not os.path.exists(directory_name): |
| 106 print "Extracting test262-%s.tar.gz ..." % revision | 117 print "Extracting test262-%s.tar.gz ..." % revision |
| 107 md5 = hashlib.md5() | 118 md5 = hashlib.md5() |
| 108 with open(archive_name, "rb") as f: | 119 with open(archive_name, "rb") as f: |
| 109 for chunk in iter(lambda: f.read(8192), ""): | 120 for chunk in iter(lambda: f.read(8192), ""): |
| 110 md5.update(chunk) | 121 md5.update(chunk) |
| 122 print "MD5 hash is %s" % md5.hexdigest() | |
| 111 if md5.hexdigest() != TEST_262_ARCHIVE_MD5: | 123 if md5.hexdigest() != TEST_262_ARCHIVE_MD5: |
| 112 os.remove(archive_name) | 124 os.remove(archive_name) |
| 125 print "MD5 expected %s" % TEST_262_ARCHIVE_MD5 | |
| 113 raise Exception("Hash mismatch of test data file") | 126 raise Exception("Hash mismatch of test data file") |
| 114 archive = tarfile.open(archive_name, "r:gz") | 127 archive = tarfile.open(archive_name, "r:gz") |
| 115 if sys.platform in ("win32", "cygwin"): | 128 if sys.platform in ("win32", "cygwin"): |
| 116 # Magic incantation to allow longer path names on Windows. | 129 # Magic incantation to allow longer path names on Windows. |
| 117 archive.extractall(u"\\\\?\\%s" % self.root) | 130 archive.extractall(u"\\\\?\\%s" % self.root) |
| 118 else: | 131 else: |
| 119 archive.extractall(self.root) | 132 archive.extractall(self.root) |
| 120 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), | 133 os.rename(os.path.join(self.root, "tc39-test262-%s" % revision), |
| 121 directory_name) | 134 directory_name) |
| 122 | 135 |
| 123 | 136 |
| 124 def GetSuite(name, root): | 137 def GetSuite(name, root): |
| 125 return Test262TestSuite(name, root) | 138 return Test262TestSuite(name, root) |
| OLD | NEW |