1diff --git a/bin/run.js b/bin/run.js 2index 650f19a..7284fa1 100755 3--- a/bin/run.js 4+++ b/bin/run.js 5@@ -76,6 +76,7 @@ if (argv.prelude) { 6 let hostType; 7 let hostPath; 8 let features; 9+let mode; 10 11 if (argv.hostType) { 12 hostType = argv.hostType; 13@@ -123,6 +124,12 @@ if (argv.features) { 14 features = argv.features.split(',').map(feature => feature.trim()); 15 } 16 17+mode = "only strict mode" 18+ 19+if (argv.mode) { 20+ mode = argv.mode 21+} 22+ 23 // Show help if no arguments provided 24 if (!argv._.length) { 25 cli.showHelp(); 26@@ -130,17 +137,35 @@ if (!argv._.length) { 27 return; 28 } 29 30-// Test Pipeline 31-const pool = new AgentPool( 32- Number(argv.threads), hostType, argv.hostArgs, hostPath, { tempDir, timeout, transform } 33-); 34 35 if (!test262Dir) { 36 test262Dir = test262Finder(argv._[0]); 37 } 38+ 39 reporterOpts.test262Dir = test262Dir; 40+reporterOpts.tempDir = tempDir 41+ 42+// Test Pipeline 43+const pool = new AgentPool( 44+ Number(argv.threads), hostType, argv.hostArgs, hostPath, { tempDir, timeout, transform, test262Dir } 45+); 46 47 const remove = path.relative(process.cwd(), test262Dir); 48+if (argv.isTestListSet) { 49+ let fileName = argv._[0] 50+ if (!fs.existsSync(fileName)){ 51+ if (fileName.startsWith("test262/")) { 52+ fileName = path.join(__dirname, "../../../", fileName) 53+ } else { 54+ fileName = path.join(__dirname, "../../", fileName) 55+ } 56+ } 57+ const data = fs.readFileSync(fileName, "utf8") 58+ argv._ = data 59+ .split("\n") 60+ .map(line => line.trim()) 61+ .filter(line => line.length > 0 && !line.startsWith("#")) 62+} 63 argv._ = argv._.map(p => path.relative(remove, p)); 64 65 let test262Version; 66@@ -166,6 +191,7 @@ if (preprocessor) { 67 tests = tests.pipe(filter(preprocessor)); 68 } 69 70+tests = tests.pipe(filter(operMode)); 71 const results = zip(pool, tests).pipe( 72 flatMap(pair => { 73 return pool.runTest(pair); 74@@ -209,3 +235,11 @@ function hasFeatures(test) { 75 } 76 return features.filter(feature => (test.attrs.features || []).includes(feature)).length > 0; 77 } 78+ 79+function operMode(test) { 80+ test_scenario = test.scenario 81+ if (mode.indexOf(test_scenario) != -1) { 82+ return true; 83+ } 84+ return false; 85+} 86diff --git a/lib/agent-pool.js b/lib/agent-pool.js 87index ad14b84..1b8a184 100644 88--- a/lib/agent-pool.js 89+++ b/lib/agent-pool.js 90@@ -1,6 +1,6 @@ 91 'use strict'; 92 const {Subject} = require('rxjs'); 93-const eshost = require('eshost'); 94+const eshost = require('../../eshost/lib/eshost'); 95 96 const internal = new WeakMap(); 97 98@@ -18,6 +18,7 @@ class AgentPool extends Subject { 99 shortName: '$262', 100 transform: options.transform, 101 out: options.tempDir, 102+ test262Dir: options.test262Dir, 103 }) 104 .then(agent => { 105 this.agents.push(agent); 106diff --git a/lib/cli.js b/lib/cli.js 107index 4a74309..a330271 100644 108--- a/lib/cli.js 109+++ b/lib/cli.js 110@@ -1,4 +1,4 @@ 111-const { supportedHosts } = require("eshost"); 112+const { supportedHosts } = require("./../../eshost/lib/eshost"); 113 const yargs = require('yargs'); 114 const yargv = yargs 115 .strict() 116@@ -22,6 +22,9 @@ const yargv = yargs 117 .nargs('threads', 1) 118 .default('threads', 1) 119 .alias('threads', 't') 120+ .nargs('mode', 1) 121+ .default('mode', 1) 122+ .alias('mode', 'm') 123 .describe('reporter', 'format of data written to standard output') 124 .choices('reporter', ['simple', 'json']) 125 .nargs('reporter', 1) 126@@ -33,6 +36,8 @@ const yargv = yargs 127 .describe('timeout', 'test timeout (in ms, default 10000)') 128 .nargs('timeout', 1) 129 .describe('acceptVersion', 'override for supported Test262 version') 130+ .boolean('isTestListSet') 131+ .describe('isTestListSet', 'Set if positional argument contains test-list file') 132 .boolean('saveCompiledTests') 133 .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') 134 .boolean('saveOnlyFailed') 135diff --git a/lib/reporters/simple.js b/lib/reporters/simple.js 136index 08f9a55..1579861 100644 137--- a/lib/reporters/simple.js 138+++ b/lib/reporters/simple.js 139@@ -1,22 +1,30 @@ 140 'use strict'; 141 const path = require('path'); 142+const fs = require('fs'); 143 const saveCompiledTest = require('../saveCompiledTest'); 144+var xmlbuilder = require('xmlbuilder'); 145 146 function simpleReporter(results, opts) { 147 let passed = 0; 148 let failed = 0; 149 let lastPassed = true; 150+ let xmll = xmlbuilder.create("testsuite"); 151+ xmll.att("name", "Test 262"); 152 153 results.on('pass', function (test) { 154 passed++; 155 156 clearPassed(); 157 lastPassed = true; 158- process.stdout.write(`PASS ${test.file}`); 159+ let mess = `PASS ${test.file} (${test.scenario})\n` 160+ console.log(mess); 161+ writeStatistics(mess, opts); 162+ 163+ xmll.ele("testcase").att("name", test.file); 164 165 if (opts.saveCompiledTests && !opts.saveOnlyFailed) { 166 test.savedTestPath = saveCompiledTest(test, opts); 167- process.stdout.write(`\nSaved compiled passed test as ${test.savedTestPath}\n`); 168+ // process.stdout.write(`\nSaved compiled passed test as ${test.savedTestPath}\n`); 169 } 170 }); 171 172@@ -24,14 +32,27 @@ function simpleReporter(results, opts) { 173 failed++; 174 clearPassed(); 175 lastPassed = false; 176- console.log(`FAIL ${test.file} (${test.scenario})`); 177- console.log(` ${test.result.message}`); 178+ 179+ let mess = `FAIL ${test.file} (${test.scenario})\n` 180+ saveInfoToFile(test,opts); 181+ 182+ console.log(mess); 183+ console.log(`${test.result.message}`); 184 console.log(''); 185 186+ writeStatistics(mess, opts); 187+ 188+ var tc = xmll.ele("testcase"); 189+ tc.att("name", test.file); 190+ var ff = tc.ele("failure"); 191+ var cd = `error message = ${test.result.message}\nOUT: ${test.result.stdout}\nERR: ${test.result.stderr}` 192+ ff.cdata(cd) 193+ 194 if (opts.saveCompiledTests) { 195 test.savedTestPath = saveCompiledTest(test, opts); 196- process.stdout.write(`Saved compiled failed test as ${test.savedTestPath}\n`); 197+ // process.stdout.write(`Saved compiled failed test as ${test.savedTestPath}\n`); 198 } 199+ 200 }); 201 202 results.on('end', function () { 203@@ -40,6 +61,11 @@ function simpleReporter(results, opts) { 204 console.log(`Ran ${(passed + failed)} tests`); 205 console.log(`${passed} passed`); 206 console.log(`${failed} failed`); 207+ 208+ xmll.att("tests", passed + failed); 209+ xmll.att("failures", failed); 210+ 211+ fs.writeFileSync(path.join(opts.tempDir,"result.xml"), xmll.end({pretty: true})); 212 }); 213 214 function clearPassed() { 215@@ -52,6 +78,29 @@ function simpleReporter(results, opts) { 216 } 217 } 218 } 219+ 220+ function saveInfoToFile(test,opts){ 221+ let filePath = test.file; 222+ let tmps = filePath.split(opts.test262Dir); 223+ let outFile = path.join(opts.tempDir,tmps[1]); 224+ let scenario = test.scenario === 'strict mode' ? 'strict' : test.scenario; 225+ let outcome = 'err'; 226+ let savedTestPath = path.normalize( 227+ `${outFile}.${opts.hostType}.${scenario}.${outcome}` 228+ ); 229+ fs.writeFileSync(savedTestPath, ` ${test.result.message}`); 230+ } 231+ 232+ function writeStatistics(data, opts) { 233+ let save_file = path.join(opts.tempDir,"result.txt"); 234+ fs.appendFile(save_file, data, 'utf8', function(err){ 235+ if(err) 236+ { 237+ console.error(err); 238+ } 239+ }); 240+ } 241+ 242 } 243 244 module.exports = simpleReporter; 245diff --git a/lib/saveCompiledTest.js b/lib/saveCompiledTest.js 246index c233adb..7739946 100644 247--- a/lib/saveCompiledTest.js 248+++ b/lib/saveCompiledTest.js 249@@ -6,8 +6,11 @@ const path = require('path'); 250 module.exports = function saveCompiledTest(test, options) { 251 let outcome = test.result.pass ? 'pass' : 'fail'; 252 let scenario = test.scenario === 'strict mode' ? 'strict' : test.scenario; 253+ let filePath = test.file; 254+ let tmps = filePath.split(options.test262Dir); 255+ let outFile = path.join(options.tempDir,tmps[1]); 256 let savedTestPath = path.normalize( 257- `${test.file}.${options.hostType}.${scenario}.${outcome}` 258+ `${outFile}.${options.hostType}.${scenario}.${outcome}` 259 ); 260 fs.writeFileSync(savedTestPath, test.compiled); 261 return savedTestPath; 262diff --git a/lib/validator.js b/lib/validator.js 263index e7cb695..d4671a3 100644 264--- a/lib/validator.js 265+++ b/lib/validator.js 266@@ -35,7 +35,7 @@ module.exports = function validate(test) { 267 } else { 268 return { 269 pass: false, 270- message: `Expected no error, got ${result.error.name}: ${result.error.message}`, 271+ message: `Expected no error, but got ${result.error.name}: \n ${result.stderr}`, 272 }; 273 } 274 } else if (!ranToFinish && !test.attrs.flags.raw) { 275@@ -46,7 +46,7 @@ module.exports = function validate(test) { 276 } 277 return { 278 pass: false, 279- message, 280+ message: `Expected no error, but got : \n ${result.stderr}`, 281 }; 282 } else { 283 return { 284@@ -78,7 +78,7 @@ module.exports = function validate(test) { 285 } else { 286 return { 287 pass: false, 288- message: `Expected test to throw error of type ${test.attrs.negative.type}, got ${result.error.name}: ${result.error.message}`, 289+ message: `Expected test to throw error of type ${test.attrs.negative.type}, but got ${result.error.name}: \n ${result.stderr}`, 290 }; 291 } 292 } 293diff --git a/package.json b/package.json 294index 60ef715..9e7ef0c 100644 295--- a/package.json 296+++ b/package.json 297@@ -15,11 +15,11 @@ 298 "minimatch": "^3.0.4", 299 "rxjs": "^6.4.0", 300 "test262-stream": "^1.3.0", 301- "yargs": "^13.2.2" 302+ "yargs": "^13.2.2", 303+ "xmlbuilder": "^15.1.1" 304 }, 305 "author": "Brian Terlson", 306- "license": "BSD-3-Clause", 307- "files": [ 308+ "license": "BSD-3-Clause", "files": [ 309 "index.js", 310 "bin", 311 "lib", 312