Skip to content

Commit

Permalink
Use temp module to create temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
bterlson committed Aug 17, 2015
1 parent 8a3c02d commit 498d9d8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
3 changes: 1 addition & 2 deletions bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ function getFilesStream(config) {
}

return p;
})

});

files = _(files.map(globStream)).merge();

Expand Down
55 changes: 28 additions & 27 deletions lib/runners/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = ConsoleRunner;
var Runner = require('../runner');
var fs = require('fs');
var cp = require('child_process');
var counter = 0;
var temp = require('temp');

var batchDoneFn = function $DONE(err) {
if(err) {
Expand Down Expand Up @@ -91,7 +91,7 @@ Object.defineProperty(ConsoleRunner.prototype, 'runNextFn', {

ConsoleRunner.prototype.execute = function(test, cb) {
var runner = this;
var file = '__tmp' + counter++ + '.js';
var file = temp.path({suffix: '.js'});

var command = this.command + ' ' + file;

Expand All @@ -113,7 +113,7 @@ ConsoleRunner.prototype.execute = function(test, cb) {

ConsoleRunner.prototype.executeBatch = function(batch, batchDone) {
var runner = this;
var scriptFile = '__tmp' + counter++ + '.js';
var scriptFile = temp.path({suffix: '.js'});
var script = this.logFnSrc + '\n' +
batchDoneFn + '\n' +
'var $setRealmValue = ' + this._setRealmValue + ';\n' +
Expand All @@ -125,31 +125,32 @@ ConsoleRunner.prototype.executeBatch = function(batch, batchDone) {

script += 'runNext();'

fs.writeFileSync(scriptFile, script);

cp.exec(this.command + " " + scriptFile, function(err, stdout, stderr) {
var results = { log: [] };
var lines = stdout.split(/\r?\n/);
var index = 0;

lines.forEach(function(line) {
switch(line) {
case 'test262/test-start':
break;
case 'test262/test-end':
var test = batch[index++];
runner.validateResult(test, results);
results = { log: [] };

break;
default:
results.log.push(line);
}
})
fs.writeFile(scriptFile, script, function(err) {
cp.exec(runner.command + " " + scriptFile, function(err, stdout, stderr) {
var results = { log: [] };
var lines = stdout.split(/\r?\n/);
var index = 0;

lines.forEach(function(line) {
switch(line) {
case 'test262/test-start':
break;
case 'test262/test-end':
var test = batch[index++];
runner.validateResult(test, results);
results = { log: [] };

break;
default:
results.log.push(line);
}
})

fs.unlink(scriptFile);
batchDone();
});
})

fs.unlink(scriptFile);
batchDone();
});
}


Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"minimist": "^0.2.0",
"stream-bifurcate": "^1.0.0",
"tap": "~0.4.11",
"temp": "^0.8.1",
"test262-parser": "^2.0.5",
"through": "~2.3.4"
},
Expand Down

0 comments on commit 498d9d8

Please sign in to comment.