forked from compat-table/compat-table
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjerryscript.js
46 lines (39 loc) · 1.44 KB
/
jerryscript.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
/*
* Node.js test runner for running data-*.js tests with JerryScript 'jerry' command.
*
* Reports discrepancies to console; fix them manually in data-*.js files.
* Expects 'jerry' to be already built. Example:
*
* $ node jerryscript.js /path/to/jerry [suitename]
*/
var child_process = require('child_process');
var console = require('console');
var runner_support = require('./runner_support');
var jerryCommand = process.argv[2];
var suites = process.argv.slice(3);
// Key for .res (e.g. test.res.jerryscript1_0), automatic based on `jerry --version`.
var jerryKey = (function () {
var stdout = child_process.execFileSync(jerryCommand, [ '--version' ], {
encoding: 'utf-8'
});
var m = /^Version:\s+(\d)\.(\d)(?:\.(\d))?/.exec(stdout);
if (m) {
return 'jerryscript' + m[1] + '_' + m[2] + (m[3] ? '_' + m[3] : '');
}
throw new Error('Invalid JerryScript version');
})();
console.log('JerryScript result key is: test.res.' + jerryKey);
// jerryKey = "jerryscript2_4_0" // uncomment this line to test pre 2.4.0
function jerryRunner(testFilename) {
try {
var stdout = child_process.execFileSync(jerryCommand, [ testFilename ], {
encoding: 'utf-8'
});
//console.log(stdout);
return /^\[SUCCESS\]$/m.test(stdout);
} catch (e) {
//console.log(e);
return false;
}
}
runner_support.runTests(jerryRunner, jerryKey, 'JerryScript', { suites: suites });