Skip to content

Commit

Permalink
Fix JENKINS-29391 add support to full path in testFiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolas Falco committed Jul 13, 2015
1 parent eb14c5c commit 8b6692c
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/main/java/org/jenkinsci/plugins/MsTestBuilder.java
Expand Up @@ -17,7 +17,9 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

import org.kohsuke.stapler.DataBoundConstructor;
Expand Down Expand Up @@ -187,6 +189,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
}

// Add test containers to command line
Set<String> testContainers = new LinkedHashSet<String>(7);
StringTokenizer testFilesToknzr = new StringTokenizer(testFiles, "\r\n");
while (testFilesToknzr.hasMoreTokens()) {
String testFile = testFilesToknzr.nextToken();
Expand All @@ -195,12 +198,28 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
testFile = Util.fixEmptyAndTrim(testFile);

if (testFile != null) {
for (FilePath testContainerFile : workspace.list(testFile)) {
// TODO make path relative to workspace to reduce length of command line
args.add("/testcontainer:" + testContainerFile);
}
File tcFile = new File(testFile);
if (tcFile.isAbsolute()) {
if (tcFile.isFile() && tcFile.exists()) {
testContainers.add(testFile);
}
} else {
for (FilePath tcFilePath : workspace.list(testFile)) {
// TODO make path relative to workspace to reduce length of command line (see windows max size)
testContainers.add(tcFilePath.getRemote());
}
}
}
}
// nothing of include rule has match files in workspace folder
if (testContainers.isEmpty()) {
listener.fatalError("No test files was found");
return false;
}

for (String testContainer : testContainers) {
args.add("/testcontainer:" + testContainer);
}

try {
int r = launcher.launch().cmds(args).envs(env).stdout(listener).pwd(workspace).join();
Expand Down

0 comments on commit 8b6692c

Please sign in to comment.