From 0f3b77af3af5c277fe01dd7c3522934b821ef602 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 21 Jul 2015 19:06:00 -0400 Subject: [PATCH] Do not append content to tests marked as `raw` --- lib/runner.js | 14 +++++--------- lib/runners/console.js | 8 ++++++-- lib/runners/node-ip.js | 2 ++ lib/runners/node.js | 2 +- lib/runners/nodehost.js | 9 +++++++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/runner.js b/lib/runner.js index 8a36186..c9c07f4 100644 --- a/lib/runner.js +++ b/lib/runner.js @@ -88,6 +88,10 @@ 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) { @@ -95,14 +99,6 @@ Runner.prototype.compile = function(test) { 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) { @@ -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)"; diff --git a/lib/runners/console.js b/lib/runners/console.js index 994840a..f9818af 100644 --- a/lib/runners/console.js +++ b/lib/runners/console.js @@ -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); } @@ -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();' diff --git a/lib/runners/node-ip.js b/lib/runners/node-ip.js index 10de836..6eb01cc 100644 --- a/lib/runners/node-ip.js +++ b/lib/runners/node-ip.js @@ -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); diff --git a/lib/runners/node.js b/lib/runners/node.js index 1b25b5a..b5f924d 100644 --- a/lib/runners/node.js +++ b/lib/runners/node.js @@ -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() { diff --git a/lib/runners/nodehost.js b/lib/runners/nodehost.js index 37f62b4..b90e6b1 100644 --- a/lib/runners/nodehost.js +++ b/lib/runners/nodehost.js @@ -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) { @@ -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); }