-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest262-runner.js
47 lines (45 loc) · 1.31 KB
/
test262-runner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const {spawnSync} = require("child_process");
const {resolve} = require("path");
const {cpus} = require("os");
const pkg = require("./package.json");
const args = [
"--hostArgs",
`"--icu-data-dir=node_modules/full-icu"`,
"--reporter-keys",
"file,attrs,result",
"-t",
String(cpus().length),
"--prelude",
pkg.test262,
"-r",
"json",
"test262/test/intl402/RelativeTimeFormat/**/*.*"
];
console.log(`Running "test262-harness ${args.join(" ")}"`);
const result = spawnSync("test262-harness", args, {
env: process.env,
encoding: "utf-8"
});
if (result.status || result.stderr || result.error) {
console.error(result.stderr);
console.error(result.error);
process.exit(result.status || 1);
}
const json = JSON.parse(result.stdout);
const failedTests = json.filter(r => !r.result.pass);
json.forEach(t => {
if (t.result.pass) {
console.log(`✓ ${t.attrs.description}`);
} else {
console.log("\n\n");
console.log(`🗴 ${t.attrs.description}`);
console.log(`\t ${t.result.message}`);
console.log("\t", resolve(__dirname, "..", t.file));
console.log("\n\n");
}
});
if (failedTests.length) {
console.log(`Tests: ${failedTests.length} failed, ${json.length - failedTests.length} passed, ${json.length} total`);
process.exit(1);
}
console.log(`Tests: ${json.length - failedTests.length} passed, ${json.length} total`);