Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
bterlson committed Sep 24, 2015
2 parents 6fef5a0 + 3191698 commit ff0670b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
24 changes: 11 additions & 13 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ var errorLogRe = /^test262\/error (.*)$/;
// errorStack: stack trace of error thrown (used for debugging purposes)
Runner.prototype.validateResult = function(test, result) {
var expectingStack = false;
var isNegative = test.attrs.flags.negative || test.attrs.negative;
var negative = test.attrs.negative;
// parse result from log
(result.log || []).forEach(function(log) {
var errorMatch = log.match(errorLogRe);
Expand Down Expand Up @@ -203,17 +203,13 @@ Runner.prototype.validateResult = function(test, result) {
test.errorMessage = result.errorMessage;
test.errorStack = result.errorStack;

if(isNegative) {
if(test.attrs.negative) {
// failure can either match against error name, or an exact match
// against error message (the latter case is thus far only to support
// NotEarlyError thrown errors which have an error type of "Error").
test.pass =
!!result.errorName.match(new RegExp(test.attrs.negative)) ||
result.errorMessage === test.attrs.negative;
} else {
test.pass = true
}
if(negative) {
// failure can either match against error name, or an exact match
// against error message (the latter case is thus far only to support
// NotEarlyError thrown errors which have an error type of "Error").
test.pass =
!!result.errorName.match(new RegExp(negative)) ||
result.errorMessage === negative;
} else {
test.pass = false
}
Expand All @@ -223,8 +219,10 @@ Runner.prototype.validateResult = function(test, result) {
test.pass = false;
test.errorName = "Test262 Error";
test.errorMessage = "Test did not run to completion ($DONE not called)";
} else if(isNegative) {
} else if(negative) {
test.pass = false;
test.errorName = "Error Expected";
test.errorMessage = "'" + negative + "' is expected, but was not thrown";
} else {
test.pass = true;
}
Expand Down
13 changes: 8 additions & 5 deletions lib/simpleReporter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var through = require('through');
var readline = require('readline');
var util = require('util');
var path = require('path');

var state = {
Expand Down Expand Up @@ -35,8 +34,10 @@ function actualString(test) {
}

module.exports = through(function(data) {
process.stdout.clearLine();
process.stdout.cursorTo(0);
if (process.stdout.clearLine && process.stdout.cursorTo) {
process.stdout.clearLine();
process.stdout.cursorTo(0);
}

if(data.pass) {
state.pass++;
Expand All @@ -50,8 +51,10 @@ module.exports = through(function(data) {
" Got: " + actualString(data) + "\n\n");
}
}, function() {
process.stdout.clearLine();
process.stdout.cursorTo(0);
if (process.stdout.clearLine && process.stdout.cursorTo) {
process.stdout.clearLine();
process.stdout.cursorTo(0);
}
console.log("Ran " + (state.pass + state.fail) + " tests")
console.log(state.pass + " passed")
console.log(state.fail + " failed")
Expand Down
4 changes: 4 additions & 0 deletions test/collateral/negativeMessage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*---
description: Should report the expected error indicated by the "negative" frontmatter
negative: ExpectedError
---*/
2 changes: 2 additions & 0 deletions test/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var all = [
{ file: 'test/collateral/error.js', strictMode: true, pass: false, errorMessage: 'failure message', errorName: 'Test262Error' },
{ file: 'test/collateral/thrownError.js', strictMode: false, pass: false, errorMessage: 'failure message', errorName: 'Error', topOfStack: "foo" },
{ file: 'test/collateral/thrownError.js', strictMode: true, pass: false, errorMessage: 'failure message', errorName: 'Error', topOfStack: "foo" },
{ file: 'test/collateral/negativeMessage.js', strictMode: false, pass: false, errorMessage: "'ExpectedError' is expected, but was not thrown", errorName: 'Error Expected'},
{ file: 'test/collateral/negativeMessage.js', strictMode: true, pass: false, errorMessage: "'ExpectedError' is expected, but was not thrown", errorName: 'Error Expected'},
]

var seen = {};
Expand Down

0 comments on commit ff0670b

Please sign in to comment.