OLD | NEW |
1 # Copyright 2014 the V8 project authors. All rights reserved. | 1 # Copyright 2014 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 13 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 urllib | |
35 | 34 |
36 from testrunner.local import testsuite | 35 from testrunner.local import testsuite |
| 36 from testrunner.local import utils |
37 from testrunner.objects import testcase | 37 from testrunner.objects import testcase |
38 | 38 |
39 | 39 |
40 SINON_TAG = '1.7.3' | 40 SINON_TAG = '1.7.3' |
41 SINON_NAME = 'sinon' | 41 SINON_NAME = 'sinon' |
42 SINON_FILENAME = 'sinon.js' | 42 SINON_FILENAME = 'sinon.js' |
43 SINON_URL = 'http://sinonjs.org/releases/sinon-' + SINON_TAG + '.js' | 43 SINON_URL = 'http://sinonjs.org/releases/sinon-' + SINON_TAG + '.js' |
44 SINON_HASH = 'b7ab4dd9a1a2cf0460784af3728ad15caf4bbea923f680c5abde5c8332f35984' | 44 SINON_HASH = 'b7ab4dd9a1a2cf0460784af3728ad15caf4bbea923f680c5abde5c8332f35984' |
45 | 45 |
46 TEST_TAG = '2.0.3' | 46 TEST_TAG = '2.0.3' |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 if output.exit_code != 0: | 95 if output.exit_code != 0: |
96 return True | 96 return True |
97 return not 'All tests have run.' in output.stdout or \ | 97 return not 'All tests have run.' in output.stdout or \ |
98 'FAIL:' in output.stdout | 98 'FAIL:' in output.stdout |
99 | 99 |
100 def DownloadTestData(self): | 100 def DownloadTestData(self): |
101 archive = os.path.join(self.root, TEST_ARCHIVE) | 101 archive = os.path.join(self.root, TEST_ARCHIVE) |
102 directory = os.path.join(self.root, TEST_NAME) | 102 directory = os.path.join(self.root, TEST_NAME) |
103 if not os.path.exists(archive): | 103 if not os.path.exists(archive): |
104 print('Downloading {0} from {1} ...'.format(TEST_NAME, TEST_URL)) | 104 print('Downloading {0} from {1} ...'.format(TEST_NAME, TEST_URL)) |
105 urllib.urlretrieve(TEST_URL, archive) | 105 utils.URLRetrieve(TEST_URL, archive) |
106 if os.path.exists(directory): | 106 if os.path.exists(directory): |
107 shutil.rmtree(directory) | 107 shutil.rmtree(directory) |
108 | 108 |
109 if not os.path.exists(directory): | 109 if not os.path.exists(directory): |
110 print('Extracting {0} ...'.format(TEST_ARCHIVE)) | 110 print('Extracting {0} ...'.format(TEST_ARCHIVE)) |
111 hash = hashlib.sha256() | 111 hash = hashlib.sha256() |
112 with open(archive, 'rb') as f: | 112 with open(archive, 'rb') as f: |
113 for chunk in iter(lambda: f.read(8192), ''): | 113 for chunk in iter(lambda: f.read(8192), ''): |
114 hash.update(chunk) | 114 hash.update(chunk) |
115 if hash.hexdigest() != TEST_ARCHIVE_HASH: | 115 if hash.hexdigest() != TEST_ARCHIVE_HASH: |
116 os.remove(archive) | 116 os.remove(archive) |
117 raise Exception('Hash mismatch of test data file') | 117 raise Exception('Hash mismatch of test data file') |
118 archive = tarfile.open(archive, 'r:gz') | 118 archive = tarfile.open(archive, 'r:gz') |
119 if sys.platform in ('win32', 'cygwin'): | 119 if sys.platform in ('win32', 'cygwin'): |
120 # Magic incantation to allow longer path names on Windows. | 120 # Magic incantation to allow longer path names on Windows. |
121 archive.extractall(u'\\\\?\\%s' % self.root) | 121 archive.extractall(u'\\\\?\\%s' % self.root) |
122 else: | 122 else: |
123 archive.extractall(self.root) | 123 archive.extractall(self.root) |
124 shutil.move(os.path.join(self.root, TEST_ARCHIVE_TOP), directory) | 124 shutil.move(os.path.join(self.root, TEST_ARCHIVE_TOP), directory) |
125 | 125 |
126 def DownloadSinon(self): | 126 def DownloadSinon(self): |
127 directory = os.path.join(self.root, SINON_NAME) | 127 directory = os.path.join(self.root, SINON_NAME) |
128 if not os.path.exists(directory): | 128 if not os.path.exists(directory): |
129 os.mkdir(directory) | 129 os.mkdir(directory) |
130 path = os.path.join(directory, SINON_FILENAME) | 130 path = os.path.join(directory, SINON_FILENAME) |
131 if not os.path.exists(path): | 131 if not os.path.exists(path): |
132 urllib.urlretrieve(SINON_URL, path) | 132 utils.URLRetrieve(SINON_URL, path) |
133 hash = hashlib.sha256() | 133 hash = hashlib.sha256() |
134 with open(path, 'rb') as f: | 134 with open(path, 'rb') as f: |
135 for chunk in iter(lambda: f.read(8192), ''): | 135 for chunk in iter(lambda: f.read(8192), ''): |
136 hash.update(chunk) | 136 hash.update(chunk) |
137 if hash.hexdigest() != SINON_HASH: | 137 if hash.hexdigest() != SINON_HASH: |
138 os.remove(path) | 138 os.remove(path) |
139 raise Exception('Hash mismatch of test data file') | 139 raise Exception('Hash mismatch of test data file') |
140 | 140 |
141 def DownloadData(self): | 141 def DownloadData(self): |
142 self.DownloadTestData() | 142 self.DownloadTestData() |
143 self.DownloadSinon() | 143 self.DownloadSinon() |
144 | 144 |
145 | 145 |
146 def GetSuite(name, root): | 146 def GetSuite(name, root): |
147 return PromiseAplusTestSuite(name, root) | 147 return PromiseAplusTestSuite(name, root) |
OLD | NEW |