summaryrefslogtreecommitdiff
path: root/scripts/test
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2019-08-21 08:54:57 -0700
committerGitHub <noreply@github.com>2019-08-21 08:54:57 -0700
commitc57f93c8919ab33574e5ce78f0044980ca33de76 (patch)
treed9a536f7e55b0f4018a257cb61e0e97a113abdac /scripts/test
parent2895ca0816507a9ca1ea19b5d990a1bb8299c9c4 (diff)
downloadbinaryen-c57f93c8919ab33574e5ce78f0044980ca33de76.tar.gz
binaryen-c57f93c8919ab33574e5ce78f0044980ca33de76.tar.bz2
binaryen-c57f93c8919ab33574e5ce78f0044980ca33de76.zip
Remove test output from source tree (#2114)
Diffstat (limited to 'scripts/test')
-rw-r--r--scripts/test/node-esm-loader.mjs6
-rw-r--r--scripts/test/shared.py5
-rwxr-xr-xscripts/test/wasm2js.py3
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)