Skip to content

Commit

Permalink
Do not append content to tests marked as raw
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike committed Jul 21, 2015
1 parent 7e0b66d commit 0f3b77a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
14 changes: 5 additions & 9 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,17 @@ Runner.prototype.errorFnSrc = function $ERROR(err) {
}.toString();

Runner.prototype.compile = function(test) {
if (test.attrs.flags.raw) {
return;
}

// add call to $DONE at the bottom of the test file if it's not
// present.
if(test.contents.indexOf("$DONE") === -1) {
// lead with a semicolon to prevent ASI nonsense.
test.contents += "\n;$DONE();\n"
}

if (test.attrs.flags.raw) {
if (this.needsCtrlFlow) {
test.contents += "\n;" + this._ctrlFlowSrc;
}

return;
}

test.contents = this._errorSrc + "\n;" + test.contents;

if (this.needsCtrlFlow) {
Expand Down Expand Up @@ -223,7 +219,7 @@ Runner.prototype.validateResult = function(test, result) {
}
} else {
// ensure $DONE was called if there wasn't an error reported
if(!result.doneCalled) {
if(!result.doneCalled && !test.attrs.flags.raw) {
test.pass = false;
test.errorName = "Test262 Error";
test.errorMessage = "Test did not run to completion ($DONE not called)";
Expand Down
8 changes: 6 additions & 2 deletions lib/runners/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ Object.defineProperty(ConsoleRunner.prototype, 'runNextFn', {
if(!this._runBatched) throw "Don't know how to run a batched tests";

var runNextFn = function runNext() {
var test = tests.shift();
var testInfo = tests.shift();
var test = testInfo.contents;
var env = $1;
$setRealmValue(env, "$DONE", $DONE);

try {
$LOG('test262/test-start')
$2;
if (testInfo.attrs.flags.raw) {
$DONE();
}
} catch(e) {
$DONE(e);
}
Expand Down Expand Up @@ -116,7 +120,7 @@ ConsoleRunner.prototype.executeBatch = function(batch, batchDone) {
this.runNextFn + '\n';

script += 'var tests = ' + JSON.stringify(batch.map(function(test, i) {
return test.contents
return test
})).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029") + '\n';

script += 'runNext();'
Expand Down
2 changes: 2 additions & 0 deletions lib/runners/node-ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ NodeRunner.prototype.execute = function(test, cb) {
result.errorName = "Error";
result.errorMessage = error;
}
} else if (test.attrs.flags.raw) {
context.$DONE();
}

this.validateResult(test, result);
Expand Down
2 changes: 1 addition & 1 deletion lib/runners/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ NodeRunner.prototype = Object.create(ConsoleRunner.prototype);
NodeRunner.prototype.execute = function(test, cb) {
this._test = test;
this._testDone = cb;
this._instance.stdin.write(test.contents);
this._instance.stdin.write(JSON.stringify(test));
}

NodeRunner.prototype.end = function() {
Expand Down
9 changes: 7 additions & 2 deletions lib/runners/nodehost.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var vm = require('vm');

process.stdin.resume();
process.stdin.on('data', function(test) {
process.stdin.on('data', function(testJSON) {
var test = JSON.parse(testJSON);
var result = { log: [] }
var context = {
$DONE: function(error) {
Expand All @@ -25,7 +26,11 @@ process.stdin.on('data', function(test) {
};

try {
vm.runInNewContext(test, context, {displayErrors: false});
vm.runInNewContext(test.contents, context, {displayErrors: false});

if (test.attrs.flags.raw) {
context.$DONE();
}
} catch(e) {
context.$DONE(e);
}
Expand Down

0 comments on commit 0f3b77a

Please sign in to comment.