From 41426c32d78c2e47fbe5800e21a428619df70a49 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sat, 13 Dec 2008 01:31:23 +0000 Subject: [PATCH] [FIXED HUDSON-2694] Detection of the test mode now is done by Java code git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@13546 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/Functions.java | 5 +++++ core/src/main/resources/lib/layout/layout.jelly | 4 ++++ .../main/java/org/jvnet/hudson/test/HudsonTestCase.java | 3 ++- war/resources/scripts/hudson-behavior.js | 9 --------- 4 files changed, 11 insertions(+), 10 deletions(-) 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 = {