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

[FIXED JENKINS-4409] Use a fixed directory for TestPluginManager. #780

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions test/src/main/java/org/jvnet/hudson/test/TestPluginManager.java
Expand Up @@ -57,7 +57,12 @@ public class TestPluginManager extends PluginManager {

private TestPluginManager() throws IOException {
// TestPluginManager outlives a Jetty server, so can't pass in ServletContext.
super(null, Util.createTempDir());
this(Util.createTempDir());
}

private TestPluginManager(File dir) throws IOException {
// TestPluginManager outlives a Jetty server, so can't pass in ServletContext.
super(null, dir);
}

@Override
Expand Down Expand Up @@ -123,7 +128,14 @@ public void stop() {

static {
try {
INSTANCE = new TestPluginManager();
File rootDir = new File("./target/plugin-manager-for-test").getAbsoluteFile();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No good, this will behave differently depending on the CWD in effect when the test is run, which could be anything.

if(rootDir.exists()) {
// Cleanup rootDir if already exists.
// It is created in the last test execution and contains old plugins.
// This often happens in Windows.
Util.deleteRecursive(rootDir);
}
INSTANCE = new TestPluginManager(rootDir);
Runtime.getRuntime().addShutdownHook(new Thread("delete " + INSTANCE.rootDir) {
@Override public void run() {
try {
Expand Down