Only run assertion checks in DEBUG builds. (Bug 472557) r=Waldo,bsmedberg
authorL. David Baron <dbaron@dbaron.org>
Tue, 13 Jan 2009 11:50:40 -0800
changeset 23625 e2e5ec200b713bd6de48cb641c3045d4f3c6cb08
parent 23624 5254e429712de6bdff5ea36cd3cb6ba8e060a071
child 23626 046f5da25280a44cb0969d6e39e7e245cfe30ce5
push id4643
push userdbaron@mozilla.com
push dateTue, 13 Jan 2009 19:52:06 +0000
treeherdermozilla-central@046f5da25280 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo, bsmedberg
bugs472557
milestone1.9.2a1pre
Only run assertion checks in DEBUG builds. (Bug 472557) r=Waldo,bsmedberg
layout/tools/reftest/reftest.js
xpcom/base/nsDebugImpl.cpp
xpcom/base/nsIDebug2.idl
--- a/layout/tools/reftest/reftest.js
+++ b/layout/tools/reftest/reftest.js
@@ -861,45 +861,47 @@ function FinishTestItem()
     gClearingForAssertionCheck = true;
     gBrowser.loadURI("about:blank");
 }
 
 function DoAssertionCheck()
 {
     gClearingForAssertionCheck = false;
 
-    // TEMPORARILY DISABLING ASSERTION CHECKS FOR NOW.  TO RE-ENABLE,
-    // USE COMMENTED LINE TO REPLACE FOLLOWING ONE.
-    // var newAssertionCount = gDebug.assertionCount;
-    var newAssertionCount = 0;
-    var numAsserts = newAssertionCount - gAssertionCount;
-    gAssertionCount = newAssertionCount;
+    if (gDebug.isDebugBuild) {
+        // TEMPORARILY DISABLING ASSERTION CHECKS FOR NOW.  TO RE-ENABLE,
+        // USE COMMENTED LINE TO REPLACE FOLLOWING ONE.
+        // var newAssertionCount = gDebug.assertionCount;
+        var newAssertionCount = 0;
+        var numAsserts = newAssertionCount - gAssertionCount;
+        gAssertionCount = newAssertionCount;
 
-    var minAsserts = gURLs[0].minAsserts;
-    var maxAsserts = gURLs[0].maxAsserts;
+        var minAsserts = gURLs[0].minAsserts;
+        var maxAsserts = gURLs[0].maxAsserts;
 
-    var expectedAssertions = "expected " + minAsserts;
-    if (minAsserts != maxAsserts) {
-        expectedAssertions += " to " + maxAsserts;
-    }
-    expectedAssertions += " assertions";
+        var expectedAssertions = "expected " + minAsserts;
+        if (minAsserts != maxAsserts) {
+            expectedAssertions += " to " + maxAsserts;
+        }
+        expectedAssertions += " assertions";
 
-    if (numAsserts < minAsserts) {
-        ++gTestResults.AssertionUnexpectedFixed;
-        dump("REFTEST TEST-UNEXPECTED-PASS | " + gURLs[0].prettyPath +
-             " | assertion count " + numAsserts + " is less than " +
-             expectedAssertions + "\n");
-    } else if (numAsserts > maxAsserts) {
-        ++gTestResults.AssertionUnexpected;
-        dump("REFTEST TEST-UNEXPECTED-FAIL | " + gURLs[0].prettyPath +
-             " | assertion count " + numAsserts + " is more than " +
-             expectedAssertions + "\n");
-    } else if (numAsserts != 0) {
-        ++gTestResults.AssertionKnown;
-        dump("REFTEST TEST-KNOWN-FAIL | " + gURLs[0].prettyPath +
-             " | assertion count " + numAsserts + " matches " +
-             expectedAssertions + "\n");
+        if (numAsserts < minAsserts) {
+            ++gTestResults.AssertionUnexpectedFixed;
+            dump("REFTEST TEST-UNEXPECTED-PASS | " + gURLs[0].prettyPath +
+                 " | assertion count " + numAsserts + " is less than " +
+                 expectedAssertions + "\n");
+        } else if (numAsserts > maxAsserts) {
+            ++gTestResults.AssertionUnexpected;
+            dump("REFTEST TEST-UNEXPECTED-FAIL | " + gURLs[0].prettyPath +
+                 " | assertion count " + numAsserts + " is more than " +
+                 expectedAssertions + "\n");
+        } else if (numAsserts != 0) {
+            ++gTestResults.AssertionKnown;
+            dump("REFTEST TEST-KNOWN-FAIL | " + gURLs[0].prettyPath +
+                 " | assertion count " + numAsserts + " matches " +
+                 expectedAssertions + "\n");
+        }
     }
 
     // And start the next test.
     gURLs.shift();
     StartCurrentTest();
 }
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -133,16 +133,27 @@ nsDebugImpl::Break(const char *aFile, PR
 NS_IMETHODIMP
 nsDebugImpl::Abort(const char *aFile, PRInt32 aLine)
 {
   NS_DebugBreak(NS_DEBUG_ABORT, nsnull, nsnull, aFile, aLine);
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsDebugImpl::GetIsDebugBuild(PRBool* aResult)
+{
+#ifdef DEBUG
+  *aResult = PR_TRUE;
+#else
+  *aResult = PR_FALSE;
+#endif
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsDebugImpl::GetAssertionCount(PRInt32* aResult)
 {
   *aResult = gAssertionCount;
   return NS_OK;
 }
 
 /**
  * Implementation of the nsDebug methods. Note that this code is
--- a/xpcom/base/nsIDebug2.idl
+++ b/xpcom/base/nsIDebug2.idl
@@ -34,16 +34,23 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 /* interface to expose information about calls to NS_DebugBreak */
 
 #include "nsIDebug.idl"
 
-[scriptable, uuid(15c0b474-fedb-4789-878b-def834b84735)]
+[scriptable, uuid(9c9307ed-480a-4f2a-8f29-21378c03bcbc)]
 interface nsIDebug2 : nsIDebug
 {
     /**
+     * Whether XPCOM was compiled with DEBUG defined.  This often
+     * correlates to whether other code (e.g., Firefox, XULRunner) was
+     * compiled with DEBUG defined.
+     */
+    readonly attribute boolean isDebugBuild;
+
+    /**
      * The number of assertions since process start.
      */
     readonly attribute long assertionCount;
 };