Skip to content

Commit 664d3fe

Browse files
authored
[test] More use of do_runf helper. NFC (emscripten-core#25805)
1 parent 90d94be commit 664d3fe

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

test/test_other.py

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,9 +1424,7 @@ def test_multiply_defined_libsymbols(self):
14241424
self.emcc('a2.c', ['-r', '-L.', '-lA', '-o', 'a2.o'])
14251425
self.emcc('b2.c', ['-r', '-L.', '-lA', '-o', 'b2.o'])
14261426

1427-
self.emcc('main.c', ['-L.', '-lA', 'a2.o', 'b2.o'])
1428-
1429-
self.assertContained('result: 1', self.run_js('a.out.js'))
1427+
self.do_runf('main.c', 'result: 1', cflags=['-L.', '-lA', 'a2.o', 'b2.o'])
14301428

14311429
def test_multiply_defined_libsymbols_2(self):
14321430
create_file('a.c', "int x() { return 55; }")
@@ -1449,9 +1447,7 @@ def test_multiply_defined_libsymbols_2(self):
14491447
building.emar('cr', 'libLIB.a', ['a.o', 'b.o']) # libLIB.a with a and b
14501448

14511449
# a is in the lib AND in an .o, so should be ignored in the lib. We do still need b from the lib though
1452-
self.emcc('main.c', ['a.o', 'c.o', '-L.', '-lLIB'])
1453-
1454-
self.assertContained('result: 62', self.run_js('a.out.js'))
1450+
self.do_runf('main.c', 'result: 62', cflags=['a.o', 'c.o', '-L.', '-lLIB'])
14551451

14561452
def test_link_group(self):
14571453
create_file('lib.c', 'int x() { return 42; }')
@@ -1724,12 +1720,8 @@ def test_export_all_and_exported_functions(self):
17241720
''')
17251721

17261722
# libfunc2 should not be linked by default, even with EXPORT_ALL
1727-
self.emcc('lib.c', ['-sEXPORT_ALL', '--pre-js', 'pre.js', '-o', 'a.out.js'])
1728-
err = self.run_js('a.out.js', assert_returncode=NON_ZERO)
1729-
self.assertContained('_libfunc2 is not defined', err)
1730-
1731-
self.emcc('lib.c', ['-sEXPORTED_FUNCTIONS=_libfunc2', '-sEXPORT_ALL', '--pre-js', 'pre.js', '-o', 'a.out.js'])
1732-
self.assertContained('libfunc\n', self.run_js('a.out.js'))
1723+
self.do_runf('lib.c', '_libfunc2 is not defined', cflags=['-sEXPORT_ALL', '--pre-js', 'pre.js'], assert_returncode=NON_ZERO)
1724+
self.do_runf('lib.c', 'libfunc\n', cflags=['-sEXPORTED_FUNCTIONS=_libfunc2', '-sEXPORT_ALL', '--pre-js', 'pre.js'])
17331725

17341726
@all_engines
17351727
@also_with_wasmfs
@@ -1910,8 +1902,7 @@ def test_multiple_archives_duplicate_basenames(self):
19101902
}
19111903
''')
19121904

1913-
self.run_process([EMCC, 'main.c', '-L.', '-la', '-lb'])
1914-
self.assertContained('a\nb\n', self.run_js('a.out.js'))
1905+
self.do_runf('main.c', 'a\nb\n', cflags=['-L.', '-la', '-lb'])
19151906

19161907
def test_archive_duplicate_basenames(self):
19171908
ensure_dir('a')
@@ -1962,9 +1953,7 @@ def test_archive_duplicate_basenames(self):
19621953

19631954
# With fastcomp we don't support duplicate members so this should generate
19641955
# a warning. With the wasm backend (lld) this is fully supported.
1965-
cmd = [EMCC, 'main.c', '-L.', '-ldup']
1966-
self.run_process(cmd)
1967-
self.assertContained('a\nb...\n', self.run_js('a.out.js'))
1956+
self.do_runf('main.c', 'a\nb...\n', cflags=['-L.', '-ldup'])
19681957

19691958
def test_export_from_archive(self):
19701959
export_name = 'this_is_an_entry_point'
@@ -2019,10 +2008,7 @@ def test_include_file(self, args):
20192008
}
20202009
''')
20212010

2022-
self.run_process([EMCC, 'main.c'] + args)
2023-
# run in node.js to ensure we verify that file preloading works there
2024-
result = self.run_js('a.out.js')
2025-
self.assertContained('|hello from a file wi|', result)
2011+
self.do_runf('main.c', '|hello from a file wi|', cflags=args)
20262012

20272013
@parameterized({
20282014
'': ([],),
@@ -9232,8 +9218,7 @@ def test_noderawfs_access_abspath(self):
92329218
return access(argv[1], F_OK);
92339219
}
92349220
''')
9235-
self.run_process([EMCC, 'access.c', '-sNODERAWFS'])
9236-
self.run_js('a.out.js', args=[os.path.abspath('foo')])
9221+
self.do_runf('access.c', cflags=['-sNODERAWFS'], args=[os.path.abspath('foo')])
92379222

92389223
def test_noderawfs_readfile_prerun(self):
92399224
create_file('foo', 'bar')
@@ -14367,8 +14352,7 @@ def test_emmalloc_in_addition(self, args):
1436714352
# etc., and only provide the emmalloc_malloc etc. family of functions that
1436814353
# we can use.
1436914354
emmalloc = path_from_root('system', 'lib', 'emmalloc.c')
14370-
self.run_process([EMCC, test_file('other/test_emmalloc_in_addition.c'), emmalloc] + args)
14371-
self.assertContained('success', self.run_js('a.out.js'))
14355+
self.do_runf('other/test_emmalloc_in_addition.c', 'success', cflags=[emmalloc] + args)
1437214356

1437314357
def test_unused_destructor(self):
1437414358
self.do_runf('other/test_unused_destructor.c', cflags=['-flto', '-O2'])
@@ -14735,8 +14719,7 @@ def test_rust_integration_basics(self):
1473514719

1473614720
def test_relative_em_cache(self):
1473714721
with env_modify({'EM_CACHE': 'foo'}):
14738-
err = self.expect_fail([EMCC, '-c', test_file('hello_world.c')])
14739-
self.assertContained('emcc: error: environment variable EM_CACHE must be an absolute path: foo', err)
14722+
self.assert_fail([EMCC, '-c', test_file('hello_world.c')], 'emcc: error: environment variable EM_CACHE must be an absolute path: foo')
1474014723

1474114724
@crossplatform
1474214725
def test_create_cache_directory(self):

0 commit comments

Comments
 (0)