Bug 1045421 - Remove date time bomb from test_crash_manager.js, add logging. r=gfritzsche, a=test-only
authorGregory Szorc <gps@mozilla.com>
Tue, 29 Jul 2014 09:47:59 -0700
changeset 208256 ac0afa7b1b25
parent 208255 ee74d30a8968
child 208257 8375886783f2
push id3791
push userryanvm@gmail.com
push date2014-08-07 16:00 +0000
treeherdermozilla-beta@ac0afa7b1b25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche, test-only
bugs1045421
milestone32.0
Bug 1045421 - Remove date time bomb from test_crash_manager.js, add logging. r=gfritzsche, a=test-only 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]