diff options
Diffstat (limited to 'scripts/test')
-rw-r--r-- | scripts/test/node-esm-loader.mjs | 6 | ||||
-rw-r--r-- | scripts/test/shared.py | 5 | ||||
-rwxr-xr-x | scripts/test/wasm2js.py | 3 |
3 files changed, 11 insertions, 3 deletions
diff --git a/scripts/test/node-esm-loader.mjs b/scripts/test/node-esm-loader.mjs index 5d41033fb..9d073c171 100644 --- a/scripts/test/node-esm-loader.mjs +++ b/scripts/test/node-esm-loader.mjs @@ -7,7 +7,9 @@ import Module from 'module'; const builtins = Module.builtinModules; const baseURL = new URL('file://'); -baseURL.pathname = `${process.cwd()}/`; +const binaryen_root = path.dirname(path.dirname(process.cwd())); +baseURL.pathname = `${binaryen_root}/`; + export function resolve(specifier, parentModuleURL = baseURL, defaultResolve) { if (builtins.includes(specifier)) { @@ -18,7 +20,7 @@ export function resolve(specifier, parentModuleURL = baseURL, defaultResolve) { } // Resolve special modules used in our test suite. if (specifier == 'spectest' || specifier == 'env' || specifier == 'mod.ule') { - const resolved = new URL('./scripts/test/' + specifier + '.js', parentModuleURL); + const resolved = new URL('./scripts/test/' + specifier + '.js', baseURL); return { url: resolved.href, format: 'esm' diff --git a/scripts/test/shared.py b/scripts/test/shared.py index ad2f44c14..921da1f7f 100644 --- a/scripts/test/shared.py +++ b/scripts/test/shared.py @@ -124,6 +124,11 @@ if not options.binaryen_root: options.binaryen_test = os.path.join(options.binaryen_root, 'test') +test_out = os.path.join(options.binaryen_root, 'out', 'test') +if not os.path.exists(test_out): + os.makedirs(test_out) +os.chdir(test_out) + # Finds the given executable 'program' in PATH. # Operates like the Unix tool 'which'. diff --git a/scripts/test/wasm2js.py b/scripts/test/wasm2js.py index 39ba946fe..c1abaa8f9 100755 --- a/scripts/test/wasm2js.py +++ b/scripts/test/wasm2js.py @@ -86,7 +86,8 @@ def test_wasm2js_output(): # to enable ESM syntax and we're also passing a custom loader to handle the # `spectest` and `env` modules in our tests. if NODEJS: - node = [NODEJS, '--experimental-modules', '--loader', './scripts/test/node-esm-loader.mjs'] + loader = os.path.join(options.binaryen_root, 'scripts', 'test', 'node-esm-loader.mjs') + node = [NODEJS, '--experimental-modules', '--loader', loader] cmd = node[:] cmd.append('a.2asm.mjs') out = run_command(cmd) |