OLD | NEW |
1 # This Source Code Form is subject to the terms of the Mozilla Public | 1 # This Source Code Form is subject to the terms of the Mozilla Public |
2 # License, v. 2.0. If a copy of the MPL was not distributed with this | 2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
4 | 4 |
5 import difflib | 5 import difflib |
6 import json | 6 import json |
7 import os | 7 import os |
8 import re | 8 import re |
9 import shutil | 9 import shutil |
10 import zipfile | 10 import zipfile |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 """Test-privatekey for signing chrome release-package.""" | 224 """Test-privatekey for signing chrome release-package.""" |
225 return os.path.join(os.path.dirname(__file__), 'chrome_rsa.pem') | 225 return os.path.join(os.path.dirname(__file__), 'chrome_rsa.pem') |
226 | 226 |
227 | 227 |
228 @pytest.fixture | 228 @pytest.fixture |
229 def lib_files(tmpdir): | 229 def lib_files(tmpdir): |
230 files = packager.Files(['lib'], set()) | 230 files = packager.Files(['lib'], set()) |
231 files['ext/a.js'] = 'require("./c.js");\nvar bar;' | 231 files['ext/a.js'] = 'require("./c.js");\nvar bar;' |
232 files['lib/b.js'] = 'var foo;' | 232 files['lib/b.js'] = 'var foo;' |
233 files['ext/c.js'] = 'var this_is_c;' | 233 files['ext/c.js'] = 'var this_is_c;' |
| 234 files['qunit/common.js'] = 'var qunit = {};' |
| 235 files['qunit/tests/some_test.js'] = 'var passed = true;' |
234 | 236 |
235 tmpdir.mkdir('lib').join('b.js').write(files['lib/b.js']) | 237 tmpdir.mkdir('lib').join('b.js').write(files['lib/b.js']) |
236 ext_dir = tmpdir.mkdir('ext') | 238 ext_dir = tmpdir.mkdir('ext') |
237 ext_dir.join('a.js').write(files['ext/a.js']) | 239 ext_dir.join('a.js').write(files['ext/a.js']) |
238 ext_dir.join('c.js').write(files['ext/c.js']) | 240 ext_dir.join('c.js').write(files['ext/c.js']) |
239 | 241 qunit_dir = tmpdir.mkdir('qunit') |
| 242 qunit_dir.join('common.js').write(files['qunit/common.js']) |
| 243 qunit_tests_dir = qunit_dir.mkdir('tests') |
| 244 qunit_tests_dir.join('some_test.js').write( |
| 245 files['qunit/tests/some_test.js'] |
| 246 ) |
240 return files | 247 return files |
241 | 248 |
242 | 249 |
243 def comparable_xml(xml): | 250 def comparable_xml(xml): |
244 """Create a nonambiguous representation of a given XML tree. | 251 """Create a nonambiguous representation of a given XML tree. |
245 | 252 |
246 Note that this function is not safe against ambiguous tags | 253 Note that this function is not safe against ambiguous tags |
247 containing differently distributed children, e.g.: | 254 containing differently distributed children, e.g.: |
248 | 255 |
249 '<a><b><c/></b><b><d/></b></a>' | 256 '<a><b><c/></b><b><d/></b></a>' |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 manifest = json.loads(package.read(os.path.join(prefix, 'manifest.json'))) | 320 manifest = json.loads(package.read(os.path.join(prefix, 'manifest.json'))) |
314 filenames = package.namelist() | 321 filenames = package.namelist() |
315 scripts = [ | 322 scripts = [ |
316 'ext/common.js', | 323 'ext/common.js', |
317 'ext/background.js', | 324 'ext/background.js', |
318 ] | 325 ] |
319 | 326 |
320 assert (os.path.join(prefix, 'qunit/index.html') in filenames) == devenv | 327 assert (os.path.join(prefix, 'qunit/index.html') in filenames) == devenv |
321 assert (os.path.join(prefix, 'devenvPoller__.js') in filenames) == devenv | 328 assert (os.path.join(prefix, 'devenvPoller__.js') in filenames) == devenv |
322 assert (os.path.join(prefix, 'devenvVersion__') in filenames) == devenv | 329 assert (os.path.join(prefix, 'devenvVersion__') in filenames) == devenv |
| 330 assert (os.path.join(prefix, 'qunit/tests.js') in filenames) == devenv |
| 331 assert (os.path.join(prefix, 'qunit/tests.js.map') in filenames) == devenv |
323 | 332 |
324 if devenv: | 333 if devenv: |
325 quint_index = package.read(os.path.join(prefix, 'qunit/index.html')) | 334 quint_index = package.read(os.path.join(prefix, 'qunit/index.html')) |
326 assert '../ext/common.js' in quint_index | 335 assert '../ext/common.js' in quint_index |
327 assert '../ext/background.js' in quint_index | 336 assert '../ext/background.js' in quint_index |
328 | 337 |
329 assert set(manifest['background']['scripts']) == set( | 338 assert set(manifest['background']['scripts']) == set( |
330 scripts + ['devenvPoller__.js'] | 339 scripts + ['devenvPoller__.js'] |
331 ) | 340 ) |
332 else: | 341 else: |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 expected = os.path.join( | 485 expected = os.path.join( |
477 os.path.dirname(__file__), | 486 os.path.dirname(__file__), |
478 'expecteddata', | 487 'expecteddata', |
479 filename.format(name, ext), | 488 filename.format(name, ext), |
480 ) | 489 ) |
481 | 490 |
482 assert_manifest_content( | 491 assert_manifest_content( |
483 package.read(os.path.join(folder, '{}.{}'.format(name, ext))), | 492 package.read(os.path.join(folder, '{}.{}'.format(name, ext))), |
484 expected, | 493 expected, |
485 ) | 494 ) |
OLD | NEW |