-
Notifications
You must be signed in to change notification settings - Fork 0
/
test262-runner.js
52 lines (49 loc) · 1.38 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
48
49
50
51
52
// const { spawnSync } = require('child_process');
const spawn = require('cross-spawn');
const { resolve } = require ('path');
const { cpus } = require('os');
const implementation = process.argv[2]
const args = [
'--reporter-keys',
'file,attrs,result',
'-t',
String(cpus().length),
'--prelude',
'./build/' + implementation + '.js',
'-r',
'json',
'test262/test/intl402/RelativeTimeFormat/**/*.js'
];
console.log(`Running "test262-harness ${args.join(' ')}"`);
const result = spawn.sync('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`
);