Skip to content

Apache Lucene open-source search software

LUCENE-3506: (take 2): -Dtests.asserts.gracious=true test framework will not validate java assertions are enabled.

Doron Cohen068d7ca7dcb8
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index ec32cd53acc..a030238e67f 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -731,7 +731,8 @@ Test Cases
* LUCENE-3506: tests relying on assertions being enabled were no-op because
they ignored AssertionError. With this fix now entire test framework
- (all tests) fail if assertions are disabled. (Doron Cohen)
+ (every test) fails if assertions are disabled, unless
+ -Dtests.asserts.gracious=true is specified. (Doron Cohen)
======================= Lucene 3.4.0 =======================
diff --git a/lucene/common-build.xml b/lucene/common-build.xml
index eee39cb525d..b897056e932 100644
--- a/lucene/common-build.xml
+++ b/lucene/common-build.xml
@@ -95,6 +95,7 @@
<property name="tests.loggingfile" value="/dev/null"/>
<property name="tests.nightly" value="false" />
<property name="tests.cleanthreads.sysprop" value="perMethod"/>
+ <property name="tests.asserts.gracious" value="false"/>
<property name="javac.deprecation" value="off"/>
<property name="javac.debug" value="on"/>
@@ -575,6 +576,9 @@
<sysproperty key="java.util.logging.config.file" value="${tests.loggingfile}"/>
<!-- set whether or not nightly tests should run -->
<sysproperty key="tests.nightly" value="@{tests.nightly}"/>
+
+ <!-- set whether tests framework should not require java assertions enabled -->
+ <sysproperty key="tests.asserts.gracious" value="${tests.asserts.gracious}"/>
<!-- TODO: create propertyset for test properties, so each project can have its own set -->
<sysproperty key="tests.multiplier" value="@{tests.multiplier}"/>
diff --git a/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java b/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
index 5fe5c7bfbb4..826e1659323 100644
--- a/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
+++ b/lucene/src/test-framework/org/apache/lucene/util/LuceneTestCase.java
@@ -402,7 +402,9 @@ public abstract class LuceneTestCase extends Assert {
testsFailed = false;
// verify assertions are enabled (do last, for smooth cleanup)
- assertTrue("assertions are not enabled!", assertionsEnabled());
+ if (!Boolean.parseBoolean(System.getProperty("tests.asserts.gracious", "false"))) {
+ assertTrue("assertions are not enabled!", assertionsEnabled());
+ }
}
@AfterClass