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