Bug 937370 - Errors loading xpcshell test file may be silently discarded. r=ted

This commit is contained in:
Mark Hammond 2013-11-22 17:36:16 +11:00
parent 23910f3136
commit f6dafe7159
2 changed files with 28 additions and 0 deletions

View File

@ -451,6 +451,12 @@ function _load_files(aFiles) {
diagnostic: _exception_message(e),
source_file: element,
stack: _format_exception_stack(e.stack)});
} catch (e) {
_log("javascript_error",
{_message: "TEST-UNEXPECTED-FAIL | (xpcshell/head.js) | Source file " + element + " contains an error",
diagnostic: _exception_message(e),
source_file: element,
stack: _format_exception_stack(e.stack)});
}
}

View File

@ -160,6 +160,14 @@ LOAD_ERROR_SYNTAX_ERROR = '''
function run_test(
'''
# A test for failure to load a test due to an error other than a syntax error
LOAD_ERROR_OTHER_ERROR = '''
function run_test() {
yield "foo";
return "foo"; // can't use return in a generator!
};
'''
class XPCShellTestsTests(unittest.TestCase):
"""
Yes, these are unit tests for a unit test harness.
@ -678,5 +686,19 @@ tail =
self.assertInLog("test_error.js:3")
self.assertNotInLog("TEST-PASS")
def testDoReportNonSyntaxError(self):
"""
Check that attempting to load a test file containing an error other
than a syntax error generates details of the error in the log
"""
self.writeFile("test_error.js", LOAD_ERROR_OTHER_ERROR)
self.writeManifest(["test_error.js"])
self.assertTestResult(False)
self.assertInLog("TEST-UNEXPECTED-FAIL")
self.assertInLog("Diagnostic: TypeError: generator function run_test returns a value at")
self.assertInLog("test_error.js:4")
self.assertNotInLog("TEST-PASS")
if __name__ == "__main__":
unittest.main()