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

Allow a custom maven command. #27

Merged
merged 1 commit into from
Feb 13, 2024
Merged
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
Expand Up @@ -33,6 +33,7 @@

@Mojo(name = "supertest")
public class SuperTestMavenPlugin extends AbstractMojo {

// this is the max time to wait in seconds for process termination after the stdout read is
// finished or terminated
private static final int STDOUT_POST_READ_WAIT_TIMEOUT = 10;
Expand All @@ -46,6 +47,10 @@ public class SuperTestMavenPlugin extends AbstractMojo {
@Parameter(defaultValue = "${project}", readonly = true)
MavenProject project;


@Parameter(property = "mavenCommand", defaultValue = "mvn", readonly = true)
String mavenCommand = "mvn";

@Parameter(property = "mvnTestOpts", readonly = true)
String mvnTestOpts;

Expand Down Expand Up @@ -97,7 +102,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
getLog().debug("Test classes found: " + String.join(",", allTestClasses));

int exitCode;
final String command = "mvn test " + buildProcessedMvnTestOpts(artifactId, groupId);
final String command =
mavenCommand + " test " + buildProcessedMvnTestOpts(artifactId, groupId);
try {
exitCode = runShellCommand(command, "supertest run#1");
} catch (IOException | InterruptedException e) {
Expand Down Expand Up @@ -329,7 +335,7 @@ public File[] getXmlFileList(File baseDir) {
*/
public String createRerunCommand(
Set<String> allTestClasses, Map<String, List<String>> classnameToTestcaseList) {
final StringBuilder retryRun = new StringBuilder("mvn test");
final StringBuilder retryRun = new StringBuilder(mavenCommand + " test");
Set<String> incompleteTests = new HashSet<>(allTestClasses);

retryRun.append(" -Dtest=");
Expand Down Expand Up @@ -364,8 +370,8 @@ private void appendFailedTestCases(
String className, List<String> failedTestCaseList, StringBuilder retryRun) {
retryRun.append(className);

if (failedTestCaseList.contains("")) {
retryRun.append(",");
if (failedTestCaseList.contains("")) {
retryRun.append(",");
return;
}

Expand Down
Loading