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

Delta Between Two Patch Sets: tests/test_packagerWebExt.py

Issue 29600577: Issue 5997 - Avoid including qunit files in release builds (Closed)
Left Patch Set: Avoid bundling tests if testScripts option is missing Created Nov. 7, 2017, 4:04 p.m.
Right Patch Set: Add assertions for qunit bundle Created Nov. 9, 2017, 3:32 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « templates/testIndex.html.tmpl ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
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')
242 qunit_dir.join('common.js').write(files['qunit/common.js']) 242 qunit_dir.join('common.js').write(files['qunit/common.js'])
243 qunit_tests_dir = qunit_dir.mkdir('tests') 243 qunit_tests_dir = qunit_dir.mkdir('tests')
244 qunit_tests_dir.join('some_test.js').write( 244 qunit_tests_dir.join('some_test.js').write(
245 files['qunit/tests/some_test.js'] 245 files['qunit/tests/some_test.js']
246 ) 246 )
tlucas 2017/11/08 12:08:51 You are adding these scripts but do not use it in
kzar 2017/11/09 15:33:16 Well they are used since the bundle is created, bu
247 return files 247 return files
248 248
249 249
250 def comparable_xml(xml): 250 def comparable_xml(xml):
251 """Create a nonambiguous representation of a given XML tree. 251 """Create a nonambiguous representation of a given XML tree.
252 252
253 Note that this function is not safe against ambiguous tags 253 Note that this function is not safe against ambiguous tags
254 containing differently distributed children, e.g.: 254 containing differently distributed children, e.g.:
255 255
256 '<a><b><c/></b><b><d/></b></a>' 256 '<a><b><c/></b><b><d/></b></a>'
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 assert 'var bar;' in libfoo 309 assert 'var bar;' in libfoo
310 assert 'webpack:///./ext/a.js' in libfoomap 310 assert 'webpack:///./ext/a.js' in libfoomap
311 311
312 assert 'var this_is_c;' in libfoo 312 assert 'var this_is_c;' in libfoo
313 assert 'webpack:///./ext/c.js' in libfoomap 313 assert 'webpack:///./ext/c.js' in libfoomap
314 314
315 assert ('var foo;' in libfoo) != excluded 315 assert ('var foo;' in libfoo) != excluded
316 assert ('webpack:///./lib/b.js' in libfoomap) != excluded 316 assert ('webpack:///./lib/b.js' in libfoomap) != excluded
317 317
318 318
319 def assert_devenv_scripts(package, prefix, devenv): 319 def assert_devenv_scripts(package, prefix, devenv):
tlucas 2017/11/08 12:08:51 I guess here would be the correct place to assert
kzar 2017/11/09 15:33:16 Done.
320 manifest = json.loads(package.read(os.path.join(prefix, 'manifest.json'))) 320 manifest = json.loads(package.read(os.path.join(prefix, 'manifest.json')))
321 filenames = package.namelist() 321 filenames = package.namelist()
322 scripts = [ 322 scripts = [
323 'ext/common.js', 323 'ext/common.js',
324 'ext/background.js', 324 'ext/background.js',
325 ] 325 ]
326 326
327 assert (os.path.join(prefix, 'qunit/index.html') in filenames) == devenv 327 assert (os.path.join(prefix, 'qunit/index.html') in filenames) == devenv
328 assert (os.path.join(prefix, 'devenvPoller__.js') in filenames) == devenv 328 assert (os.path.join(prefix, 'devenvPoller__.js') in filenames) == devenv
329 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
330 332
331 if devenv: 333 if devenv:
332 quint_index = package.read(os.path.join(prefix, 'qunit/index.html')) 334 quint_index = package.read(os.path.join(prefix, 'qunit/index.html'))
333 assert '../ext/common.js' in quint_index 335 assert '../ext/common.js' in quint_index
334 assert '../ext/background.js' in quint_index 336 assert '../ext/background.js' in quint_index
335 337
336 assert set(manifest['background']['scripts']) == set( 338 assert set(manifest['background']['scripts']) == set(
337 scripts + ['devenvPoller__.js'] 339 scripts + ['devenvPoller__.js']
338 ) 340 )
339 else: 341 else:
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 expected = os.path.join( 485 expected = os.path.join(
484 os.path.dirname(__file__), 486 os.path.dirname(__file__),
485 'expecteddata', 487 'expecteddata',
486 filename.format(name, ext), 488 filename.format(name, ext),
487 ) 489 )
488 490
489 assert_manifest_content( 491 assert_manifest_content(
490 package.read(os.path.join(folder, '{}.{}'.format(name, ext))), 492 package.read(os.path.join(folder, '{}.{}'.format(name, ext))),
491 expected, 493 expected,
492 ) 494 )
LEFTRIGHT

Powered by Google App Engine
This is Rietveld