-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1323 from hcoles/feature/auto_enable_jvm_assertions
auto set -ea for #1322
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
pitest-entry/src/main/java/org/pitest/mutationtest/autoconfig/EnableAssertions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.pitest.mutationtest.autoconfig; | ||
|
||
import org.pitest.mutationtest.config.ConfigurationUpdater; | ||
import org.pitest.mutationtest.config.ReportOptions; | ||
import org.pitest.plugin.Feature; | ||
import org.pitest.plugin.FeatureSetting; | ||
|
||
import static java.util.Collections.singletonList; | ||
|
||
/** | ||
* Gradle and maven both now automatically set the -ea flag to | ||
* enable assertions when running tests. Pitest must therefore | ||
* do it too. | ||
*/ | ||
public class EnableAssertions implements ConfigurationUpdater { | ||
|
||
@Override | ||
public void updateConfig(FeatureSetting conf, ReportOptions toModify) { | ||
toModify.addChildJVMArgs(singletonList("-ea")); | ||
} | ||
|
||
@Override | ||
public Feature provides() { | ||
return Feature.named("AUTO_ASSERTIONS") | ||
.withOnByDefault(true) | ||
.withDescription(description()); | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "Automatically add -ea to launch args to enable assertions"; | ||
} | ||
|
||
} |
3 changes: 2 additions & 1 deletion
3
.../src/main/resources/META-INF/services/org.pitest.mutationtest.config.ConfigurationUpdater
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
org.pitest.mutationtest.autoconfig.KeepMacOsFocus | ||
org.pitest.mutationtest.autoconfig.AutoSetThreads | ||
org.pitest.mutationtest.autoconfig.AutoSetThreads | ||
org.pitest.mutationtest.autoconfig.EnableAssertions |
28 changes: 28 additions & 0 deletions
28
pitest-entry/src/test/java/org/pitest/mutationtest/autoconfig/EnableAssertionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.pitest.mutationtest.autoconfig; | ||
|
||
import org.junit.Test; | ||
import org.pitest.mutationtest.config.ReportOptions; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class EnableAssertionsTest { | ||
EnableAssertions underTest = new EnableAssertions(); | ||
|
||
@Test | ||
public void addsEAFlag() { | ||
ReportOptions data = new ReportOptions(); | ||
|
||
underTest.updateConfig(null, data); | ||
assertThat(data.getJvmArgs()).contains("-ea"); | ||
} | ||
|
||
@Test | ||
public void featureIsNamedAutoAssertions() { | ||
assertThat(underTest.provides().name()).isEqualTo("auto_assertions"); | ||
} | ||
|
||
@Test | ||
public void featureIsOnByDefault() { | ||
assertThat(underTest.provides().isOnByDefault()).isTrue(); | ||
} | ||
} |