Skip to content

Commit 68d63ba

Browse files
[GR-45763] Backport 22.3 : Upload JavaScript data to testing dashboard.
PullRequest: js/2800
2 parents 7187529 + 1a7e3ae commit 68d63ba

File tree

5 files changed

+1419
-102
lines changed

5 files changed

+1419
-102
lines changed

graal-js/mx.graal-js/mx_graal_js.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#
2727
# ----------------------------------------------------------------------------------------------------
2828

29-
import os, shutil, tarfile
29+
import os, shutil, tarfile, tempfile
3030
from os.path import join, exists, getmtime
3131

3232
import mx_graal_js_benchmark
@@ -71,16 +71,16 @@ def _graal_js_gate_runner(args, tasks):
7171
js(['-Dpolyglot.js.profile-time=true', '-e', '""'])
7272

7373
webassemblyTestSuite = 'com.oracle.truffle.js.test.suite.WebAssemblySimpleTestSuite'
74-
with Task('UnitTests', tasks, tags=[GraalJsDefaultTags.default, GraalJsDefaultTags.all]) as t:
74+
with Task('UnitTests', tasks, tags=[GraalJsDefaultTags.default, GraalJsDefaultTags.all], report=True) as t:
7575
if t:
7676
noWebAssemblyTestSuite = '^(?!' + webassemblyTestSuite + ')'
7777
commonOptions = ['--enable-timing', '--very-verbose', '--suite', _suite.name]
78-
unittest(['--regex', noWebAssemblyTestSuite] + commonOptions)
79-
unittest(['--regex', 'ZoneRulesProviderTest', '-Djava.time.zone.DefaultZoneRulesProvider=com.oracle.truffle.js.test.runtime.SimpleZoneRulesProvider'] + commonOptions)
78+
unittest(['--regex', noWebAssemblyTestSuite] + commonOptions, test_report_tags={'task': t.title})
79+
unittest(['--regex', 'ZoneRulesProviderTest', '-Djava.time.zone.DefaultZoneRulesProvider=com.oracle.truffle.js.test.runtime.SimpleZoneRulesProvider'] + commonOptions, test_report_tags={'task': t.title})
8080

81-
with Task('WebAssemblyTests', tasks, tags=['webassembly', GraalJsDefaultTags.all]) as t:
81+
with Task('WebAssemblyTests', tasks, tags=['webassembly', GraalJsDefaultTags.all], report=True) as t:
8282
if t:
83-
unittest(['--regex', webassemblyTestSuite, '--enable-timing', '--very-verbose', '--suite', _suite.name])
83+
unittest(['--regex', webassemblyTestSuite, '--enable-timing', '--very-verbose', '--suite', _suite.name], test_report_tags={'task': t.title})
8484

8585
gateTestConfigs = {
8686
GraalJsDefaultTags.default: ['gate'],
@@ -106,14 +106,20 @@ def _graal_js_gate_runner(args, tasks):
106106
if testCommandName == 'TestNashorn' and testConfigName == 'latestversion':
107107
continue
108108
testName = '%s-%s' % (testCommandName, testConfigName)
109-
with Task(testName, tasks, tags=[testName, testConfigName, GraalJsDefaultTags.all]) as t:
109+
report = True if testConfigName == GraalJsDefaultTags.default else None
110+
with Task(testName, tasks, tags=[testName, testConfigName, GraalJsDefaultTags.all], report=report) as t:
110111
if t:
111112
gateTestCommands[testCommandName](gateTestConfigs[testConfigName])
112113

113-
with Task('TCK tests', tasks, tags=[GraalJsDefaultTags.all, GraalJsDefaultTags.tck]) as t:
114+
with Task('TCK tests', tasks, tags=[GraalJsDefaultTags.all, GraalJsDefaultTags.tck], report=True) as t:
114115
if t:
115-
import mx_truffle
116-
mx_truffle._tck([])
116+
import mx_gate, mx_truffle
117+
jsonResultsFile = tempfile.NamedTemporaryFile(delete=False, suffix='.json.gz').name
118+
try:
119+
mx_truffle._tck(['--json-results=' + jsonResultsFile])
120+
mx_gate.make_test_report(jsonResultsFile, tags={'task': t.title})
121+
finally:
122+
os.unlink(jsonResultsFile)
117123

118124
prepend_gate_runner(_suite, _graal_js_pre_gate_runner)
119125
add_gate_runner(_suite, _graal_js_gate_runner)

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class GraalNodeJsTags:
5050

5151
def _graal_nodejs_post_gate_runner(args, tasks):
5252
_setEnvVar('NODE_INTERNAL_ERROR_CHECK', 'true')
53-
with Task('UnitTests', tasks, tags=[GraalNodeJsTags.allTests, GraalNodeJsTags.unitTests]) as t:
53+
with Task('UnitTests', tasks, tags=[GraalNodeJsTags.allTests, GraalNodeJsTags.unitTests], report=True) as t:
5454
if t:
5555
_setEnvVar('NODE_JVM_CLASSPATH', mx.distribution('graal-js:TRUFFLE_JS_TESTS').path)
5656
commonArgs = ['-ea', '-esa']
@@ -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:

graal-nodejs/test/graal/index.js

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -42,10 +42,28 @@
4242
var Mocha = require('mocha');
4343
var fs = require('fs');
4444

45+
const {
46+
EVENT_TEST_FAIL,
47+
EVENT_TEST_PASS,
48+
EVENT_TEST_PENDING
49+
} = Mocha.Runner.constants;
50+
4551
var limitToSuites = [];
52+
var jsonResultsFile = null;
4653
for (var i = 2; i < process.argv.length; i++) {
4754
var arg = process.argv[i];
4855
if (arg.length > 0) {
56+
if (arg.startsWith('--')) {
57+
if (arg == '--help') {
58+
console.log(`node ${process.argv[1]} [--json-results=file.json.gz] [testsuite.js...]`)
59+
process.exit(0);
60+
} else if (arg.startsWith('--json-results=')) {
61+
jsonResultsFile = arg.split('=', 2)[1];
62+
} else {
63+
console.error(`Unknown option: ${arg}`);
64+
}
65+
continue;
66+
}
4967
suite = process.argv[i];
5068
console.log("limiting to suite:", suite);
5169
limitToSuites.push(suite);
@@ -104,8 +122,40 @@ for (var i = 0; i < filesLength; i++) {
104122
}
105123
}
106124

125+
const JsonStatus = {
126+
PASSED: "PASSED",
127+
FAILED: "FAILED",
128+
IGNORED: "IGNORED"
129+
};
130+
131+
let results = [];
132+
function onTestEnd(test, status) {
133+
results.push({
134+
name: test.fullTitle(),
135+
status: status,
136+
duration: String(test.duration || 0)
137+
});
138+
}
139+
function onRunEnd() {
140+
if (jsonResultsFile !== null) {
141+
let output = JSON.stringify(results);
142+
if (jsonResultsFile.endsWith('.gz')) {
143+
const {gzipSync} = require('zlib');
144+
output = gzipSync(output);
145+
}
146+
fs.writeFileSync(jsonResultsFile, output);
147+
}
148+
}
149+
107150
mocha.run(function (failures) {
151+
onRunEnd();
108152
process.on('exit', function () {
109-
process.exit(failures); // exit with non-zero status if there were failures
153+
process.exit(failures ? 1 : 0); // exit with non-zero status if there were failures
110154
});
155+
}).on(EVENT_TEST_PASS, (test) => {
156+
onTestEnd(test, JsonStatus.PASSED);
157+
}).on(EVENT_TEST_FAIL, (test) => {
158+
onTestEnd(test, JsonStatus.FAILED);
159+
}).on(EVENT_TEST_PENDING, (test) => {
160+
onTestEnd(test, JsonStatus.IGNORED);
111161
});

0 commit comments

Comments
 (0)