From d81c6a3c87cc828b0d1d485a9a4054cb3686c729 Mon Sep 17 00:00:00 2001 From: Doug Martin Date: Tue, 24 Jun 2014 18:08:55 -0400 Subject: [PATCH 1/2] added a test enabled check box to easily disable tests --- .../plugins/seleniumhq/SeleniumhqBuilder.java | 44 ++++++++++++++++--- .../seleniumhq/SeleniumhqBuilder/config.jelly | 3 ++ 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java b/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java index d45cb0a..213c661 100644 --- a/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java +++ b/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java @@ -45,17 +45,30 @@ public class SeleniumhqBuilder extends Builder { private final String suiteFile; private final String resultFile; private final String other; + private final boolean testEnabled; + @DataBoundConstructor public SeleniumhqBuilder(String browser, String startURL, String suiteFile, String resultFile, - String other) { + String other, boolean testEnabled) { this.browser = browser; this.startURL = startURL; this.suiteFile = suiteFile; this.resultFile = resultFile; this.other = other; + this.testEnabled = testEnabled; } + //Left this call in to satisfy the tests. Did not change the tests. + public SeleniumhqBuilder(String browser, String startURL, String suiteFile, String resultFile, + String other) { + this.browser = browser; + this.startURL = startURL; + this.suiteFile = suiteFile; + this.resultFile = resultFile; + this.other = other; + this.testEnabled = true; + } /** * We'll use this from the config.jelly. */ @@ -91,6 +104,13 @@ public String getResultFile() { return resultFile; } + /** + * We'll use this from the config.jelly. + */ + public boolean getTestEnabled() { + return testEnabled; + } + /** * Check if the suiteFile is a URL * @@ -113,7 +133,7 @@ public boolean isURLSuiteFile() { * @throws IOException */ public boolean isFileSuiteFile(AbstractBuild build, Launcher launcher) throws IOException, InterruptedException { - FilePath suiteFilePath = new FilePath(build.getWorkspace(), this.suiteFile); + FilePath suiteFilePath = new FilePath(build.getWorkspace(), this.suiteFile); if (suiteFilePath.exists()) { return suiteFilePath.isDirectory() == false; @@ -142,6 +162,18 @@ public boolean perform(AbstractBuild build, Launcher launcher, BuildListene return false; } + //if test is not enabled we should mark it as NOT BUILT (rather than success or failure + if(!this.getTestEnabled()) { + listener.getLogger().println("---------------"); + listener.getLogger().println("SKIPPING: Test Suite. '" + this.getSuiteFile() + "' was marked as not enabled"); + listener.getLogger().println("---------------"); + //Let the other surrounding tests determine the build result + //build.setResult(Result.NOT_BUILT); + + //return build so build doesn't get aborted & other tests will get run + return true; + } + // ------------------------------- // Check projet config // ------------------------------- @@ -188,7 +220,7 @@ else if (this.isURLSuiteFile()) { File localWorkspace = new File(build.getRootDir(), "workspace"); File tempSuiteLocal = localWorkspace.createTempFile("tempHtmlSuite", "html"); - + listener.getLogger().println("Try downloading suite file on master"); listener.getLogger().println(" from url : " + this.suiteFile ); listener.getLogger().println(" to file : " + tempSuiteLocal.getPath()); @@ -214,9 +246,9 @@ else if (this.isURLSuiteFile()) return false; } } - else + else { - // The suiteFile it is a unsuported type + // The suiteFile it is a unsuported type listener.error("The suiteFile is not a file or an url ! Check your build configuration."); build.setResult(Result.FAILURE); return false; @@ -242,7 +274,7 @@ else if (this.isURLSuiteFile()) cmd.add(this.getStartURL()); cmd.add(suiteFile); cmd.add(resultFile); - + try { String javaCmdString = ""; diff --git a/src/main/resources/hudson/plugins/seleniumhq/SeleniumhqBuilder/config.jelly b/src/main/resources/hudson/plugins/seleniumhq/SeleniumhqBuilder/config.jelly index 482a3c1..37ed0e7 100644 --- a/src/main/resources/hudson/plugins/seleniumhq/SeleniumhqBuilder/config.jelly +++ b/src/main/resources/hudson/plugins/seleniumhq/SeleniumhqBuilder/config.jelly @@ -4,6 +4,9 @@ See global.jelly for a general discussion about jelly script. --> + + + From 7625cd5227810e6d6c064f101ac31014ee2c89df Mon Sep 17 00:00:00 2001 From: Doug Martin Date: Tue, 24 Jun 2014 19:09:21 -0400 Subject: [PATCH 2/2] quick fix to allow a parameter to be passed as test suite. Full fix coming later --- .../java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java b/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java index 213c661..c01f5fd 100644 --- a/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java +++ b/src/main/java/hudson/plugins/seleniumhq/SeleniumhqBuilder.java @@ -246,6 +246,12 @@ else if (this.isURLSuiteFile()) return false; } } + //see if we've got a jenkins variable. if so just pass it along + else if (this.suiteFile.startsWith("$")) + { + listener.getLogger().println("Suite File Looks Like a Parameter: "+ this.suiteFile); + suiteFile = this.suiteFile; + } else { // The suiteFile it is a unsuported type