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

Side by Side Diff: tests/test_packagerWebExt.py

Issue 29825555: Issue 6291 - add ManifoldJS packaging for Edge (Closed) Base URL: https://hg.adblockplus.org/buildtools/file/9a56d76cd951
Patch Set: Created July 11, 2018, 12:05 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 assert '../ext/common.js' in quint_index 338 assert '../ext/common.js' in quint_index
339 assert '../ext/background.js' in quint_index 339 assert '../ext/background.js' in quint_index
340 340
341 assert set(manifest['background']['scripts']) == set( 341 assert set(manifest['background']['scripts']) == set(
342 scripts + ['devenvPoller__.js'], 342 scripts + ['devenvPoller__.js'],
343 ) 343 )
344 else: 344 else:
345 assert set(manifest['background']['scripts']) == set(scripts) 345 assert set(manifest['background']['scripts']) == set(scripts)
346 346
347 347
348 def assert_base_files(package, platform, prefix): 348 def assert_base_files(package, platform, prefix, devenv):
349 filenames = set(package.namelist()) 349 filenames = set(package.namelist())
350 350
351 if platform == 'edge': 351 if platform == 'edge':
352 assert 'AppxManifest.xml' in filenames 352 assert ('AppxManifest.xml' in filenames) is not devenv
353 assert 'AppxBlockMap.xml' in filenames 353 assert ('AppxBlockMap.xml' in filenames) is not devenv
354 assert '[Content_Types].xml' in filenames 354 assert ('[Content_Types].xml' in filenames) is not devenv
355 355
356 assert package.read('Assets/logo_44.png') == '44' 356 assert package.read('Assets/logo_44.png') == '44'
357 assert package.read('Extension/icons/abp-44.png') == '44' 357 assert package.read('Extension/icons/abp-44.png') == '44'
358 358
359 assert os.path.join(prefix, 'bar.json') in filenames 359 assert os.path.join(prefix, 'bar.json') in filenames
360 assert os.path.join(prefix, 'manifest.json') in filenames 360 assert os.path.join(prefix, 'manifest.json') in filenames
361 assert os.path.join(prefix, 'lib/foo.js') in filenames 361 assert os.path.join(prefix, 'lib/foo.js') in filenames
362 assert os.path.join(prefix, 'foo/logo_50.png') in filenames 362 assert os.path.join(prefix, 'foo/logo_50.png') in filenames
363 assert os.path.join(prefix, 'icons/logo_150.png') in filenames 363 assert os.path.join(prefix, 'icons/logo_150.png') in filenames
364 364
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 devenv = command == 'devenv' 422 devenv = command == 'devenv'
423 423
424 if platform == 'chrome' and release: 424 if platform == 'chrome' and release:
425 key = keyfile 425 key = keyfile
426 else: 426 else:
427 key = None 427 key = None
428 428
429 manifests = { 429 manifests = {
430 'gecko': [('', 'manifest', 'json')], 430 'gecko': [('', 'manifest', 'json')],
431 'chrome': [('', 'manifest', 'json')], 431 'chrome': [('', 'manifest', 'json')],
432 'edge': [('', 'AppxManifest', 'xml'), 432 'edge': [('Extension', 'manifest', 'json')],
433 ('Extension', 'manifest', 'json')],
434 } 433 }
435 434
435 if not devenv:
436 manifests['edge'].append(('', 'AppxManifest', 'xml'))
437
436 filenames = { 438 filenames = {
437 'gecko': 'adblockplusfirefox-1.2.3{}.xpi', 439 'gecko': 'adblockplusfirefox-1.2.3{}.xpi',
438 'chrome': 'adblockpluschrome-1.2.3{{}}.{}'.format( 440 'chrome': 'adblockpluschrome-1.2.3{{}}.{}'.format(
439 {True: 'crx', False: 'zip'}[release], 441 {True: 'crx', False: 'zip'}[release],
440 ), 442 ),
441 'edge': 'adblockplusedge-1.2.3{}.appx', 443 'edge': 'adblockplusedge-1.2.3{}.appx',
442 } 444 }
443 445
444 if platform == 'edge': 446 if platform == 'edge':
445 prefix = 'Extension' 447 prefix = 'Extension'
(...skipping 21 matching lines...) Expand all
467 out_file = filenames[platform].format(add_version) 469 out_file = filenames[platform].format(add_version)
468 470
469 out_file_path = os.path.abspath(os.path.join( 471 out_file_path = os.path.abspath(os.path.join(
470 os.path.dirname(__file__), os.pardir, out_file)) 472 os.path.dirname(__file__), os.pardir, out_file))
471 assert os.path.exists(out_file_path) 473 assert os.path.exists(out_file_path)
472 474
473 if release and platform == 'chrome': 475 if release and platform == 'chrome':
474 assert_chrome_signature(out_file_path, keyfile) 476 assert_chrome_signature(out_file_path, keyfile)
475 477
476 with content_class(out_file_path) as package: 478 with content_class(out_file_path) as package:
477 assert_base_files(package, platform, prefix) 479 assert_base_files(package, platform, prefix, devenv)
478 assert_all_locales_present(package, prefix) 480 assert_all_locales_present(package, prefix)
479 assert_webpack_bundle(package, prefix, not release and not devenv, 481 assert_webpack_bundle(package, prefix, not release and not devenv,
480 platform == 'gecko') 482 platform == 'gecko')
481 483
482 if platform == 'chrome': 484 if platform == 'chrome':
483 assert_locale_upfix(package) 485 assert_locale_upfix(package)
484 486
485 assert_devenv_scripts(package, prefix, devenv) 487 assert_devenv_scripts(package, prefix, devenv)
486 488
487 for folder, name, ext in manifests[platform]: 489 for folder, name, ext in manifests[platform]:
488 filename = '{{}}_{}_{}.{{}}'.format(platform, command) 490 filename = '{{}}_{}_{}.{{}}'.format(platform, command)
489 expected = os.path.join( 491 expected = os.path.join(
490 os.path.dirname(__file__), 492 os.path.dirname(__file__),
491 'expecteddata', 493 'expecteddata',
492 filename.format(name, ext), 494 filename.format(name, ext),
493 ) 495 )
494 496
495 assert_manifest_content( 497 assert_manifest_content(
496 package.read(os.path.join(folder, '{}.{}'.format(name, ext))), 498 package.read(os.path.join(folder, '{}.{}'.format(name, ext))),
497 expected, 499 expected,
498 ) 500 )
OLDNEW
« packagerEdge.py ('K') | « tests/test_packagerEdge.py ('k') | tox.ini » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld