Skip to content

Commit

Permalink
Fixed a bug in the test harness.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohsuke committed Feb 1, 2011
1 parent d44eef2 commit 45da182
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
File renamed without changes.
20 changes: 10 additions & 10 deletions test/src/main/java/org/jvnet/hudson/test/WarExploder.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static File getExplodedDir() throws Exception {
}

/**
* Explodes hudson.war, if necesasry, and returns its root dir.
* Explodes hudson.war, if necessary, and returns its root dir.
*/
private static File explode() throws Exception {
// are we in the hudson main workspace? If so, pick up hudson/main/war/resources
Expand All @@ -71,15 +71,15 @@ private static File explode() throws Exception {
File d = new File(".").getAbsoluteFile();

// just in case we were started from hudson instead of from hudson/main/...
if (new File(d, "main/war/target/hudson").exists()) {
return new File(d, "main/war/target/hudson");
if (new File(d, "main/war/target/jenkins").exists()) {
return new File(d, "main/war/target/jenkins");
}

for( ; d!=null; d=d.getParentFile()) {
if(new File(d,".hudson").exists()) {
File dir = new File(d,"war/target/hudson");
if(new File(d,".jenkins").exists()) {
File dir = new File(d,"war/target/jenkins");
if(dir.exists()) {
System.out.println("Using hudson.war resources from "+dir);
System.out.println("Using jenkins.war resources from "+dir);
return dir;
}
}
Expand All @@ -89,22 +89,22 @@ private static File explode() throws Exception {
URL winstone = WarExploder.class.getResource("/winstone.jar");
if(winstone==null)
// impossible, since the test harness pulls in hudson.war
throw new AssertionError("hudson.war is not in the classpath.");
throw new AssertionError("jenkins.war is not in the classpath.");
File war = Which.jarFile(Class.forName("executable.Executable"));

File explodeDir = new File("./target/hudson-for-test").getAbsoluteFile();
File explodeDir = new File("./target/jenkins-for-test").getAbsoluteFile();
File timestamp = new File(explodeDir,".timestamp");

if(!timestamp.exists() || (timestamp.lastModified()!=war.lastModified())) {
System.out.println("Exploding hudson.war at "+war);
System.out.println("Exploding jenkins.war at "+war);
new FilePath(explodeDir).deleteRecursive();
new FilePath(war).unzip(new FilePath(explodeDir));
if(!explodeDir.exists()) // this is supposed to be impossible, but I'm investigating HUDSON-2605
throw new IOException("Failed to explode "+war);
new FileOutputStream(timestamp).close();
timestamp.setLastModified(war.lastModified());
} else {
System.out.println("Picking up existing exploded hudson.war at "+explodeDir.getAbsolutePath());
System.out.println("Picking up existing exploded jenkins.war at "+explodeDir.getAbsolutePath());
}

return explodeDir;
Expand Down

0 comments on commit 45da182

Please sign in to comment.