Skip to content

Commit d20f8c4

Browse files
authored
Remove IN_TEST_HARNESS setting (#18862)
This was set my some unit tests but not all the have a set of disparate effects on the generated code. Better to avoid having the test hardness be able have these kinds of special privileges, and it turns out they could all be implemented in other ways, or were not actually needed.
1 parent ca5f2bc commit d20f8c4

File tree

8 files changed

+11
-30
lines changed

8 files changed

+11
-30
lines changed

src/embind/embind.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,6 @@ var LibraryEmbind = {
4848
Module['getLiveInheritedInstances'] = getLiveInheritedInstances;
4949
Module['flushPendingDeletes'] = flushPendingDeletes;
5050
Module['setDelayFunction'] = setDelayFunction;
51-
#if IN_TEST_HARNESS
52-
#if ASSERTIONS
53-
Module['ASSERTIONS'] = true;
54-
#endif
55-
#if DYNAMIC_EXECUTION
56-
// Without dynamic execution, dynamically created functions will have no
57-
// names. This lets the test suite know that.
58-
Module['DYNAMIC_EXECUTION'] = true;
59-
#endif
60-
#if EMBIND_STD_STRING_IS_UTF8
61-
Module['EMBIND_STD_STRING_IS_UTF8'] = true;
62-
#endif
63-
#endif
6451
},
6552

6653
$throwInternalError__deps: ['$InternalError'],

src/library_pthread.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ var LibraryPThread = {
901901

902902
emscripten_check_blocking_allowed__deps: ['$warnOnce'],
903903
emscripten_check_blocking_allowed: function() {
904-
#if ASSERTIONS || IN_TEST_HARNESS || !MINIMAL_RUNTIME || !ALLOW_BLOCKING_ON_MAIN_THREAD
904+
#if ASSERTIONS || !MINIMAL_RUNTIME || !ALLOW_BLOCKING_ON_MAIN_THREAD
905905
#if ENVIRONMENT_MAY_BE_NODE
906906
if (ENVIRONMENT_IS_NODE) return;
907907
#endif

src/postamble_minimal.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ function run() {
3232

3333
#endif
3434

35-
#if IN_TEST_HARNESS && hasExportedSymbol('flush')
36-
// flush any stdio streams for test harness, since there are existing
37-
// tests that depend on this behavior.
38-
// For production use, instead print full lines to avoid this kind of lazy
39-
// behavior.
40-
_fflush();
41-
#endif
42-
4335
#if EXIT_RUNTIME
4436

4537
#if ASSERTIONS

src/settings.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,10 +1520,6 @@ var SDL2_MIXER_FORMATS = ["ogg"];
15201520
// [compile+link]
15211521
var USE_SQLITE3 = false;
15221522

1523-
// If true, the current build is performed for the Emscripten test harness.
1524-
// [other]
1525-
var IN_TEST_HARNESS = false;
1526-
15271523
// If 1, target compiling a shared Wasm Memory.
15281524
// [compile+link] - affects user code at compile and system libraries at link.
15291525
var SHARED_MEMORY = false;

test/common.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,6 @@ def compile_btest(self, args, reporting=Reporting.FULL):
18261826
# use REPORT_RESULT, and also adds a cpp file to be compiled alongside the testcase, which
18271827
# contains the implementation of REPORT_RESULT (we can't just include that implementation in
18281828
# the header as there may be multiple files being compiled here).
1829-
args += ['-sIN_TEST_HARNESS']
18301829
if reporting != Reporting.NONE:
18311830
# For basic reporting we inject JS helper funtions to report result back to server.
18321831
args += ['-DEMTEST_PORT_NUMBER=%d' % self.port,

test/embind/helpers.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mergeInto(LibraryManager.library, {
2+
$ASSERTIONS: Boolean({{{ ASSERTIONS }}}),
3+
$DYNAMIC_EXECUTION: Boolean({{{ DYNAMIC_EXECUTION }}}),
4+
$EMBIND_STD_STRING_IS_UTF8: Boolean({{{ EMBIND_STD_STRING_IS_UTF8 }}}),
5+
});

test/test_browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4059,15 +4059,15 @@ def test_pthread_custom_pthread_main_url(self):
40594059

40604060
# Test that it is possible to define "Module.locateFile" string to locate where worker.js will be loaded from.
40614061
create_file('shell.html', read_file(path_from_root('src/shell.html')).replace('var Module = {', 'var Module = { locateFile: function (path, prefix) {if (path.endsWith(".wasm")) {return prefix + path;} else {return "cdn/" + path;}}, '))
4062-
self.compile_btest(['main.cpp', '--shell-file', 'shell.html', '-sWASM=0', '-sIN_TEST_HARNESS', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE', '-o', 'test.html'], reporting=Reporting.JS_ONLY)
4062+
self.compile_btest(['main.cpp', '--shell-file', 'shell.html', '-sWASM=0', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE', '-o', 'test.html'], reporting=Reporting.JS_ONLY)
40634063
shutil.move('test.worker.js', Path('cdn/test.worker.js'))
40644064
if os.path.exists('test.html.mem'):
40654065
shutil.copyfile('test.html.mem', Path('cdn/test.html.mem'))
40664066
self.run_browser('test.html', '/report_result?exit:0')
40674067

40684068
# Test that it is possible to define "Module.locateFile(foo)" function to locate where worker.js will be loaded from.
40694069
create_file('shell2.html', read_file(path_from_root('src/shell.html')).replace('var Module = {', 'var Module = { locateFile: function(filename) { if (filename == "test.worker.js") return "cdn/test.worker.js"; else return filename; }, '))
4070-
self.compile_btest(['main.cpp', '--shell-file', 'shell2.html', '-sWASM=0', '-sIN_TEST_HARNESS', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE', '-o', 'test2.html'], reporting=Reporting.JS_ONLY)
4070+
self.compile_btest(['main.cpp', '--shell-file', 'shell2.html', '-sWASM=0', '-sUSE_PTHREADS', '-sPTHREAD_POOL_SIZE', '-o', 'test2.html'], reporting=Reporting.JS_ONLY)
40714071
delete_file('test.worker.js')
40724072
self.run_browser('test2.html', '/report_result?exit:0')
40734073

test/test_other.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2760,11 +2760,13 @@ def test_embind(self, extra_args):
27602760
[EMXX, test_file('embind/embind_test.cpp'),
27612761
'--pre-js', test_file('embind/test.pre.js'),
27622762
'--post-js', test_file('embind/test.post.js'),
2763+
'--js-library', test_file('embind/helpers.js'),
27632764
'-sWASM_ASYNC_COMPILATION=0',
27642765
# This test uses a `CustomSmartPtr` class which has 1MB of data embedded in
27652766
# it which means we need more stack space than normal.
27662767
'-sSTACK_SIZE=2MB',
2767-
'-sIN_TEST_HARNESS'] + args)
2768+
'-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$EMBIND_STD_STRING_IS_UTF8,$DYNAMIC_EXECUTION,$ASSERTIONS',
2769+
'-sEXPORTED_FUNCTIONS=EMBIND_STD_STRING_IS_UTF8,DYNAMIC_EXECUTION,ASSERTIONS'] + args)
27682770

27692771
if '-sDYNAMIC_EXECUTION=0' in args:
27702772
js_binary_str = read_file('a.out.js')

0 commit comments

Comments
 (0)