提交 284771d5 编写于 作者: H huybrechts

added a test for ProcessTreeKiller

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15367 71c3de6d-444a-0410-be80-ed276b4c234a
上级 18591f02
......@@ -119,6 +119,11 @@ THE SOFTWARE.
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<repositories>
......
......@@ -50,6 +50,10 @@ public class ExtractResourceSCM extends NullSCM {
@Override
public boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, File changeLogFile) throws IOException, InterruptedException {
if (workspace.exists()) {
listener.getLogger().println("Deleting existing workspace " + workspace.getRemote());
workspace.deleteRecursive();
}
listener.getLogger().println("Staging "+zip);
workspace.unzipFrom(zip.openStream());
return true;
......
package hudson.util;
import hudson.model.FreeStyleProject;
import hudson.tasks.Maven;
import org.easymock.EasyMock;
import org.jvnet.hudson.test.ExtractResourceSCM;
import org.jvnet.hudson.test.HudsonTestCase;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
public class ProcessTreeKillerTest extends HudsonTestCase {
public void testManualAbortProcess() throws Exception {
ProcessTreeKiller.enabled = true;
FreeStyleProject project = createFreeStyleProject();
// this contains a maven project with a single test that sleeps 5s.
project.setScm(new ExtractResourceSCM(getClass().getResource(
"ProcessTreeKiller-test-project.jar")));
project.getBuildersList().add(new Maven("install", "maven"));
// build the project, wait until tests are running, then cancel.
project.scheduleBuild(0);
Thread.sleep(2000);
project.getLastBuild().doStop(
EasyMock.createNiceMock(StaplerRequest.class),
EasyMock.createNiceMock(StaplerResponse.class));
Thread.sleep(1000);
// will fail (at least on windows) if test process is still running
project.getWorkspace().deleteRecursive();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册