Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto set -ea for #1322 #1323

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
}

}
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
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();
}
}
Loading