Skip to content

Commit 730bd85

Browse files
woessossama-ismaili
authored andcommitted
Generate Node.js unit test reports.
(cherry picked from commit 6c00c65)
1 parent 08744d2 commit 730bd85

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

graal-nodejs/mx.graal-nodejs/mx_graal_nodejs.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,24 @@ def _graal_nodejs_post_gate_runner(args, tasks):
5959
p = join(unitTestDir, dir_name)
6060
if exists(p):
6161
mx.rmtree(p)
62-
npm(['--scripts-prepend-node-path=auto', 'install', '--nodedir=' + _suite.dir] + commonArgs, cwd=unitTestDir)
63-
npm(['--scripts-prepend-node-path=auto', 'test'] + commonArgs, cwd=unitTestDir)
64-
if mx.suite('wasm', fatalIfMissing=False):
65-
npm(['--scripts-prepend-node-path=auto', 'run', 'testwasm'] + commonArgs, cwd=unitTestDir)
66-
# test that WebAssembly can be enabled using env. variables
67-
_setEnvVar('NODE_OPTIONS', '--polyglot')
68-
_setEnvVar('NODE_POLYGLOT_OPTIONS', '--js.webassembly --experimental-options')
69-
node(commonArgs + ['-e', 'console.log(WebAssembly)'])
70-
_setEnvVar('NODE_OPTIONS', '')
71-
_setEnvVar('NODE_POLYGLOT_OPTIONS', '')
62+
63+
jsonResultsFile = tempfile.NamedTemporaryFile(delete=False, suffix='.json.gz').name
64+
testArgs = ['--', '--json-results=' + jsonResultsFile]
65+
try:
66+
npm(['--scripts-prepend-node-path=auto', 'install', '--nodedir=' + _suite.dir] + commonArgs, cwd=unitTestDir)
67+
npm(['--scripts-prepend-node-path=auto', 'test'] + commonArgs + testArgs, cwd=unitTestDir)
68+
if mx.suite('wasm', fatalIfMissing=False):
69+
npm(['--scripts-prepend-node-path=auto', 'run', 'testwasm'] + commonArgs + testArgs, cwd=unitTestDir)
70+
# test that WebAssembly can be enabled using env. variables
71+
_setEnvVar('NODE_OPTIONS', '--polyglot')
72+
_setEnvVar('NODE_POLYGLOT_OPTIONS', '--js.webassembly --experimental-options')
73+
node(commonArgs + ['-e', 'console.log(WebAssembly)'])
74+
_setEnvVar('NODE_OPTIONS', '')
75+
_setEnvVar('NODE_POLYGLOT_OPTIONS', '')
76+
77+
mx_gate.make_test_report(jsonResultsFile, tags={'task': t.title})
78+
finally:
79+
os.unlink(jsonResultsFile)
7280

7381
with Task('TestNpm', tasks, tags=[GraalNodeJsTags.allTests, GraalNodeJsTags.windows]) as t:
7482
if t:

0 commit comments

Comments
 (0)