Skip to content

Commit 7a5d1d8

Browse files
authored
Add --quiet option to file_packager (#21307)
This suppressed the `Remember to build the main file with ..` message that is otherwise printed to stderr. This also allows the tests to assert that no stderr is produced in successful cases.
1 parent 8ee4350 commit 7a5d1d8

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

test/test_other.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,18 +3271,18 @@ def check(text):
32713271
self.fail('output contains more then one empty line in row')
32723272

32733273
# relative path must be within/below the current dir
3274-
stderr = self.expect_fail([FILE_PACKAGER, 'test.data', '--preload', '../data1.txt'])
3274+
stderr = self.expect_fail([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../data1.txt'])
32753275
self.assertContained('which is not contained within the current directory', stderr)
32763276

32773277
# relative path that ends up under us is cool
3278-
proc = self.run_process([FILE_PACKAGER, 'test.data', '--preload', '../subdir/data2.txt'], stderr=PIPE, stdout=PIPE)
3279-
self.assertNotContained('which is not contained within the current directory', proc.stderr)
3278+
proc = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', '../subdir/data2.txt'], stderr=PIPE, stdout=PIPE)
3279+
self.assertEqual(proc.stderr, '')
32803280
check(proc.stdout)
32813281

32823282
# direct path leads to the same code being generated - relative path does not make us do anything different
3283-
proc2 = self.run_process([FILE_PACKAGER, 'test.data', '--preload', 'data2.txt'], stderr=PIPE, stdout=PIPE)
3283+
proc2 = self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', 'data2.txt'], stderr=PIPE, stdout=PIPE)
32843284
check(proc2.stdout)
3285-
self.assertNotContained('below the current directory', proc2.stderr)
3285+
self.assertEqual(proc2.stderr, '')
32863286

32873287
def clean(txt):
32883288
lines = txt.splitlines()
@@ -3294,15 +3294,15 @@ def clean(txt):
32943294
# verify '--separate-metadata' option produces separate metadata file
32953295
os.chdir('..')
32963296

3297-
self.run_process([FILE_PACKAGER, 'test.data', '--preload', 'data1.txt', '--preload', 'subdir/data2.txt', '--js-output=immutable.js', '--separate-metadata', '--use-preload-cache'])
3297+
self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', 'data1.txt', '--preload', 'subdir/data2.txt', '--js-output=immutable.js', '--separate-metadata', '--use-preload-cache'])
32983298
self.assertExists('immutable.js.metadata')
32993299
# verify js output JS file is not touched when the metadata is separated
33003300
orig_timestamp = os.path.getmtime('immutable.js')
33013301
orig_content = read_file('immutable.js')
33023302
# ensure some time passes before running the packager again so that if it does touch the
33033303
# js file it will end up with the different timestamp.
33043304
time.sleep(1.0)
3305-
self.run_process([FILE_PACKAGER, 'test.data', '--preload', 'data1.txt', '--preload', 'subdir/data2.txt', '--js-output=immutable.js', '--separate-metadata', '--use-preload-cache'])
3305+
self.run_process([FILE_PACKAGER, 'test.data', '--quiet', '--preload', 'data1.txt', '--preload', 'subdir/data2.txt', '--js-output=immutable.js', '--separate-metadata', '--use-preload-cache'])
33063306
# assert both file content and timestamp are the same as reference copy
33073307
self.assertTextDataIdentical(orig_content, read_file('immutable.js'))
33083308
self.assertEqual(orig_timestamp, os.path.getmtime('immutable.js'))

tools/file_packager.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
5858
--no-node Whether to support Node.js. By default we do, which emits some extra code.
5959
60+
--quiet Suppress reminder about using `FORCE_FILESYSTEM`
61+
6062
Notes:
6163
6264
* The file packager generates unix-style file paths. So if you are on windows and a file is accessed at
@@ -110,6 +112,7 @@ def __init__(self):
110112
self.obj_output = None
111113
self.depfile = None
112114
self.from_emcc = False
115+
self.quiet = False
113116
self.force = True
114117
# If set to True, IndexedDB (IDBFS in library_idbfs.js) is used to locally
115118
# cache VFS XHR so that subsequent page loads can read the data from the
@@ -411,9 +414,11 @@ def main():
411414
if '=' in arg:
412415
options.export_name = arg.split('=', 1)[1]
413416
leading = ''
414-
elif arg.startswith('--from-emcc'):
417+
elif arg == '--from-emcc':
415418
options.from_emcc = True
416419
leading = ''
420+
elif arg == '--quiet':
421+
options.quiet = True
417422
elif arg.startswith('--plugin'):
418423
plugin = utils.read_file(arg.split('=', 1)[1])
419424
eval(plugin) # should append itself to plugins
@@ -454,7 +459,7 @@ def main():
454459
'and a specified --js-output')
455460
return 1
456461

457-
if not options.from_emcc:
462+
if not options.from_emcc and not options.quiet:
458463
err('Remember to build the main file with `-sFORCE_FILESYSTEM` '
459464
'so that it includes support for loading this file package')
460465

0 commit comments

Comments
 (0)