diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index f0523fb29f..5642d37c9d 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -946,4 +946,9 @@ public class Functions { } private static final Pattern SCHEME = Pattern.compile("[a-z]+://.+"); + + /** + * Set to true if we are running unit tests. + */ + public static boolean isUnitTest = false; } diff --git a/core/src/main/resources/lib/layout/layout.jelly b/core/src/main/resources/lib/layout/layout.jelly index 503ec26e22..e3ee8fc6dd 100644 --- a/core/src/main/resources/lib/layout/layout.jelly +++ b/core/src/main/resources/lib/layout/layout.jelly @@ -40,6 +40,10 @@ + + + + diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index bff6d48e89..563f15d979 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -27,6 +27,7 @@ import hudson.util.StreamTaskListener; import hudson.util.ProcessTreeKiller; import hudson.maven.MavenModuleSet; import hudson.FilePath; +import hudson.Functions; import junit.framework.TestCase; import org.jvnet.hudson.test.HudsonHomeLoader.CopyExisting; import org.jvnet.hudson.test.recipes.Recipe; @@ -529,7 +530,7 @@ public abstract class HudsonTestCase extends TestCase { Logger.getLogger("org.springframework").setLevel(Level.WARNING); // hudson-behavior.js relies on this to decide whether it's running unit tests. - System.setProperty("hudson.unitTest","true"); + Functions.isUnitTest = true; } private static final Logger LOGGER = Logger.getLogger(HudsonTestCase.class.getName()); diff --git a/war/resources/scripts/hudson-behavior.js b/war/resources/scripts/hudson-behavior.js index 579b4dca51..4351de8338 100644 --- a/war/resources/scripts/hudson-behavior.js +++ b/war/resources/scripts/hudson-behavior.js @@ -14,15 +14,6 @@ function object(o) { // id generator var iota = 0; -// are we run as unit tests? -var isRunAsTest = (function() { - try { - return Packages.java.lang.System.getProperty("hudson.unitTest")!=null; - } catch(e) { - return false; - } -})(); - // Form check code //======================================================== var FormChecker = {