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,5 +1,6 @@ 114 'use strict'; 115 const path = require('path'); 116+const fs = require('fs'); 117 const saveCompiledTest = require('../saveCompiledTest'); 118 119 function simpleReporter(results, opts) { 120@@ -12,11 +13,13 @@ function simpleReporter(results, opts) { 121 122 clearPassed(); 123 lastPassed = true; 124- process.stdout.write(`PASS ${test.file}`); 125+ let mess = `PASS ${test.file} (${test.scenario})\n` 126+ console.log(mess); 127+ writeStatistics(mess,opts); 128 129 if (opts.saveCompiledTests && !opts.saveOnlyFailed) { 130 test.savedTestPath = saveCompiledTest(test, opts); 131- process.stdout.write(`\nSaved compiled passed test as ${test.savedTestPath}\n`); 132+ // process.stdout.write(`\nSaved compiled passed test as ${test.savedTestPath}\n`); 133 } 134 }); 135 136@@ -24,14 +27,21 @@ function simpleReporter(results, opts) { 137 failed++; 138 clearPassed(); 139 lastPassed = false; 140- console.log(`FAIL ${test.file} (${test.scenario})`); 141- console.log(` ${test.result.message}`); 142+ 143+ let mess = `FAIL ${test.file} (${test.scenario})\n` 144+ saveInfoToFile(test,opts); 145+ 146+ console.log(mess); 147+ console.log(`${test.result.message}`); 148 console.log(''); 149 150+ writeStatistics(mess,opts); 151+ 152 if (opts.saveCompiledTests) { 153 test.savedTestPath = saveCompiledTest(test, opts); 154- process.stdout.write(`Saved compiled failed test as ${test.savedTestPath}\n`); 155+ // process.stdout.write(`Saved compiled failed test as ${test.savedTestPath}\n`); 156 } 157+ 158 }); 159 160 results.on('end', function () { 161@@ -52,6 +62,29 @@ function simpleReporter(results, opts) { 162 } 163 } 164 } 165+ 166+ function saveInfoToFile(test,opts){ 167+ let filePath = test.file; 168+ let tmps = filePath.split(opts.test262Dir); 169+ let outFile = path.join(opts.tempDir,tmps[1]); 170+ let scenario = test.scenario === 'strict mode' ? 'strict' : test.scenario; 171+ let outcome = 'err'; 172+ let savedTestPath = path.normalize( 173+ `${outFile}.${opts.hostType}.${scenario}.${outcome}` 174+ ); 175+ fs.writeFileSync(savedTestPath, ` ${test.result.message}`); 176+ } 177+ 178+ function writeStatistics(data,opts) { 179+ let save_file = path.join(opts.tempDir,"result.txt"); 180+ fs.appendFile(save_file,data,'utf8',function(err){ 181+ if(err) 182+ { 183+ console.error(err); 184+ } 185+ }); 186+ } 187+ 188 } 189 190 module.exports = simpleReporter; 191diff --git a/lib/saveCompiledTest.js b/lib/saveCompiledTest.js 192index c233adb..7739946 100644 193--- a/lib/saveCompiledTest.js 194+++ b/lib/saveCompiledTest.js 195@@ -6,8 +6,11 @@ const path = require('path'); 196 module.exports = function saveCompiledTest(test, options) { 197 let outcome = test.result.pass ? 'pass' : 'fail'; 198 let scenario = test.scenario === 'strict mode' ? 'strict' : test.scenario; 199+ let filePath = test.file; 200+ let tmps = filePath.split(options.test262Dir); 201+ let outFile = path.join(options.tempDir,tmps[1]); 202 let savedTestPath = path.normalize( 203- `${test.file}.${options.hostType}.${scenario}.${outcome}` 204+ `${outFile}.${options.hostType}.${scenario}.${outcome}` 205 ); 206 fs.writeFileSync(savedTestPath, test.compiled); 207 return savedTestPath; 208diff --git a/lib/validator.js b/lib/validator.js 209index e7cb695..38a113c 100644 210--- a/lib/validator.js 211+++ b/lib/validator.js 212@@ -35,7 +35,7 @@ module.exports = function validate(test) { 213 } else { 214 return { 215 pass: false, 216- message: `Expected no error, got ${result.error.name}: ${result.error.message}`, 217+ message: `Expected no error, but got ${result.error.name}: \n ${result.stderr}`, 218 }; 219 } 220 } else if (!ranToFinish && !test.attrs.flags.raw) { 221@@ -46,7 +46,7 @@ module.exports = function validate(test) { 222 } 223 return { 224 pass: false, 225- message, 226+ message: `Expected no error, but got : \n ${result.stderr}`, 227 }; 228 } else { 229 return { 230@@ -78,9 +78,9 @@ module.exports = function validate(test) { 231 } else { 232 return { 233 pass: false, 234- message: `Expected test to throw error of type ${test.attrs.negative.type}, got ${result.error.name}: ${result.error.message}`, 235+ message: `Expected test to throw error of type ${test.attrs.negative.type}, but got ${result.error.name}: \n ${result.stderr}`, 236 }; 237 } 238 } 239 } 240-}; 241+}; 242\ No newline at end of file 243