Bug 684783 - Fix intermittent test_errorhandler.js. r=philikon

This commit is contained in:
Richard Newman 2011-09-06 13:09:29 -07:00
parent fd13f63ab7
commit b323e9ae40

View File

@ -1241,7 +1241,7 @@ add_test(function test_sync_engine_generic_fail() {
let engine = Engines.get("catapult");
engine.enabled = true;
engine.sync = function sync() {
Svc.Obs.notify("weave:engine:sync:error", "", "steam");
Svc.Obs.notify("weave:engine:sync:error", "", "catapult");
};
let log = Log4Moz.repository.getLogger("Sync.ErrorHandler");
@ -1250,6 +1250,12 @@ add_test(function test_sync_engine_generic_fail() {
Svc.Obs.add("weave:service:reset-file-log", function onResetFileLog() {
Svc.Obs.remove("weave:service:reset-file-log", onResetFileLog);
// Put these checks here, not after sync(), so that we aren't racing the
// log handler... which resets everything just a few lines below!
_("Status.engines: " + JSON.stringify(Status.engines));
do_check_eq(Status.engines["catapult"], ENGINE_UNKNOWN_FAIL);
do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
// Test Error log was written on SYNC_FAILED_PARTIAL.
let entries = logsdir.directoryEntries;
do_check_true(entries.hasMoreElements());
@ -1263,14 +1269,11 @@ add_test(function test_sync_engine_generic_fail() {
server.stop(run_next_test);
});
do_check_eq(Status.engines["steam"], undefined);
do_check_eq(Status.engines["catapult"], undefined);
do_check_true(setUp());
Service.sync();
do_check_eq(Status.engines["steam"], ENGINE_UNKNOWN_FAIL);
do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
});
// This test should be the last one since it monkeypatches the engine object
@ -1282,7 +1285,7 @@ add_test(function test_engine_applyFailed() {
engine.enabled = true;
delete engine.exception;
engine.sync = function sync() {
Svc.Obs.notify("weave:engine:sync:applied", {newFailed:1}, "steam");
Svc.Obs.notify("weave:engine:sync:applied", {newFailed:1}, "catapult");
};
let log = Log4Moz.repository.getLogger("Sync.ErrorHandler");
@ -1291,6 +1294,9 @@ add_test(function test_engine_applyFailed() {
Svc.Obs.add("weave:service:reset-file-log", function onResetFileLog() {
Svc.Obs.remove("weave:service:reset-file-log", onResetFileLog);
do_check_eq(Status.engines["catapult"], ENGINE_APPLY_FAIL);
do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
// Test Error log was written on SYNC_FAILED_PARTIAL.
let entries = logsdir.directoryEntries;
do_check_true(entries.hasMoreElements());
@ -1304,12 +1310,9 @@ add_test(function test_engine_applyFailed() {
server.stop(run_next_test);
});
do_check_eq(Status.engines["steam"], undefined);
do_check_eq(Status.engines["catapult"], undefined);
do_check_true(setUp());
Service.sync();
do_check_eq(Status.engines["steam"], ENGINE_APPLY_FAIL);
do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
});