Bug 693427 - Intermittent TEST-UNEXPECTED-FAIL | xpcshell/tests/services/sync/tests/unit/test_errorhandler_filelog.js | test failed (with xpcshell return code: 0) | false == true. r=trivial

This commit is contained in:
Richard Newman 2012-10-31 17:07:16 -07:00
parent c728d84af7
commit 66a60c4906

View File

@ -10,7 +10,7 @@ const logsdir = FileUtils.getDir("ProfD", ["weave", "logs"], true);
const LOG_PREFIX_SUCCESS = "success-";
const LOG_PREFIX_ERROR = "error-";
const CLEANUP_DELAY = 1000; // delay to age files for cleanup (ms)
const DELAY_BUFFER = 50; // buffer for timers on different OS platforms
const DELAY_BUFFER = 500; // buffer for timers on different OS platforms
const PROLONGED_ERROR_DURATION =
(Svc.Prefs.get('errorhandler.networkFailureReportTimeout') * 2) * 1000;
@ -248,8 +248,8 @@ add_test(function test_login_error_logOnError_true() {
// Check that error log files are deleted above an age threshold.
add_test(function test_logErrorCleanup_age() {
let maxAge = CLEANUP_DELAY/1000;
let firstlog_name;
_("Beginning test_logErrorCleanup_age.");
let maxAge = CLEANUP_DELAY / 1000;
let oldLogs = [];
let numLogs = 10;
let errString = "some error log\n";
@ -257,13 +257,15 @@ add_test(function test_logErrorCleanup_age() {
Svc.Prefs.set("log.appender.file.logOnError", true);
Svc.Prefs.set("log.appender.file.maxErrorAge", maxAge);
// Make some files.
_("Making some files.");
for (let i = 0; i < numLogs; i++) {
let filename = LOG_PREFIX_ERROR + Date.now() + i + ".txt";
let now = Date.now();
let filename = LOG_PREFIX_ERROR + now + "" + i + ".txt";
let newLog = FileUtils.getFile("ProfD", ["weave", "logs", filename]);
let foStream = FileUtils.openFileOutputStream(newLog);
foStream.write(errString, errString.length);
foStream.close();
_(" > Created " + filename);
oldLogs.push(newLog.leafName);
}
@ -291,7 +293,10 @@ add_test(function test_logErrorCleanup_age() {
run_next_test();
});
let delay = CLEANUP_DELAY + DELAY_BUFFER;
_("Cleaning up logs after " + delay + "msec.");
CommonUtils.namedTimer(function onTimer() {
Svc.Obs.notify("weave:service:sync:error");
}, CLEANUP_DELAY + DELAY_BUFFER, this, "cleanup-timer");
}, delay, this, "cleanup-timer");
});