Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: tests/test_packagerWebExt.py

Issue 29747571: Issue 6563 - Assure devbuild-number in info module (Closed) Base URL: https://hg.adblockplus.org/buildtools/file/a3db4a1a49e8
Patch Set: Created April 9, 2018, 9:57 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « packagerChrome.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 @pytest.fixture 222 @pytest.fixture
223 def keyfile(tmpdir): 223 def keyfile(tmpdir):
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");\nrequire("info");\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 = {};' 234 files['qunit/common.js'] = 'var qunit = {};'
235 files['qunit/tests/some_test.js'] = 'var passed = true;' 235 files['qunit/tests/some_test.js'] = 'var passed = true;'
236 236
237 tmpdir.mkdir('lib').join('b.js').write(files['lib/b.js']) 237 tmpdir.mkdir('lib').join('b.js').write(files['lib/b.js'])
238 ext_dir = tmpdir.mkdir('ext') 238 ext_dir = tmpdir.mkdir('ext')
239 ext_dir.join('a.js').write(files['ext/a.js']) 239 ext_dir.join('a.js').write(files['ext/a.js'])
240 ext_dir.join('c.js').write(files['ext/c.js']) 240 ext_dir.join('c.js').write(files['ext/c.js'])
241 qunit_dir = tmpdir.mkdir('qunit') 241 qunit_dir = tmpdir.mkdir('qunit')
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 generated = comparable_xml(manifest) 278 generated = comparable_xml(manifest)
279 expected = comparable_xml(fp.read()) 279 expected = comparable_xml(fp.read())
280 else: 280 else:
281 generated = comparable_json(manifest) 281 generated = comparable_json(manifest)
282 expected = comparable_json(fp.read()) 282 expected = comparable_json(fp.read())
283 283
284 diff = list(difflib.unified_diff(generated, expected, n=0)) 284 diff = list(difflib.unified_diff(generated, expected, n=0))
285 assert len(diff) == 0, '\n'.join(diff) 285 assert len(diff) == 0, '\n'.join(diff)
286 286
287 287
288 def assert_webpack_bundle(package, prefix, excluded=False): 288 def assert_webpack_bundle(package, prefix, is_devbuild, excluded=False):
289 libfoo = package.read(os.path.join(prefix, 'lib/foo.js')) 289 libfoo = package.read(os.path.join(prefix, 'lib/foo.js'))
290 libfoomap = package.read(os.path.join(prefix, 'lib/foo.js.map')) 290 libfoomap = package.read(os.path.join(prefix, 'lib/foo.js.map'))
291 291
292 assert 'var bar;' in libfoo 292 assert 'var bar;' in libfoo
293 if is_devbuild:
294 assert 'addonVersion = "1.2.3.1337";' in libfoo
295 else:
296 assert 'addonVersion = "1.2.3";' in libfoo
297
293 assert 'webpack:///./ext/a.js' in libfoomap 298 assert 'webpack:///./ext/a.js' in libfoomap
294 299
295 assert 'var this_is_c;' in libfoo 300 assert 'var this_is_c;' in libfoo
296 assert 'webpack:///./ext/c.js' in libfoomap 301 assert 'webpack:///./ext/c.js' in libfoomap
297 302
298 assert ('var foo;' in libfoo) != excluded 303 assert ('var foo;' in libfoo) != excluded
299 assert ('webpack:///./lib/b.js' in libfoomap) != excluded 304 assert ('webpack:///./lib/b.js' in libfoomap) != excluded
300 305
301 306
302 def assert_devenv_scripts(package, prefix, devenv): 307 def assert_devenv_scripts(package, prefix, devenv):
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 out_file_path = os.path.abspath(os.path.join( 454 out_file_path = os.path.abspath(os.path.join(
450 os.path.dirname(__file__), os.pardir, out_file)) 455 os.path.dirname(__file__), os.pardir, out_file))
451 assert os.path.exists(out_file_path) 456 assert os.path.exists(out_file_path)
452 457
453 if release and platform == 'chrome': 458 if release and platform == 'chrome':
454 assert_chrome_signature(out_file_path, keyfile) 459 assert_chrome_signature(out_file_path, keyfile)
455 460
456 with content_class(out_file_path) as package: 461 with content_class(out_file_path) as package:
457 assert_base_files(package, platform, prefix) 462 assert_base_files(package, platform, prefix)
458 assert_all_locales_present(package, prefix) 463 assert_all_locales_present(package, prefix)
459 assert_webpack_bundle(package, prefix, platform == 'gecko') 464 assert_webpack_bundle(package, prefix, not release and not devenv,
465 platform == 'gecko')
460 466
461 if platform == 'chrome': 467 if platform == 'chrome':
462 assert_locale_upfix(package) 468 assert_locale_upfix(package)
463 469
464 assert_devenv_scripts(package, prefix, devenv) 470 assert_devenv_scripts(package, prefix, devenv)
465 471
466 for folder, name, ext in manifests[platform]: 472 for folder, name, ext in manifests[platform]:
467 filename = '{{}}_{}_{}.{{}}'.format(platform, command) 473 filename = '{{}}_{}_{}.{{}}'.format(platform, command)
468 expected = os.path.join( 474 expected = os.path.join(
469 os.path.dirname(__file__), 475 os.path.dirname(__file__),
470 'expecteddata', 476 'expecteddata',
471 filename.format(name, ext), 477 filename.format(name, ext),
472 ) 478 )
473 479
474 assert_manifest_content( 480 assert_manifest_content(
475 package.read(os.path.join(folder, '{}.{}'.format(name, ext))), 481 package.read(os.path.join(folder, '{}.{}'.format(name, ext))),
476 expected, 482 expected,
477 ) 483 )
OLDNEW
« no previous file with comments | « packagerChrome.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld