13af6ab5fSopenharmony_cidiff --git a/bin/run.js b/bin/run.js 23af6ab5fSopenharmony_ciindex 650f19a..7284fa1 100755 33af6ab5fSopenharmony_ci--- a/bin/run.js 43af6ab5fSopenharmony_ci+++ b/bin/run.js 53af6ab5fSopenharmony_ci@@ -76,6 +76,7 @@ if (argv.prelude) { 63af6ab5fSopenharmony_ci let hostType; 73af6ab5fSopenharmony_ci let hostPath; 83af6ab5fSopenharmony_ci let features; 93af6ab5fSopenharmony_ci+let mode; 103af6ab5fSopenharmony_ci 113af6ab5fSopenharmony_ci if (argv.hostType) { 123af6ab5fSopenharmony_ci hostType = argv.hostType; 133af6ab5fSopenharmony_ci@@ -123,6 +124,12 @@ if (argv.features) { 143af6ab5fSopenharmony_ci features = argv.features.split(',').map(feature => feature.trim()); 153af6ab5fSopenharmony_ci } 163af6ab5fSopenharmony_ci 173af6ab5fSopenharmony_ci+mode = "only strict mode" 183af6ab5fSopenharmony_ci+ 193af6ab5fSopenharmony_ci+if (argv.mode) { 203af6ab5fSopenharmony_ci+ mode = argv.mode 213af6ab5fSopenharmony_ci+} 223af6ab5fSopenharmony_ci+ 233af6ab5fSopenharmony_ci // Show help if no arguments provided 243af6ab5fSopenharmony_ci if (!argv._.length) { 253af6ab5fSopenharmony_ci cli.showHelp(); 263af6ab5fSopenharmony_ci@@ -130,17 +137,35 @@ if (!argv._.length) { 273af6ab5fSopenharmony_ci return; 283af6ab5fSopenharmony_ci } 293af6ab5fSopenharmony_ci 303af6ab5fSopenharmony_ci-// Test Pipeline 313af6ab5fSopenharmony_ci-const pool = new AgentPool( 323af6ab5fSopenharmony_ci- Number(argv.threads), hostType, argv.hostArgs, hostPath, { tempDir, timeout, transform } 333af6ab5fSopenharmony_ci-); 343af6ab5fSopenharmony_ci 353af6ab5fSopenharmony_ci if (!test262Dir) { 363af6ab5fSopenharmony_ci test262Dir = test262Finder(argv._[0]); 373af6ab5fSopenharmony_ci } 383af6ab5fSopenharmony_ci+ 393af6ab5fSopenharmony_ci reporterOpts.test262Dir = test262Dir; 403af6ab5fSopenharmony_ci+reporterOpts.tempDir = tempDir 413af6ab5fSopenharmony_ci+ 423af6ab5fSopenharmony_ci+// Test Pipeline 433af6ab5fSopenharmony_ci+const pool = new AgentPool( 443af6ab5fSopenharmony_ci+ Number(argv.threads), hostType, argv.hostArgs, hostPath, { tempDir, timeout, transform, test262Dir } 453af6ab5fSopenharmony_ci+); 463af6ab5fSopenharmony_ci 473af6ab5fSopenharmony_ci const remove = path.relative(process.cwd(), test262Dir); 483af6ab5fSopenharmony_ci+if (argv.isTestListSet) { 493af6ab5fSopenharmony_ci+ let fileName = argv._[0] 503af6ab5fSopenharmony_ci+ if (!fs.existsSync(fileName)){ 513af6ab5fSopenharmony_ci+ if (fileName.startsWith("test262/")) { 523af6ab5fSopenharmony_ci+ fileName = path.join(__dirname, "../../../", fileName) 533af6ab5fSopenharmony_ci+ } else { 543af6ab5fSopenharmony_ci+ fileName = path.join(__dirname, "../../", fileName) 553af6ab5fSopenharmony_ci+ } 563af6ab5fSopenharmony_ci+ } 573af6ab5fSopenharmony_ci+ const data = fs.readFileSync(fileName, "utf8") 583af6ab5fSopenharmony_ci+ argv._ = data 593af6ab5fSopenharmony_ci+ .split("\n") 603af6ab5fSopenharmony_ci+ .map(line => line.trim()) 613af6ab5fSopenharmony_ci+ .filter(line => line.length > 0 && !line.startsWith("#")) 623af6ab5fSopenharmony_ci+} 633af6ab5fSopenharmony_ci argv._ = argv._.map(p => path.relative(remove, p)); 643af6ab5fSopenharmony_ci 653af6ab5fSopenharmony_ci let test262Version; 663af6ab5fSopenharmony_ci@@ -166,6 +191,7 @@ if (preprocessor) { 673af6ab5fSopenharmony_ci tests = tests.pipe(filter(preprocessor)); 683af6ab5fSopenharmony_ci } 693af6ab5fSopenharmony_ci 703af6ab5fSopenharmony_ci+tests = tests.pipe(filter(operMode)); 713af6ab5fSopenharmony_ci const results = zip(pool, tests).pipe( 723af6ab5fSopenharmony_ci flatMap(pair => { 733af6ab5fSopenharmony_ci return pool.runTest(pair); 743af6ab5fSopenharmony_ci@@ -209,3 +235,11 @@ function hasFeatures(test) { 753af6ab5fSopenharmony_ci } 763af6ab5fSopenharmony_ci return features.filter(feature => (test.attrs.features || []).includes(feature)).length > 0; 773af6ab5fSopenharmony_ci } 783af6ab5fSopenharmony_ci+ 793af6ab5fSopenharmony_ci+function operMode(test) { 803af6ab5fSopenharmony_ci+ test_scenario = test.scenario 813af6ab5fSopenharmony_ci+ if (mode.indexOf(test_scenario) != -1) { 823af6ab5fSopenharmony_ci+ return true; 833af6ab5fSopenharmony_ci+ } 843af6ab5fSopenharmony_ci+ return false; 853af6ab5fSopenharmony_ci+} 863af6ab5fSopenharmony_cidiff --git a/lib/agent-pool.js b/lib/agent-pool.js 873af6ab5fSopenharmony_ciindex ad14b84..1b8a184 100644 883af6ab5fSopenharmony_ci--- a/lib/agent-pool.js 893af6ab5fSopenharmony_ci+++ b/lib/agent-pool.js 903af6ab5fSopenharmony_ci@@ -1,6 +1,6 @@ 913af6ab5fSopenharmony_ci 'use strict'; 923af6ab5fSopenharmony_ci const {Subject} = require('rxjs'); 933af6ab5fSopenharmony_ci-const eshost = require('eshost'); 943af6ab5fSopenharmony_ci+const eshost = require('../../eshost/lib/eshost'); 953af6ab5fSopenharmony_ci 963af6ab5fSopenharmony_ci const internal = new WeakMap(); 973af6ab5fSopenharmony_ci 983af6ab5fSopenharmony_ci@@ -18,6 +18,7 @@ class AgentPool extends Subject { 993af6ab5fSopenharmony_ci shortName: '$262', 1003af6ab5fSopenharmony_ci transform: options.transform, 1013af6ab5fSopenharmony_ci out: options.tempDir, 1023af6ab5fSopenharmony_ci+ test262Dir: options.test262Dir, 1033af6ab5fSopenharmony_ci }) 1043af6ab5fSopenharmony_ci .then(agent => { 1053af6ab5fSopenharmony_ci this.agents.push(agent); 1063af6ab5fSopenharmony_cidiff --git a/lib/cli.js b/lib/cli.js 1073af6ab5fSopenharmony_ciindex 4a74309..a330271 100644 1083af6ab5fSopenharmony_ci--- a/lib/cli.js 1093af6ab5fSopenharmony_ci+++ b/lib/cli.js 1103af6ab5fSopenharmony_ci@@ -1,4 +1,4 @@ 1113af6ab5fSopenharmony_ci-const { supportedHosts } = require("eshost"); 1123af6ab5fSopenharmony_ci+const { supportedHosts } = require("./../../eshost/lib/eshost"); 1133af6ab5fSopenharmony_ci const yargs = require('yargs'); 1143af6ab5fSopenharmony_ci const yargv = yargs 1153af6ab5fSopenharmony_ci .strict() 1163af6ab5fSopenharmony_ci@@ -22,6 +22,9 @@ const yargv = yargs 1173af6ab5fSopenharmony_ci .nargs('threads', 1) 1183af6ab5fSopenharmony_ci .default('threads', 1) 1193af6ab5fSopenharmony_ci .alias('threads', 't') 1203af6ab5fSopenharmony_ci+ .nargs('mode', 1) 1213af6ab5fSopenharmony_ci+ .default('mode', 1) 1223af6ab5fSopenharmony_ci+ .alias('mode', 'm') 1233af6ab5fSopenharmony_ci .describe('reporter', 'format of data written to standard output') 1243af6ab5fSopenharmony_ci .choices('reporter', ['simple', 'json']) 1253af6ab5fSopenharmony_ci .nargs('reporter', 1) 1263af6ab5fSopenharmony_ci@@ -33,6 +36,8 @@ const yargv = yargs 1273af6ab5fSopenharmony_ci .describe('timeout', 'test timeout (in ms, default 10000)') 1283af6ab5fSopenharmony_ci .nargs('timeout', 1) 1293af6ab5fSopenharmony_ci .describe('acceptVersion', 'override for supported Test262 version') 1303af6ab5fSopenharmony_ci+ .boolean('isTestListSet') 1313af6ab5fSopenharmony_ci+ .describe('isTestListSet', 'Set if positional argument contains test-list file') 1323af6ab5fSopenharmony_ci .boolean('saveCompiledTests') 1333af6ab5fSopenharmony_ci .describe('saveCompiledTests', 'Write the compiled version of path/to/test.js as path/to/test.js.<hostType>.<default|strict>.<pass|fail> so that it can be easily re-run under that host') 1343af6ab5fSopenharmony_ci .boolean('saveOnlyFailed') 1353af6ab5fSopenharmony_cidiff --git a/lib/reporters/simple.js b/lib/reporters/simple.js 1363af6ab5fSopenharmony_ciindex 08f9a55..1579861 100644 1373af6ab5fSopenharmony_ci--- a/lib/reporters/simple.js 1383af6ab5fSopenharmony_ci+++ b/lib/reporters/simple.js 1393af6ab5fSopenharmony_ci@@ -1,22 +1,30 @@ 1403af6ab5fSopenharmony_ci 'use strict'; 1413af6ab5fSopenharmony_ci const path = require('path'); 1423af6ab5fSopenharmony_ci+const fs = require('fs'); 1433af6ab5fSopenharmony_ci const saveCompiledTest = require('../saveCompiledTest'); 1443af6ab5fSopenharmony_ci+var xmlbuilder = require('xmlbuilder'); 1453af6ab5fSopenharmony_ci 1463af6ab5fSopenharmony_ci function simpleReporter(results, opts) { 1473af6ab5fSopenharmony_ci let passed = 0; 1483af6ab5fSopenharmony_ci let failed = 0; 1493af6ab5fSopenharmony_ci let lastPassed = true; 1503af6ab5fSopenharmony_ci+ let xmll = xmlbuilder.create("testsuite"); 1513af6ab5fSopenharmony_ci+ xmll.att("name", "Test 262"); 1523af6ab5fSopenharmony_ci 1533af6ab5fSopenharmony_ci results.on('pass', function (test) { 1543af6ab5fSopenharmony_ci passed++; 1553af6ab5fSopenharmony_ci 1563af6ab5fSopenharmony_ci clearPassed(); 1573af6ab5fSopenharmony_ci lastPassed = true; 1583af6ab5fSopenharmony_ci- process.stdout.write(`PASS ${test.file}`); 1593af6ab5fSopenharmony_ci+ let mess = `PASS ${test.file} (${test.scenario})\n` 1603af6ab5fSopenharmony_ci+ console.log(mess); 1613af6ab5fSopenharmony_ci+ writeStatistics(mess, opts); 1623af6ab5fSopenharmony_ci+ 1633af6ab5fSopenharmony_ci+ xmll.ele("testcase").att("name", test.file); 1643af6ab5fSopenharmony_ci 1653af6ab5fSopenharmony_ci if (opts.saveCompiledTests && !opts.saveOnlyFailed) { 1663af6ab5fSopenharmony_ci test.savedTestPath = saveCompiledTest(test, opts); 1673af6ab5fSopenharmony_ci- process.stdout.write(`\nSaved compiled passed test as ${test.savedTestPath}\n`); 1683af6ab5fSopenharmony_ci+ // process.stdout.write(`\nSaved compiled passed test as ${test.savedTestPath}\n`); 1693af6ab5fSopenharmony_ci } 1703af6ab5fSopenharmony_ci }); 1713af6ab5fSopenharmony_ci 1723af6ab5fSopenharmony_ci@@ -24,14 +32,27 @@ function simpleReporter(results, opts) { 1733af6ab5fSopenharmony_ci failed++; 1743af6ab5fSopenharmony_ci clearPassed(); 1753af6ab5fSopenharmony_ci lastPassed = false; 1763af6ab5fSopenharmony_ci- console.log(`FAIL ${test.file} (${test.scenario})`); 1773af6ab5fSopenharmony_ci- console.log(` ${test.result.message}`); 1783af6ab5fSopenharmony_ci+ 1793af6ab5fSopenharmony_ci+ let mess = `FAIL ${test.file} (${test.scenario})\n` 1803af6ab5fSopenharmony_ci+ saveInfoToFile(test,opts); 1813af6ab5fSopenharmony_ci+ 1823af6ab5fSopenharmony_ci+ console.log(mess); 1833af6ab5fSopenharmony_ci+ console.log(`${test.result.message}`); 1843af6ab5fSopenharmony_ci console.log(''); 1853af6ab5fSopenharmony_ci 1863af6ab5fSopenharmony_ci+ writeStatistics(mess, opts); 1873af6ab5fSopenharmony_ci+ 1883af6ab5fSopenharmony_ci+ var tc = xmll.ele("testcase"); 1893af6ab5fSopenharmony_ci+ tc.att("name", test.file); 1903af6ab5fSopenharmony_ci+ var ff = tc.ele("failure"); 1913af6ab5fSopenharmony_ci+ var cd = `error message = ${test.result.message}\nOUT: ${test.result.stdout}\nERR: ${test.result.stderr}` 1923af6ab5fSopenharmony_ci+ ff.cdata(cd) 1933af6ab5fSopenharmony_ci+ 1943af6ab5fSopenharmony_ci if (opts.saveCompiledTests) { 1953af6ab5fSopenharmony_ci test.savedTestPath = saveCompiledTest(test, opts); 1963af6ab5fSopenharmony_ci- process.stdout.write(`Saved compiled failed test as ${test.savedTestPath}\n`); 1973af6ab5fSopenharmony_ci+ // process.stdout.write(`Saved compiled failed test as ${test.savedTestPath}\n`); 1983af6ab5fSopenharmony_ci } 1993af6ab5fSopenharmony_ci+ 2003af6ab5fSopenharmony_ci }); 2013af6ab5fSopenharmony_ci 2023af6ab5fSopenharmony_ci results.on('end', function () { 2033af6ab5fSopenharmony_ci@@ -40,6 +61,11 @@ function simpleReporter(results, opts) { 2043af6ab5fSopenharmony_ci console.log(`Ran ${(passed + failed)} tests`); 2053af6ab5fSopenharmony_ci console.log(`${passed} passed`); 2063af6ab5fSopenharmony_ci console.log(`${failed} failed`); 2073af6ab5fSopenharmony_ci+ 2083af6ab5fSopenharmony_ci+ xmll.att("tests", passed + failed); 2093af6ab5fSopenharmony_ci+ xmll.att("failures", failed); 2103af6ab5fSopenharmony_ci+ 2113af6ab5fSopenharmony_ci+ fs.writeFileSync(path.join(opts.tempDir,"result.xml"), xmll.end({pretty: true})); 2123af6ab5fSopenharmony_ci }); 2133af6ab5fSopenharmony_ci 2143af6ab5fSopenharmony_ci function clearPassed() { 2153af6ab5fSopenharmony_ci@@ -52,6 +78,29 @@ function simpleReporter(results, opts) { 2163af6ab5fSopenharmony_ci } 2173af6ab5fSopenharmony_ci } 2183af6ab5fSopenharmony_ci } 2193af6ab5fSopenharmony_ci+ 2203af6ab5fSopenharmony_ci+ function saveInfoToFile(test,opts){ 2213af6ab5fSopenharmony_ci+ let filePath = test.file; 2223af6ab5fSopenharmony_ci+ let tmps = filePath.split(opts.test262Dir); 2233af6ab5fSopenharmony_ci+ let outFile = path.join(opts.tempDir,tmps[1]); 2243af6ab5fSopenharmony_ci+ let scenario = test.scenario === 'strict mode' ? 'strict' : test.scenario; 2253af6ab5fSopenharmony_ci+ let outcome = 'err'; 2263af6ab5fSopenharmony_ci+ let savedTestPath = path.normalize( 2273af6ab5fSopenharmony_ci+ `${outFile}.${opts.hostType}.${scenario}.${outcome}` 2283af6ab5fSopenharmony_ci+ ); 2293af6ab5fSopenharmony_ci+ fs.writeFileSync(savedTestPath, ` ${test.result.message}`); 2303af6ab5fSopenharmony_ci+ } 2313af6ab5fSopenharmony_ci+ 2323af6ab5fSopenharmony_ci+ function writeStatistics(data, opts) { 2333af6ab5fSopenharmony_ci+ let save_file = path.join(opts.tempDir,"result.txt"); 2343af6ab5fSopenharmony_ci+ fs.appendFile(save_file, data, 'utf8', function(err){ 2353af6ab5fSopenharmony_ci+ if(err) 2363af6ab5fSopenharmony_ci+ { 2373af6ab5fSopenharmony_ci+ console.error(err); 2383af6ab5fSopenharmony_ci+ } 2393af6ab5fSopenharmony_ci+ }); 2403af6ab5fSopenharmony_ci+ } 2413af6ab5fSopenharmony_ci+ 2423af6ab5fSopenharmony_ci } 2433af6ab5fSopenharmony_ci 2443af6ab5fSopenharmony_ci module.exports = simpleReporter; 2453af6ab5fSopenharmony_cidiff --git a/lib/saveCompiledTest.js b/lib/saveCompiledTest.js 2463af6ab5fSopenharmony_ciindex c233adb..7739946 100644 2473af6ab5fSopenharmony_ci--- a/lib/saveCompiledTest.js 2483af6ab5fSopenharmony_ci+++ b/lib/saveCompiledTest.js 2493af6ab5fSopenharmony_ci@@ -6,8 +6,11 @@ const path = require('path'); 2503af6ab5fSopenharmony_ci module.exports = function saveCompiledTest(test, options) { 2513af6ab5fSopenharmony_ci let outcome = test.result.pass ? 'pass' : 'fail'; 2523af6ab5fSopenharmony_ci let scenario = test.scenario === 'strict mode' ? 'strict' : test.scenario; 2533af6ab5fSopenharmony_ci+ let filePath = test.file; 2543af6ab5fSopenharmony_ci+ let tmps = filePath.split(options.test262Dir); 2553af6ab5fSopenharmony_ci+ let outFile = path.join(options.tempDir,tmps[1]); 2563af6ab5fSopenharmony_ci let savedTestPath = path.normalize( 2573af6ab5fSopenharmony_ci- `${test.file}.${options.hostType}.${scenario}.${outcome}` 2583af6ab5fSopenharmony_ci+ `${outFile}.${options.hostType}.${scenario}.${outcome}` 2593af6ab5fSopenharmony_ci ); 2603af6ab5fSopenharmony_ci fs.writeFileSync(savedTestPath, test.compiled); 2613af6ab5fSopenharmony_ci return savedTestPath; 2623af6ab5fSopenharmony_cidiff --git a/lib/validator.js b/lib/validator.js 2633af6ab5fSopenharmony_ciindex e7cb695..d4671a3 100644 2643af6ab5fSopenharmony_ci--- a/lib/validator.js 2653af6ab5fSopenharmony_ci+++ b/lib/validator.js 2663af6ab5fSopenharmony_ci@@ -35,7 +35,7 @@ module.exports = function validate(test) { 2673af6ab5fSopenharmony_ci } else { 2683af6ab5fSopenharmony_ci return { 2693af6ab5fSopenharmony_ci pass: false, 2703af6ab5fSopenharmony_ci- message: `Expected no error, got ${result.error.name}: ${result.error.message}`, 2713af6ab5fSopenharmony_ci+ message: `Expected no error, but got ${result.error.name}: \n ${result.stderr}`, 2723af6ab5fSopenharmony_ci }; 2733af6ab5fSopenharmony_ci } 2743af6ab5fSopenharmony_ci } else if (!ranToFinish && !test.attrs.flags.raw) { 2753af6ab5fSopenharmony_ci@@ -46,7 +46,7 @@ module.exports = function validate(test) { 2763af6ab5fSopenharmony_ci } 2773af6ab5fSopenharmony_ci return { 2783af6ab5fSopenharmony_ci pass: false, 2793af6ab5fSopenharmony_ci- message, 2803af6ab5fSopenharmony_ci+ message: `Expected no error, but got : \n ${result.stderr}`, 2813af6ab5fSopenharmony_ci }; 2823af6ab5fSopenharmony_ci } else { 2833af6ab5fSopenharmony_ci return { 2843af6ab5fSopenharmony_ci@@ -78,7 +78,7 @@ module.exports = function validate(test) { 2853af6ab5fSopenharmony_ci } else { 2863af6ab5fSopenharmony_ci return { 2873af6ab5fSopenharmony_ci pass: false, 2883af6ab5fSopenharmony_ci- message: `Expected test to throw error of type ${test.attrs.negative.type}, got ${result.error.name}: ${result.error.message}`, 2893af6ab5fSopenharmony_ci+ message: `Expected test to throw error of type ${test.attrs.negative.type}, but got ${result.error.name}: \n ${result.stderr}`, 2903af6ab5fSopenharmony_ci }; 2913af6ab5fSopenharmony_ci } 2923af6ab5fSopenharmony_ci } 2933af6ab5fSopenharmony_cidiff --git a/package.json b/package.json 2943af6ab5fSopenharmony_ciindex 60ef715..9e7ef0c 100644 2953af6ab5fSopenharmony_ci--- a/package.json 2963af6ab5fSopenharmony_ci+++ b/package.json 2973af6ab5fSopenharmony_ci@@ -15,11 +15,11 @@ 2983af6ab5fSopenharmony_ci "minimatch": "^3.0.4", 2993af6ab5fSopenharmony_ci "rxjs": "^6.4.0", 3003af6ab5fSopenharmony_ci "test262-stream": "^1.3.0", 3013af6ab5fSopenharmony_ci- "yargs": "^13.2.2" 3023af6ab5fSopenharmony_ci+ "yargs": "^13.2.2", 3033af6ab5fSopenharmony_ci+ "xmlbuilder": "^15.1.1" 3043af6ab5fSopenharmony_ci }, 3053af6ab5fSopenharmony_ci "author": "Brian Terlson", 3063af6ab5fSopenharmony_ci- "license": "BSD-3-Clause", 3073af6ab5fSopenharmony_ci- "files": [ 3083af6ab5fSopenharmony_ci+ "license": "BSD-3-Clause", "files": [ 3093af6ab5fSopenharmony_ci "index.js", 3103af6ab5fSopenharmony_ci "bin", 3113af6ab5fSopenharmony_ci "lib", 312