Bug 1045421 - Remove date time bomb from test_crash_manager.js, add logging; r=gfritzsche
authorGregory Szorc <gps@mozilla.com>
Tue, 29 Jul 2014 09:47:59 -0700
changeset 198094 d5387e9486f1396b7381014cf5c2f8f565fd1d63
parent 198093 d1adfecad34e1eb80c0624aaadc0928dedad27a4
child 198095 353e97284fd0ea7d9a3b7b4741ee3cfc51ccaa5e
push id27261
push userryanvm@gmail.com
push dateWed, 06 Aug 2014 20:45:24 +0000
treeherdermozilla-central@a31cd48facbf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1045421
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1045421 - Remove date time bomb from test_crash_manager.js, add logging; r=gfritzsche There was a hard-coded date in test_crash_manager.js of around August 3, 2013. This meant that about a year later we would start to run into boundary issues since we weren't wrapping Date.now() inside CrashManager.jsm. It turns out the actual value of DUMMY_DATE doesn't really matter. So, the test has been changed to produce a value that is reasonably modern. While I was debugging this, I noticed we're not getting logging in the tests. So I added that.
toolkit/components/crashes/CrashManagerTest.jsm
toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
toolkit/components/crashes/tests/xpcshell/xpcshell.ini
--- a/toolkit/components/crashes/CrashManagerTest.jsm
+++ b/toolkit/components/crashes/CrashManagerTest.jsm
@@ -7,27 +7,44 @@
  * testing of the Crashes component (CrashManager.jsm).
  */
 
 "use strict";
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 this.EXPORTED_SYMBOLS = [
+  "configureLogging",
   "getManager",
   "sleep",
   "TestingCrashManager",
 ];
 
 Cu.import("resource://gre/modules/CrashManager.jsm", this);
+Cu.import("resource://gre/modules/Log.jsm", this);
 Cu.import("resource://gre/modules/osfile.jsm", this);
 Cu.import("resource://gre/modules/Promise.jsm", this);
 Cu.import("resource://gre/modules/Task.jsm", this);
 Cu.import("resource://gre/modules/Timer.jsm", this);
 
+let loggingConfigured = false;
+
+this.configureLogging = function () {
+  if (loggingConfigured) {
+    return;
+  }
+
+  let log = Log.repository.getLogger("Crashes.CrashManager");
+  log.level = Log.Level.All;
+  let appender = new Log.DumpAppender();
+  appender.level = Log.Level.All;
+  log.addAppender(appender);
+  loggingConfigured = true;
+};
+
 this.sleep = function (wait) {
   let deferred = Promise.defer();
 
   setTimeout(() => {
     deferred.resolve();
   }, wait);
 
   return deferred.promise;
--- a/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
+++ b/toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
@@ -7,20 +7,22 @@ const {classes: Cc, interfaces: Ci, util
 
 let bsp = Cu.import("resource://gre/modules/CrashManager.jsm", this);
 Cu.import("resource://gre/modules/Promise.jsm", this);
 Cu.import("resource://gre/modules/Task.jsm", this);
 Cu.import("resource://gre/modules/osfile.jsm", this);
 
 Cu.import("resource://testing-common/CrashManagerTest.jsm", this);
 
-const DUMMY_DATE = new Date(1391043519000);
+const DUMMY_DATE = new Date(Date.now() - 10 * 24 * 60 * 60 * 1000);
+DUMMY_DATE.setMilliseconds(0);
 
 function run_test() {
   do_get_profile();
+  configureLogging();
   run_next_test();
 }
 
 add_task(function* test_constructor_ok() {
   let m = new CrashManager({
     pendingDumpsDir: "/foo",
     submittedDumpsDir: "/bar",
     eventsDirs: [],
--- a/toolkit/components/crashes/tests/xpcshell/xpcshell.ini
+++ b/toolkit/components/crashes/tests/xpcshell/xpcshell.ini
@@ -1,8 +1,7 @@
 [DEFAULT]
 head =
 tail =
 
 [test_crash_manager.js]
-skip-if = true # Bug 1045421
 [test_crash_service.js]
 [test_crash_store.js]