Skip to content

Strip new lines in argLine and debugArgLine parameters #77

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

Merged
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
22 changes: 4 additions & 18 deletions src/main/java/org/scalatest/tools/maven/AbstractScalaTestMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,7 @@
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.cli.*;

import static java.util.Collections.unmodifiableList;
import static org.scalatest.tools.maven.MojoUtils.*;

import java.io.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;

import static java.util.Collections.singletonList;

import java.net.MalformedURLException;
import java.net.URLClassLoader;
import java.net.URL;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
Expand All @@ -29,7 +15,7 @@
import java.util.*;

import static java.util.Collections.singletonList;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static java.util.Collections.unmodifiableList;
import static org.scalatest.tools.maven.MojoUtils.*;

/**
Expand Down Expand Up @@ -294,12 +280,12 @@ private boolean runForkingOnce(String[] args) throws MojoFailureException {

// Set user specified JVM arguments
if (argLine != null) {
cli.createArg().setLine(argLine);
cli.createArg().setLine(stripNewLines(argLine));
}

// Set debugging JVM arguments if debugging is enabled
if (debugForkedProcess) {
cli.createArg().setLine(forkedProcessDebuggingArguments());
cli.createArg().setLine(stripNewLines(forkedProcessDebuggingArguments()));
}

// Set ScalaTest arguments
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/scalatest/tools/maven/MojoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,8 @@ static String getJvm() {
}
return result;
}

static String stripNewLines(String argLine) {
return argLine.replaceAll("[\r\n]{1,2}", " ");
}
}
10 changes: 10 additions & 0 deletions src/test/scala/org/scalatest/tools/maven/PluginTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,14 @@ final class PluginTest
MojoUtils.compoundArg("-a", comma("a", "b", "c")) should be(jlist("-a", "a b c"))
MojoUtils.compoundArg("-a", null.asInstanceOf[String]) should be(jlist())
}

def testMojoStripNewLines {
MojoUtils.stripNewLines("-XmsXg -XmxYg -XX:MaxPermSize=Zm") should be("-XmsXg -XmxYg -XX:MaxPermSize=Zm")
MojoUtils.stripNewLines("-XmsXg\n-XmxYg -XX:MaxPermSize=Zm") should be("-XmsXg -XmxYg -XX:MaxPermSize=Zm")
MojoUtils.stripNewLines("-XmsXg\n-XmxYg") should be("-XmsXg -XmxYg")
MojoUtils.stripNewLines("-XmsXg\r-XmxYg -XX:MaxPermSize=Zm") should be("-XmsXg -XmxYg -XX:MaxPermSize=Zm")
MojoUtils.stripNewLines("-XmsXg\r-XmxYg") should be("-XmsXg -XmxYg")
MojoUtils.stripNewLines("-XmsXg\r\n-XmxYg -XX:MaxPermSize=Zm") should be("-XmsXg -XmxYg -XX:MaxPermSize=Zm")
MojoUtils.stripNewLines("-XmsXg\r\n-XmxYg") should be("-XmsXg -XmxYg")
}
}