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

Side by Side Diff: tests/test_packagerWebExt.py

Issue 29762564: Issue 6625 - Expose webpack's resolve.alias to the packagers (Closed)
Patch Set: Created April 26, 2018, 8:41 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
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
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");\nrequire("info");\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['lib/aliased.js'] = 'require("mogo");'
234 files['lib/mogo.js'] = 'var this_is_mogo;'
235 files['lib/edge.js'] = 'var this_is_edge;'
233 files['ext/c.js'] = 'var this_is_c;' 236 files['ext/c.js'] = 'var this_is_c;'
237 files['ext/alias_c.js'] = 'var this_is_aliased_c;'
234 files['qunit/common.js'] = 'var qunit = {};' 238 files['qunit/common.js'] = 'var qunit = {};'
235 files['qunit/tests/some_test.js'] = 'var passed = true;' 239 files['qunit/tests/some_test.js'] = 'var passed = true;'
236 240
237 tmpdir.mkdir('lib').join('b.js').write(files['lib/b.js']) 241 libdir = tmpdir.mkdir('lib')
242 libdir.join('b.js').write(files['lib/b.js'])
243 libdir.join('aliased.js').write(files['lib/aliased.js'])
244 libdir.join('mogo.js').write(files['lib/mogo.js'])
245 libdir.join('edge.js').write(files['lib/edge.js'])
238 ext_dir = tmpdir.mkdir('ext') 246 ext_dir = tmpdir.mkdir('ext')
239 ext_dir.join('a.js').write(files['ext/a.js']) 247 ext_dir.join('a.js').write(files['ext/a.js'])
240 ext_dir.join('c.js').write(files['ext/c.js']) 248 ext_dir.join('c.js').write(files['ext/c.js'])
241 qunit_dir = tmpdir.mkdir('qunit') 249 qunit_dir = tmpdir.mkdir('qunit')
242 qunit_dir.join('common.js').write(files['qunit/common.js']) 250 qunit_dir.join('common.js').write(files['qunit/common.js'])
243 qunit_tests_dir = qunit_dir.mkdir('tests') 251 qunit_tests_dir = qunit_dir.mkdir('tests')
244 qunit_tests_dir.join('some_test.js').write( 252 qunit_tests_dir.join('some_test.js').write(
245 files['qunit/tests/some_test.js'], 253 files['qunit/tests/some_test.js'],
246 ) 254 )
247 return files 255 return files
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 if is_devbuild: 301 if is_devbuild:
294 assert 'addonVersion = "1.2.3.1337";' in libfoo 302 assert 'addonVersion = "1.2.3.1337";' in libfoo
295 else: 303 else:
296 assert 'addonVersion = "1.2.3";' in libfoo 304 assert 'addonVersion = "1.2.3";' in libfoo
297 305
298 assert 'webpack:///./ext/a.js' in libfoomap 306 assert 'webpack:///./ext/a.js' in libfoomap
299 307
300 assert 'var this_is_c;' in libfoo 308 assert 'var this_is_c;' in libfoo
301 assert 'webpack:///./ext/c.js' in libfoomap 309 assert 'webpack:///./ext/c.js' in libfoomap
302 310
311 if prefix: # webpack 'resolve.alias' exposure
312 assert 'var this_is_edge;' in libfoo
313 assert 'webpack:///./lib/edge.js' in libfoomap
314 else:
315 assert 'var this_is_mogo;' in libfoo
316 assert 'webpack:///./lib/mogo.js' in libfoomap
317
303 assert ('var foo;' in libfoo) != excluded 318 assert ('var foo;' in libfoo) != excluded
304 assert ('webpack:///./lib/b.js' in libfoomap) != excluded 319 assert ('webpack:///./lib/b.js' in libfoomap) != excluded
305 320
306 321
307 def assert_devenv_scripts(package, prefix, devenv): 322 def assert_devenv_scripts(package, prefix, devenv):
308 manifest = json.loads(package.read(os.path.join(prefix, 'manifest.json'))) 323 manifest = json.loads(package.read(os.path.join(prefix, 'manifest.json')))
309 filenames = package.namelist() 324 filenames = package.namelist()
310 scripts = [ 325 scripts = [
311 'ext/common.js', 326 'ext/common.js',
312 'ext/background.js', 327 'ext/background.js',
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 expected = os.path.join( 489 expected = os.path.join(
475 os.path.dirname(__file__), 490 os.path.dirname(__file__),
476 'expecteddata', 491 'expecteddata',
477 filename.format(name, ext), 492 filename.format(name, ext),
478 ) 493 )
479 494
480 assert_manifest_content( 495 assert_manifest_content(
481 package.read(os.path.join(folder, '{}.{}'.format(name, ext))), 496 package.read(os.path.join(folder, '{}.{}'.format(name, ext))),
482 expected, 497 expected,
483 ) 498 )
OLDNEW
« packagerChrome.py ('K') | « tests/metadata.edge ('k') | webpack_runner.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld