diff --git a/src/shell.js b/src/shell.js index d820d97fe..326b6c6c7 100644 --- a/src/shell.js +++ b/src/shell.js @@ -196,7 +196,7 @@ if (ENVIRONMENT_IS_NODE) { console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'); throw e; } - Worker = nodeWorkerThreads.Worker; + global.Worker = nodeWorkerThreads.Worker; #endif #if WASM == 2 @@ -337,7 +337,7 @@ if (ENVIRONMENT_IS_NODE) { // Polyfill the performance object, which emscripten pthreads support // depends on for good timing. if (typeof performance === 'undefined') { - performance = require('perf_hooks').performance; + global.performance = require('perf_hooks').performance; } } #endif diff --git a/src/worker.js b/src/worker.js index 76e9b61ce..6f7a30c2a 100644 --- a/src/worker.js +++ b/src/worker.js @@ -307,7 +307,7 @@ if (typeof process === 'object' && typeof process.versions === 'object' && typeo var nodeWorkerThreads = require('worker_threads'); - Worker = nodeWorkerThreads.Worker; + global.Worker = nodeWorkerThreads.Worker; var parentPort = nodeWorkerThreads.parentPort; diff --git a/tests/core/emscripten_get_compiler_setting.c b/tests/core/emscripten_get_compiler_setting.c index eee3a7dcd..3219f1759 100644 --- a/tests/core/emscripten_get_compiler_setting.c +++ b/tests/core/emscripten_get_compiler_setting.c @@ -10,9 +10,9 @@ #include int main() { - printf("QS: %d\n", emscripten_get_compiler_setting("QUANTUM_SIZE")); + printf("EXIT_RUNTIME: %d\n", emscripten_get_compiler_setting("EXIT_RUNTIME")); assert((unsigned)emscripten_get_compiler_setting("OPT_LEVEL") <= 3); assert((unsigned)emscripten_get_compiler_setting("DEBUG_LEVEL") <= 4); - printf("EV: %s\n", (char*)emscripten_get_compiler_setting("EMSCRIPTEN_VERSION")); + printf("EMSCRIPTEN_VERSION: %s\n", (char*)emscripten_get_compiler_setting("EMSCRIPTEN_VERSION")); } diff --git a/tests/core/emscripten_get_compiler_setting.out b/tests/core/emscripten_get_compiler_setting.out index cd5200647..e1c556507 100644 --- a/tests/core/emscripten_get_compiler_setting.out +++ b/tests/core/emscripten_get_compiler_setting.out @@ -1,2 +1,2 @@ -QS: 4 -EV: waka +EXIT_RUNTIME: 0 +EMSCRIPTEN_VERSION: waka diff --git a/tests/core/test_utf.c b/tests/core/test_utf.c index 99c3dcf20..786088ace 100644 --- a/tests/core/test_utf.c +++ b/tests/core/test_utf.c @@ -13,7 +13,7 @@ int main() { printf("%d %d %d %d %s\n", c[0] & 0xff, c[1] & 0xff, c[2] & 0xff, c[3] & 0xff, c); emscripten_run_script( - "cheez = _malloc(100);" + "var cheez = _malloc(100);" "Module.stringToUTF8(\"μ†ℱ ╋ℯ╳╋ 😇\", cheez, 100);" "out([UTF8ToString(cheez), Module.getValue(cheez, " "'i8')&0xff, Module.getValue(cheez+1, 'i8')&0xff, " diff --git a/tests/filesystem/src.js b/tests/filesystem/src.js index 500d08ab2..dd93dc9a4 100644 --- a/tests/filesystem/src.js +++ b/tests/filesystem/src.js @@ -1,7 +1,7 @@ var dummy_device = FS.makedev(64, 0); FS.registerDevice(dummy_device, {}); -FS.mkdir('/forbidden', 0000); +FS.mkdir('/forbidden', 0o000); FS.mkdir('/forbidden/test'); FS.mkdir('/abc'); FS.mkdir('/abc/123'); diff --git a/tests/fs/test_llseek.c b/tests/fs/test_llseek.c index 563c6a58d..c41622f54 100644 --- a/tests/fs/test_llseek.c +++ b/tests/fs/test_llseek.c @@ -12,7 +12,7 @@ int main() EM_ASM( FS.writeFile('testfile', 'a=1\nb=2\n'); var stream = FS.open('testfile', 'a'); - fd = FS.write(stream, new Uint8Array([99, 61, 51]) /* c=3 */, 0, 3); + var fd = FS.write(stream, new Uint8Array([99, 61, 51]) /* c=3 */, 0, 3); // check invalid whence var ex; diff --git a/tests/runner.py b/tests/runner.py index c5efcbe46..b45842335 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -244,6 +244,7 @@ core_test_modes = [ 'wasm3', 'wasms', 'wasmz', + 'strict' ] if shared.Settings.WASM_BACKEND: diff --git a/tests/test_core.py b/tests/test_core.py index 66c4518de..08213b90f 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -8817,6 +8817,8 @@ NODEFS is no longer included by default; build with -lnodefs.js def test_undefined_main(self): if self.get_setting('LLD_REPORT_UNDEFINED'): self.skipTest('LLD_REPORT_UNDEFINED does not allow implicit undefined main') + if self.get_setting('STRICT'): + self.skipTest('STRICT does not allow implicit undefined main') # By default in emscripten we allow main to be undefined. Its used when # building library code that has no main. # TODO(sbc): Simplify the code by making this an opt-in feature. @@ -8868,7 +8870,7 @@ NODEFS is no longer included by default; build with -lnodefs.js self.do_run_in_out_file_test('tests', 'core', 'test_get_exported_function') def test_auto_detect_main(self): - if not self.get_setting('LLD_REPORT_UNDEFINED'): + if not self.get_setting('LLD_REPORT_UNDEFINED') and not self.get_setting('STRICT'): self.do_run_in_out_file_test('tests', 'core', 'test_ctors_no_main') # Disabling IGNORE_MISSING_MAIN should cause link to fail due to missing main @@ -8975,7 +8977,8 @@ asm2nn = make_run('asm2nn', emcc_args=['-O2'], settings={'WASM': 0}, env={'EMCC_ # wasm wasm2s = make_run('wasm2s', emcc_args=['-O2'], settings={'SAFE_HEAP': 1}) wasm2ss = make_run('wasm2ss', emcc_args=['-O2'], settings={'STACK_OVERFLOW_CHECK': 2}) -strict = make_run('strict', emcc_args=['-O2'], settings={'DEFAULT_TO_CXX': 0}) +# Add DEFAULT_TO_CXX=0 +strict = make_run('strict', emcc_args=[], settings={'STRICT': 1}) if not shared.Settings.WASM_BACKEND: # emterpreter @@ -8989,7 +8992,6 @@ if shared.Settings.WASM_BACKEND: # Experimental modes (not tested by CI) lld = make_run('lld', emcc_args=[], settings={'LLD_REPORT_UNDEFINED': 1}) - strict = make_run('strict', emcc_args=[], settings={'STRICT': 1}) # TestCoreBase is just a shape for the specific subclasses, we don't test it itself del TestCoreBase # noqa diff --git a/tests/unistd/access.c b/tests/unistd/access.c index df8d603e6..3ac337b8b 100644 --- a/tests/unistd/access.c +++ b/tests/unistd/access.c @@ -27,10 +27,10 @@ int main() { FS.mount(NODEFS, { root: '.' }, 'working'); #endif FS.chdir('working'); - FS.writeFile('forbidden', ''); FS.chmod('forbidden', 0000); - FS.writeFile('readable', ''); FS.chmod('readable', 0444); - FS.writeFile('writeable', ''); FS.chmod('writeable', 0222); - FS.writeFile('allaccess', ''); FS.chmod('allaccess', 0777); + FS.writeFile('forbidden', ''); FS.chmod('forbidden', 0o000); + FS.writeFile('readable', ''); FS.chmod('readable', 0o444); + FS.writeFile('writeable', ''); FS.chmod('writeable', 0o222); + FS.writeFile('allaccess', ''); FS.chmod('allaccess', 0o777); ); #endif // Empty path checks #9136 fix @@ -68,10 +68,10 @@ int main() { // won't have problems on deleting the files. On Windows, calling shutil.rmtree() // will fail if any of the files are read-only. EM_ASM( - FS.chmod('forbidden', 0777); - FS.chmod('readable', 0777); - FS.chmod('writeable', 0777); - FS.chmod('allaccess', 0777); + FS.chmod('forbidden', 0o777); + FS.chmod('readable', 0o777); + FS.chmod('writeable', 0o777); + FS.chmod('allaccess', 0o777); ); #endif diff --git a/tests/unistd/curdir.c b/tests/unistd/curdir.c index bbcc721bf..9bc5759be 100644 --- a/tests/unistd/curdir.c +++ b/tests/unistd/curdir.c @@ -19,7 +19,7 @@ int main() { FS.mkdir('/folder'); FS.symlink('/folder', '/link'); - FS.writeFile('/file', '', { mode: 0777 }); + FS.writeFile('/file', '', { mode: 0o777 }); ); char buffer[256]; diff --git a/tests/unistd/truncate.c b/tests/unistd/truncate.c index 3435866eb..c43c95345 100644 --- a/tests/unistd/truncate.c +++ b/tests/unistd/truncate.c @@ -22,7 +22,7 @@ int main() { FS.chdir('working'); FS.writeFile('towrite', 'abcdef'); FS.writeFile('toread', 'abcdef'); - FS.chmod('toread', 0444); + FS.chmod('toread', 0o444); ); struct stat s; @@ -87,7 +87,7 @@ int main() { // won't have problems on deleting the files. On Windows, calling shutil.rmtree() // will fail if any of the files are read-only. EM_ASM( - FS.chmod('toread', 0777); + FS.chmod('toread', 0o777); ); return 0; }