Fix non-system specific path separator
This commit is contained in:
parent
9625db4b62
commit
0f7a7cf090
1 changed files with 32 additions and 9 deletions
|
@ -75,6 +75,19 @@ public class TestNgOperation extends TestOperation<TestNgOperation, List<String>
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildClassPath(String... path) {
|
||||||
|
var classpath = new StringBuilder();
|
||||||
|
for (var p : path) {
|
||||||
|
if (!p.isBlank()) {
|
||||||
|
if (!classpath.isEmpty()) {
|
||||||
|
classpath.append(File.pathSeparator);
|
||||||
|
}
|
||||||
|
classpath.append(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return classpath.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This sets the default maximum number of threads to use for data providers when running tests in parallel.
|
* This sets the default maximum number of threads to use for data providers when running tests in parallel.
|
||||||
* It will only take effect if the parallel mode has been selected (for example,with the
|
* It will only take effect if the parallel mode has been selected (for example,with the
|
||||||
|
@ -202,11 +215,13 @@ public class TestNgOperation extends TestOperation<TestNgOperation, List<String>
|
||||||
|
|
||||||
args.add("-cp");
|
args.add("-cp");
|
||||||
if (testClasspath_.isEmpty()) {
|
if (testClasspath_.isEmpty()) {
|
||||||
args.add(String.format("%s:%s:%s:%s", new File(project_.libTestDirectory(), "*"),
|
args.add(buildClassPath(joinClasspathJar(project_.testClasspathJars()),
|
||||||
new File(project_.libCompileDirectory(), "*"), project_.buildMainDirectory(),
|
joinClasspathJar(project_.compileClasspathJars()),
|
||||||
project_.buildTestDirectory()));
|
joinClasspathJar(project_.providedClasspathJars()),
|
||||||
|
project_.buildMainDirectory().getAbsolutePath(),
|
||||||
|
project_.buildTestDirectory().getAbsolutePath()));
|
||||||
} else {
|
} else {
|
||||||
args.add(String.join(":", testClasspath_));
|
args.add(String.join(File.pathSeparator, testClasspath_));
|
||||||
}
|
}
|
||||||
|
|
||||||
args.add("org.testng.TestNG");
|
args.add("org.testng.TestNG");
|
||||||
|
@ -224,7 +239,7 @@ public class TestNgOperation extends TestOperation<TestNgOperation, List<String>
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
if (LOGGER.isLoggable(Level.SEVERE) && !silent()) {
|
if (LOGGER.isLoggable(Level.SEVERE) && !silent()) {
|
||||||
LOGGER.severe("An IO error occurred while accessing the default testng.xml file: "
|
LOGGER.severe("An IO error occurred while accessing the default testng.xml file: "
|
||||||
+ ioe.getMessage());
|
+ ioe.getMessage());
|
||||||
}
|
}
|
||||||
throw new RuntimeException(ioe);
|
throw new RuntimeException(ioe);
|
||||||
}
|
}
|
||||||
|
@ -372,6 +387,14 @@ public class TestNgOperation extends TestOperation<TestNgOperation, List<String>
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String joinClasspathJar(List<File> jars) {
|
||||||
|
if (!jars.isEmpty()) {
|
||||||
|
return String.join(File.pathSeparator, jars.stream().map(File::getAbsolutePath).toList());
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of {@code .class} files or list of class names implementing {@code ITestListener} or
|
* The list of {@code .class} files or list of class names implementing {@code ITestListener} or
|
||||||
* {@code ISuiteListener}
|
* {@code ISuiteListener}
|
||||||
|
@ -1056,10 +1079,10 @@ public class TestNgOperation extends TestOperation<TestNgOperation, List<String>
|
||||||
var temp = tempFile();
|
var temp = tempFile();
|
||||||
try (var bufWriter = Files.newBufferedWriter(Paths.get(temp.getPath()))) {
|
try (var bufWriter = Files.newBufferedWriter(Paths.get(temp.getPath()))) {
|
||||||
bufWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
bufWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
|
||||||
"<!DOCTYPE suite SYSTEM \"https://testng.org/testng-1.0.dtd\">" +
|
"<!DOCTYPE suite SYSTEM \"https://testng.org/testng-1.0.dtd\">" +
|
||||||
"<suite name=\"bld Default Suite\" verbose=\"2\">" +
|
"<suite name=\"bld Default Suite\" verbose=\"2\">" +
|
||||||
"<test name=\"All Packages\">" +
|
"<test name=\"All Packages\">" +
|
||||||
"<packages>");
|
"<packages>");
|
||||||
for (var p : packages_) {
|
for (var p : packages_) {
|
||||||
bufWriter.write(String.format("<package name=\"%s\"/>", p));
|
bufWriter.write(String.format("<package name=\"%s\"/>", p));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue