зеркало из https://github.com/mozilla/pjs.git
Bug 508128 - Additional diagnostics to report more data about test exceptions. r=waldo a=test-only
--HG-- extra : rebase_source : ececb0215cac3139336a67f429320ea4106e391f
This commit is contained in:
Родитель
5d9f3c0bfc
Коммит
ee2cd851f2
|
@ -293,7 +293,7 @@ function runHttpTests(testArray, done)
|
|||
}
|
||||
catch (e)
|
||||
{
|
||||
do_throw("error running test-completion callback: " + e);
|
||||
do_report_unexpected_exception(e, "running test-completion callback");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -310,9 +310,12 @@ function runHttpTests(testArray, done)
|
|||
{
|
||||
try
|
||||
{
|
||||
do_throw("testArray[" + testIndex + "].initChannel(ch) failed: " + e);
|
||||
do_report_unexpected_exception(e, "testArray[" + testIndex + "].initChannel(ch)");
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
/* swallow and let tests continue */
|
||||
}
|
||||
catch (e) { /* swallow and let tests continue */ }
|
||||
}
|
||||
|
||||
ch.asyncOpen(listener, null);
|
||||
|
@ -341,12 +344,12 @@ function runHttpTests(testArray, done)
|
|||
}
|
||||
catch (e)
|
||||
{
|
||||
do_throw("testArray[" + testIndex + "].onStartRequest: " + e);
|
||||
do_report_unexpected_exception(e, "testArray[" + testIndex + "].onStartRequest");
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
dumpn("!!! swallowing onStartRequest exception so onStopRequest is " +
|
||||
do_note_exception(e, "!!! swallowing onStartRequest exception so onStopRequest is " +
|
||||
"called...");
|
||||
}
|
||||
},
|
||||
|
@ -464,7 +467,7 @@ function runRawTests(testArray, done)
|
|||
}
|
||||
catch (e)
|
||||
{
|
||||
do_throw("error running test-completion callback: " + e);
|
||||
do_report_unexpected_exception(e, "running test-completion callback");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -519,20 +522,31 @@ function runRawTests(testArray, done)
|
|||
{
|
||||
onInputStreamReady: function(stream)
|
||||
{
|
||||
var bis = new BinaryInputStream(stream);
|
||||
|
||||
var av = 0;
|
||||
try
|
||||
{
|
||||
av = bis.available();
|
||||
}
|
||||
catch (e) { /* default to 0 */ }
|
||||
var bis = new BinaryInputStream(stream);
|
||||
|
||||
if (av > 0)
|
||||
var av = 0;
|
||||
try
|
||||
{
|
||||
av = bis.available();
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
/* default to 0 */
|
||||
do_note_exception(e);
|
||||
}
|
||||
|
||||
if (av > 0)
|
||||
{
|
||||
received += String.fromCharCode.apply(null, bis.readByteArray(av));
|
||||
waitForMoreInput(stream);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
received += String.fromCharCode.apply(null, bis.readByteArray(av));
|
||||
waitForMoreInput(stream);
|
||||
return;
|
||||
do_report_unexpected_exception(e);
|
||||
}
|
||||
|
||||
var rawTest = testArray[testIndex];
|
||||
|
@ -542,12 +556,19 @@ function runRawTests(testArray, done)
|
|||
}
|
||||
catch (e)
|
||||
{
|
||||
do_throw("error thrown by responseCheck: " + e);
|
||||
do_report_unexpected_exception(e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
stream.close();
|
||||
performNextTest();
|
||||
try
|
||||
{
|
||||
stream.close();
|
||||
performNextTest();
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
do_report_unexpected_exception(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -568,14 +589,25 @@ function runRawTests(testArray, done)
|
|||
else
|
||||
testArray[testIndex].data[dataIndex] = str.substring(written);
|
||||
}
|
||||
catch (e) { /* stream could have been closed, just ignore */ }
|
||||
catch (e)
|
||||
{
|
||||
do_note_exception(e);
|
||||
/* stream could have been closed, just ignore */
|
||||
}
|
||||
|
||||
// Keep writing data while we can write and
|
||||
// until there's no more data to read
|
||||
if (written > 0 && dataIndex < testArray[testIndex].data.length)
|
||||
waitToWriteOutput(stream);
|
||||
else
|
||||
stream.close();
|
||||
try
|
||||
{
|
||||
// Keep writing data while we can write and
|
||||
// until there's no more data to read
|
||||
if (written > 0 && dataIndex < testArray[testIndex].data.length)
|
||||
waitToWriteOutput(stream);
|
||||
else
|
||||
stream.close();
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
do_report_unexpected_exception(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ TracingListener.prototype = {
|
|||
var newListener = new TracingListener();
|
||||
newListener.listener = request.setNewListener(newListener);
|
||||
} catch(e) {
|
||||
dump("TracingListener.onStartRequest swallowing exception: " + e + "\n");
|
||||
return; // OK
|
||||
}
|
||||
do_throw("replaced channel's listener during onStartRequest.");
|
||||
|
@ -35,21 +36,25 @@ TracingListener.prototype = {
|
|||
dump("*** tracing listener onStopRequest\n");
|
||||
|
||||
do_check_eq(gotOnStartRequest, true);
|
||||
|
||||
var sin = Components.classes["@mozilla.org/scriptableinputstream;1"].
|
||||
createInstance(Ci.nsIScriptableInputStream);
|
||||
|
||||
streamSink.close();
|
||||
var input = pipe.inputStream;
|
||||
sin.init(input);
|
||||
do_check_eq(sin.available(), originalBody.length);
|
||||
try {
|
||||
var sin = Components.classes["@mozilla.org/scriptableinputstream;1"].
|
||||
createInstance(Ci.nsIScriptableInputStream);
|
||||
|
||||
streamSink.close();
|
||||
var input = pipe.inputStream;
|
||||
sin.init(input);
|
||||
do_check_eq(sin.available(), originalBody.length);
|
||||
|
||||
var result = sin.read(originalBody.length);
|
||||
do_check_eq(result, originalBody);
|
||||
var result = sin.read(originalBody.length);
|
||||
do_check_eq(result, originalBody);
|
||||
|
||||
input.close();
|
||||
|
||||
httpserver.stop(do_test_finished);
|
||||
input.close();
|
||||
} catch (e) {
|
||||
dump("TracingListener.onStopRequest swallowing exception: " + e + "\n");
|
||||
} finally {
|
||||
httpserver.stop(do_test_finished);
|
||||
}
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
|
@ -71,10 +76,12 @@ HttpResponseExaminer.prototype = {
|
|||
Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Components.interfaces.nsIObserverService).
|
||||
addObserver(this, "http-on-examine-response", true);
|
||||
dump("Did HttpResponseExaminer.register\n");
|
||||
},
|
||||
|
||||
// Replace channel's listener.
|
||||
observe: function(subject, topic, data) {
|
||||
dump("In HttpResponseExaminer.observe\n");
|
||||
try {
|
||||
subject.QueryInterface(Components.interfaces.nsITraceableChannel);
|
||||
|
||||
|
@ -90,6 +97,7 @@ HttpResponseExaminer.prototype = {
|
|||
} catch(e) {
|
||||
do_throw("can't replace listener " + e);
|
||||
}
|
||||
dump("Did HttpResponseExaminer.observe\n");
|
||||
},
|
||||
|
||||
QueryInterface: function(iid) {
|
||||
|
|
|
@ -427,6 +427,28 @@ function do_throw(text, stack) {
|
|||
throw Components.results.NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
function do_report_unexpected_exception(ex, text) {
|
||||
var caller_stack = Components.stack.caller;
|
||||
text = text ? text + " - " : "";
|
||||
|
||||
_passed = false;
|
||||
dump("TEST-UNEXPECTED-FAIL | " + caller_stack.filename + " | " + text +
|
||||
"Unexpected exception " + ex + ", see following stack:\n" + ex.stack +
|
||||
"\n");
|
||||
|
||||
_do_quit();
|
||||
throw Components.results.NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
function do_note_exception(ex, text) {
|
||||
var caller_stack = Components.stack.caller;
|
||||
text = text ? text + " - " : "";
|
||||
|
||||
dump("TEST-INFO | " + caller_stack.filename + " | " + text +
|
||||
"Swallowed exception " + ex + ", see following stack:\n" + ex.stack +
|
||||
"\n");
|
||||
}
|
||||
|
||||
function do_check_neq(left, right, stack) {
|
||||
if (!stack)
|
||||
stack = Components.stack.caller;
|
||||
|
|
Загрузка…
Ссылка в новой задаче