From f6dafe7159aa64a92074c772d42ecd5380250f9e Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Fri, 22 Nov 2013 17:36:16 +1100 Subject: [PATCH] Bug 937370 - Errors loading xpcshell test file may be silently discarded. r=ted --- testing/xpcshell/head.js | 6 ++++++ testing/xpcshell/selftest.py | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/testing/xpcshell/head.js b/testing/xpcshell/head.js index 6a2a26562a8..e8bd28b4a99 100644 --- a/testing/xpcshell/head.js +++ b/testing/xpcshell/head.js @@ -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)}); } } diff --git a/testing/xpcshell/selftest.py b/testing/xpcshell/selftest.py index 3c67518a9f9..b1e34a54eb0 100644 --- a/testing/xpcshell/selftest.py +++ b/testing/xpcshell/selftest.py @@ -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()