Skip to content

Commit 6cf4672

Browse files
authored
Cleanup test_emrun. NFC (#22256)
1 parent cc5083e commit 6cf4672

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

test/test_browser.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5429,28 +5429,29 @@ def test_no_browser(self):
54295429
proc.terminate()
54305430
proc.wait()
54315431

5432+
def test_program_arg_separator(self):
5433+
# Verify that trying to pass argument to the page without the `--` separator will
5434+
# generate an actionable error message
5435+
err = self.expect_fail([EMRUN, '--foo'])
5436+
self.assertContained('error: unrecognized arguments: --foo', err)
5437+
self.assertContained('remember to add `--` between arguments', err)
5438+
54325439
def test_emrun(self):
5433-
self.run_process([EMCC, test_file('test_emrun.c'), '--emrun', '-o', 'hello_world.html'])
5440+
self.emcc(test_file('test_emrun.c'), ['--emrun', '-o', 'test_emrun.html'])
54345441
if not has_browser():
54355442
self.skipTest('need a browser')
54365443

54375444
# We cannot run emrun from the temp directory the suite will clean up afterwards, since the
54385445
# browser that is launched will have that directory as startup directory, and the browser will
54395446
# not close as part of the test, pinning down the cwd on Windows and it wouldn't be possible to
54405447
# delete it. Therefore switch away from that directory before launching.
5441-
54425448
os.chdir(path_from_root())
5449+
54435450
args_base = [EMRUN, '--timeout', '30', '--safe_firefox_profile',
54445451
'--kill-exit', '--port', '6939', '--verbose',
54455452
'--log-stdout', self.in_dir('stdout.txt'),
54465453
'--log-stderr', self.in_dir('stderr.txt')]
54475454

5448-
# Verify that trying to pass argument to the page without the `--` separator will
5449-
# generate an actionable error message
5450-
err = self.expect_fail(args_base + ['--foo'])
5451-
self.assertContained('error: unrecognized arguments: --foo', err)
5452-
self.assertContained('remember to add `--` between arguments', err)
5453-
54545455
if EMTEST_BROWSER is not None:
54555456
# If EMTEST_BROWSER carried command line arguments to pass to the browser,
54565457
# (e.g. "firefox -profile /path/to/foo") those can't be passed via emrun,
@@ -5470,13 +5471,13 @@ def test_emrun(self):
54705471
args_base += ['--browser_args', ' ' + ' '.join(browser_args)]
54715472

54725473
for args in [
5473-
args_base,
5474-
args_base + ['--port', '0'],
5475-
args_base + ['--private_browsing', '--port', '6941'],
5476-
args_base + ['--dump_out_directory', 'other dir/multiple', '--port', '6942'],
5477-
args_base + ['--dump_out_directory=foo_bar', '--port', '6942'],
5474+
[],
5475+
['--port', '0'],
5476+
['--private_browsing', '--port', '6941'],
5477+
['--dump_out_directory', 'other dir/multiple', '--port', '6942'],
5478+
['--dump_out_directory=foo_bar', '--port', '6942'],
54785479
]:
5479-
args += [self.in_dir('hello_world.html'), '--', '1', '2', '--3', 'escaped space', 'with_underscore']
5480+
args = args_base + args + [self.in_dir('test_emrun.html'), '--', '1', '2', '--3', 'escaped space', 'with_underscore']
54805481
print(shared.shlex_join(args))
54815482
proc = self.run_process(args, check=False)
54825483
self.assertEqual(proc.returncode, 100)

test/test_emrun.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* found in the LICENSE file.
66
*/
77

8+
#include <assert.h>
89
#include <stdio.h>
910
#include <stdlib.h>
1011
#include <emscripten.h>
@@ -14,15 +15,13 @@ int main(int argc, char **argv) {
1415
for (int i = 0; i < argc; ++i) {
1516
printf("argv[%d]: %s\n", i, argv[i]);
1617
}
18+
assert(argc > 1);
1719

1820
// Dump a file to local filesystem with emrun.
1921
EM_ASM(emrun_file_dump("test.dat", HEAPU8.subarray(0, 128)););
2022
EM_ASM(emrun_file_dump("heap.dat", HEAPU8));
2123
EM_ASM(emrun_file_dump("nested/with space.dat", HEAPU8.subarray(128, 256)););
2224

23-
if (argc <= 1) {
24-
exit(1);
25-
}
2625
printf("hello, world!\n");
2726
fprintf(stderr, "hello, error stream!\n");
2827

0 commit comments

Comments
 (0)