From 3edd36e40dd778f5f07dde9a2e36542e4ae0f309 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Tue, 2 Sep 2008 21:34:47 +0000 Subject: [PATCH] addded a variable to test if Hudson is being unit tested or not. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11965 71c3de6d-444a-0410-be80-ed276b4c234a --- .../java/org/jvnet/hudson/test/HudsonTestCase.java | 3 +++ war/resources/scripts/hudson-behavior.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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 cae106190e..09707d6a37 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -381,6 +381,9 @@ public abstract class HudsonTestCase extends TestCase { // suppress INFO output from Spring, which is verbose 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"); } diff --git a/war/resources/scripts/hudson-behavior.js b/war/resources/scripts/hudson-behavior.js index 754e0537db..a8afefb209 100644 --- a/war/resources/scripts/hudson-behavior.js +++ b/war/resources/scripts/hudson-behavior.js @@ -14,6 +14,15 @@ 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 = { @@ -634,6 +643,7 @@ function expandTextArea(button,id) { // refresh a part of the HTML specified by the given ID, // by using the contents fetched from the given URL. function refreshPart(id,url) { + if(isRunAsTest) return; window.setTimeout(function() { new Ajax.Request(url, { method: "post", @@ -892,6 +902,7 @@ function addRadioBlock(id) { function updateBuildHistory(ajaxUrl,nBuild) { + if(isRunAsTest) return; $('buildHistory').headers = ["n",nBuild]; function updateBuilds() { @@ -1328,4 +1339,4 @@ var updateCenter = { } }); } -}; \ No newline at end of file +};