mirror of https://github.com/tc39/test262.git
harness: remove unused code
sta.js: slight change to Test262Error() semantics; message property now always set (default "") make $ERROR a var set $ERROR to function $ERROR so it can be overridden if needed remove 2009 copyright in favor of 2012 copyright REVERTED: remove never-used fn testFailed testFailed actually used by $FAIL remove obsolete fn $INCLUDE ed.js: remove commented-out obsolete code test262.py: remove always-included harness file that provides no functions used by any extant test add comment line to nonstrict cth.js: define `print` for node, cscript use cth (console test harness) to define functions for console runner. V8, Spidermonkey (js) and JavaScriptCore (jsc) provide a function `print`. Provide a default `print` for node and cscript set print_handle to 'print' by default (can still override) for cscript: wrap tests in try/catch so we get syntax errors
This commit is contained in:
parent
479a6dd442
commit
4205a1da64
|
@ -10,6 +10,30 @@ function testRun(id, path, description, codeString, result, error) {
|
|||
}
|
||||
}
|
||||
|
||||
function testFinished() {
|
||||
//no-op
|
||||
}
|
||||
// define a default `print` function for async tests where there is no
|
||||
// global `print`
|
||||
var print;
|
||||
|
||||
// in node use console.log
|
||||
if (typeof console === "object") {
|
||||
print = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
console.log(args.join(" "));
|
||||
};
|
||||
}
|
||||
|
||||
// in WScript, use WScript.Echo
|
||||
if (typeof WScript === "object") {
|
||||
print = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
WScript.Echo(args.join(" "));
|
||||
};
|
||||
|
||||
// also override $ERROR to force a nonzero exit code exit
|
||||
// TODO? report syntax errors
|
||||
var oldError = $ERROR;
|
||||
$ERROR = function (message) {
|
||||
print("Test262 Error: " + message);
|
||||
WScript.Quit(1);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -12,20 +12,3 @@ if (this.window!==undefined) { //for console support
|
|||
};
|
||||
}
|
||||
|
||||
//This doesn't work with early errors in current versions of Opera
|
||||
/*
|
||||
if (/opera/i.test(navigator.userAgent)) {
|
||||
(function() {
|
||||
var origError = window.Error;
|
||||
window.Error = function() {
|
||||
if (arguments.length>0) {
|
||||
try {
|
||||
window.onerror(arguments[0]);
|
||||
} catch(e) {
|
||||
alert("Failed to invoke window.onerror (from ed.js)");
|
||||
}
|
||||
}
|
||||
return origError.apply(this, arguments);
|
||||
}
|
||||
})();
|
||||
}*/
|
|
@ -4,31 +4,23 @@
|
|||
/// "Use Terms"). Any redistribution of this code must retain the above
|
||||
/// copyright and this notice and otherwise comply with the Use Terms.
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
var NotEarlyErrorString = "NotEarlyError";
|
||||
var EarlyErrorRePat = "^((?!" + NotEarlyErrorString + ").)*$";
|
||||
var NotEarlyError = new Error(NotEarlyErrorString);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright 2009 the Sputnik authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
function Test262Error(message) {
|
||||
if (message) this.message = message;
|
||||
this.message = message || "";
|
||||
}
|
||||
|
||||
Test262Error.prototype.toString = function () {
|
||||
return "Test262 Error: " + this.message;
|
||||
};
|
||||
|
||||
function testFailed(message) {
|
||||
var $ERROR;
|
||||
$ERROR = function $ERROR(message) {
|
||||
throw new Test262Error(message);
|
||||
}
|
||||
};
|
||||
|
||||
function $INCLUDE(message) { }
|
||||
function $ERROR(message) {
|
||||
testFailed(message);
|
||||
function testFailed(message) {
|
||||
$ERROR(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ def BuildOptions():
|
|||
result.add_option("--junitname", help="Filename to save test results in JUnit XML format")
|
||||
result.add_option("--loglevel", default="warning",
|
||||
help="sets log level to debug, info, warning, error, or critical")
|
||||
result.add_option("--print-handle", default="", help="Command to print from console")
|
||||
result.add_option("--print-handle", default="print", help="Command to print from console")
|
||||
result.add_option("--list-includes", default=False, action="store_true",
|
||||
help="List includes required by tests")
|
||||
return result
|
||||
|
@ -261,11 +261,22 @@ class TestCase(object):
|
|||
def GetAdditionalIncludes(self):
|
||||
return '\n'.join([self.suite.GetInclude(include) for include in self.GetIncludeList()])
|
||||
|
||||
def GetSource(self):
|
||||
def WrapTest(self, command):
|
||||
if "cscript" not in command:
|
||||
return self.test
|
||||
|
||||
return """
|
||||
try {
|
||||
""" + self.test + """
|
||||
} catch(e) {
|
||||
$ERROR(e.message);
|
||||
}
|
||||
"""
|
||||
|
||||
def GetSource(self, command_template):
|
||||
# "var testDescrip = " + str(self.testRecord) + ';\n\n' + \
|
||||
source = self.suite.GetInclude("cth.js") + \
|
||||
self.suite.GetInclude("sta.js") + \
|
||||
self.suite.GetInclude("ed.js")
|
||||
source = self.suite.GetInclude("sta.js") + \
|
||||
self.suite.GetInclude("cth.js")
|
||||
|
||||
if self.IsAsyncTest():
|
||||
source = source + \
|
||||
|
@ -274,12 +285,14 @@ class TestCase(object):
|
|||
|
||||
source = source + \
|
||||
self.GetAdditionalIncludes() + \
|
||||
self.test + '\n'
|
||||
self.WrapTest(command_template) + '\n'
|
||||
|
||||
if self.strict_mode:
|
||||
source = '"use strict";\nvar strict_mode = true;\n' + source
|
||||
else:
|
||||
source = "var strict_mode = false; \n" + source
|
||||
# add comment line so line numbers match in both strict and non-strict version
|
||||
source = '//"no strict";\nvar strict_mode = false;\n' + source
|
||||
|
||||
return source
|
||||
|
||||
def InstantiateTemplate(self, template, params):
|
||||
|
@ -312,7 +325,7 @@ class TestCase(object):
|
|||
return (code, out, err)
|
||||
|
||||
def RunTestIn(self, command_template, tmp):
|
||||
tmp.Write(self.GetSource())
|
||||
tmp.Write(self.GetSource(command_template))
|
||||
tmp.Close()
|
||||
command = self.InstantiateTemplate(command_template, {
|
||||
'path': tmp.name
|
||||
|
@ -329,7 +342,7 @@ class TestCase(object):
|
|||
return result
|
||||
|
||||
def Print(self):
|
||||
print self.GetSource()
|
||||
print self.GetSource("")
|
||||
|
||||
|
||||
class ProgressIndicator(object):
|
||||
|
|
Loading…
Reference in New Issue