Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-37611] Add "@symbol" annotation to xunit and parameters
Add @symbol annotation to publisher, thresholds and test type to make pipeline readable. Add pipeline unit test that works with Jenkins 1.x
Update parent pom to latest 3.9
  • Loading branch information
nfalco79 committed May 3, 2018
1 parent b84c36d commit f8af22b
Show file tree
Hide file tree
Showing 29 changed files with 291 additions and 74 deletions.
108 changes: 73 additions & 35 deletions pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.37</version>
<version>3.9</version>
</parent>

<artifactId>xunit</artifactId>
Expand Down Expand Up @@ -41,12 +41,12 @@

<properties>
<dtkit.frmk.version>2.0.0</dtkit.frmk.version>
<xerces.version>2.9.1</xerces.version>
<saxon.version>9.1.0.8</saxon.version>
<dry.run.version>0.1</dry.run.version>
<xmlunit.version>1.6</xmlunit.version>
<mockito.version>2.17.0</mockito.version>
<jenkins.version>1.651.3</jenkins.version>
<java.level>7</java.level>
</properties>

<repositories>
Expand All @@ -63,6 +63,26 @@
</pluginRepository>
</pluginRepositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>annotation-indexer</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.lib.dtkit</groupId>
Expand All @@ -75,7 +95,6 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.jenkins-ci.lib.dtkit</groupId>
<artifactId>dtkit-metrics-util</artifactId>
Expand All @@ -87,7 +106,6 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.jenkins-ci.lib.dtkit</groupId>
<artifactId>dtkit-metrics-hudson-api</artifactId>
Expand All @@ -100,34 +118,17 @@
<version>${dry.run.version}</version>
</dependency>


<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>${saxon.version}</version>
</dependency>

<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>${saxon.version}</version>
<classifier>s9api</classifier>
</dependency>

<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
Expand All @@ -142,12 +143,49 @@
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-aggregator</artifactId>
<version>1.7</version>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.13</version>
</dependency>

<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>${xmlunit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>

<!-- dependencies to get pipeline work with Jenkins 1.x -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.32</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>2.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>2.6</version>
<scope>test</scope>
</dependency>
</dependencies>

<scm>
Expand All @@ -157,17 +195,17 @@
</scm>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/org/jenkinsci/plugins/xunit/XUnitBuilder.java
Expand Up @@ -62,15 +62,10 @@ public class XUnitBuilder extends Builder implements SimpleBuildStep {
private int thresholdMode;
private ExtraConfiguration extraConfiguration;

public XUnitBuilder(@CheckForNull TestType[] tools, @CheckForNull XUnitThreshold[] thresholds) {
this.types = (tools != null ? Arrays.copyOf(tools, tools.length) : new TestType[0]);
this.thresholds = (thresholds != null ? Arrays.copyOf(thresholds, thresholds.length) : new XUnitThreshold[0]);
this.thresholdMode = 1;
}

@DataBoundConstructor
public XUnitBuilder(@CheckForNull TestType[] tools, @CheckForNull XUnitThreshold[] thresholds, int thresholdMode, @CheckForNull String testTimeMargin) {
this(tools, thresholds);
this.types = (tools != null ? Arrays.copyOf(tools, tools.length) : new TestType[0]);
this.thresholds = (thresholds != null ? Arrays.copyOf(thresholds, thresholds.length) : new XUnitThreshold[0]);
this.thresholdMode = thresholdMode;
long longTestTimeMargin = XUnitDefaultValues.TEST_REPORT_TIME_MARGING;
if (testTimeMargin != null && testTimeMargin.trim().length() != 0) {
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/org/jenkinsci/plugins/xunit/XUnitPublisher.java
Expand Up @@ -30,6 +30,7 @@

import javax.annotation.CheckForNull;

import org.jenkinsci.Symbol;
import org.jenkinsci.lib.dryrun.DryRun;
import org.jenkinsci.lib.dtkit.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType;
Expand All @@ -39,6 +40,8 @@
import org.jenkinsci.plugins.xunit.threshold.XUnitThresholdDescriptor;
import org.kohsuke.stapler.DataBoundConstructor;

import com.thoughtworks.xstream.annotations.XStreamAlias;

import hudson.DescriptorExtensionList;
import hudson.Extension;
import hudson.FilePath;
Expand Down Expand Up @@ -70,15 +73,10 @@ public class XUnitPublisher extends Recorder implements DryRun, Serializable, Si
private int thresholdMode;
private ExtraConfiguration extraConfiguration;

public XUnitPublisher(@CheckForNull TestType[] tools, @CheckForNull XUnitThreshold[] thresholds) {
this.types = (tools != null ? Arrays.copyOf(tools, tools.length) : new TestType[0]);
this.thresholds = (thresholds != null ? Arrays.copyOf(thresholds, thresholds.length) : new XUnitThreshold[0]);
this.thresholdMode = 1;
}

@DataBoundConstructor
public XUnitPublisher(@CheckForNull TestType[] tools, @CheckForNull XUnitThreshold[] thresholds, int thresholdMode, @CheckForNull String testTimeMargin) {
this(tools, thresholds);
this.types = (tools != null ? Arrays.copyOf(tools, tools.length) : new TestType[0]);
this.thresholds = (thresholds != null ? Arrays.copyOf(thresholds, thresholds.length) : new XUnitThreshold[0]);
this.thresholdMode = thresholdMode;
long longTestTimeMargin = XUnitDefaultValues.TEST_REPORT_TIME_MARGING;
if (testTimeMargin != null && testTimeMargin.trim().length() != 0) {
Expand Down Expand Up @@ -151,12 +149,12 @@ public boolean performDryRun(AbstractBuild<?, ?> build, Launcher launcher, Build
return true;
}


@Override
public BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.NONE;
}

@Symbol("xunit")
@Extension
public static final class XUnitDescriptorPublisher extends BuildStepDescriptor<Publisher> {

Expand Down
Expand Up @@ -24,11 +24,14 @@

package org.jenkinsci.plugins.xunit.threshold;

import org.jenkinsci.Symbol;

import hudson.Extension;

/**
* @author Gregory Boissinot
*/
@Symbol("failed")
@Extension
public class FailedThresholdDescriptor extends XUnitThresholdDescriptor<FailedThreshold> {

Expand Down
Expand Up @@ -24,11 +24,14 @@

package org.jenkinsci.plugins.xunit.threshold;

import org.jenkinsci.Symbol;

import hudson.Extension;

/**
* @author Gregory Boissinot
*/
@Symbol("skipped")
@Extension
public class SkippedThresholdDescriptor extends XUnitThresholdDescriptor<SkippedThreshold> {

Expand Down
Expand Up @@ -24,18 +24,28 @@

package org.jenkinsci.plugins.xunit.types;

import hudson.Extension;
import org.jenkinsci.Symbol;
import org.jenkinsci.lib.dtkit.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;

/**
* <a href=
* "http://docs.adacore.com/live/wave/aunit/html/aunit_cb/aunit_cb.html">AUnit</a>
* is a unit testing framework of the xUnit family for the Ada language,
* originally developed by Ed Falis and maintained by AdaCore, distributed
* together with GNAT.
*/
public class AUnitJunitHudsonTestType extends TestType {

@DataBoundConstructor
public AUnitJunitHudsonTestType(String pattern, boolean skipNoTestFiles, boolean failIfNotNew, boolean deleteOutputFiles, boolean stopProcessingIfError) {
super(pattern, skipNoTestFiles, failIfNotNew, deleteOutputFiles, stopProcessingIfError);
}

@Symbol("AUnit")
@Extension
public static class DescriptorImpl extends TestTypeDescriptor<AUnitJunitHudsonTestType> {

Expand Down
Expand Up @@ -24,18 +24,26 @@

package org.jenkinsci.plugins.xunit.types;

import hudson.Extension;
import org.jenkinsci.Symbol;
import org.jenkinsci.lib.dtkit.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;

/**
* <a href="http://www.boost.org/doc/libs/release/libs/test">Boost.Test</a> is a
* C++03 and C++11/14 unit testing library, available on a wide range of
* platforms and compilers. The library is part of Boost.
*/
public class BoostTestJunitHudsonTestType extends TestType {

@DataBoundConstructor
public BoostTestJunitHudsonTestType(String pattern, boolean skipNoTestFiles, boolean failIfNotNew, boolean deleteOutputFiles, boolean stopProcessingIfError) {
super(pattern, skipNoTestFiles, failIfNotNew, deleteOutputFiles, stopProcessingIfError);
}

@Symbol("BoostTest")
@Extension
public static class DescriptorImpl extends TestTypeDescriptor<BoostTestJunitHudsonTestType> {

Expand Down
11 changes: 10 additions & 1 deletion src/main/java/org/jenkinsci/plugins/xunit/types/CTestType.java
Expand Up @@ -24,12 +24,20 @@

package org.jenkinsci.plugins.xunit.types;

import hudson.Extension;
import org.jenkinsci.Symbol;
import org.jenkinsci.lib.dtkit.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;

/**
* <a href="https://cmake.org/Wiki/CMake/Testing_With_CTest">CTest</a> is a
* testing tool distributed as a part of CMake. It can be used to automate
* updating (using CVS for example), configuring, building, testing, performing
* memory checking, performing coverage, and submitting results to a CDash or
* Dart dashboard system.
*
* @author Gregory Boissinot
*/
public class CTestType extends TestType {
Expand All @@ -39,6 +47,7 @@ public CTestType(String pattern, boolean skipNoTestFiles, boolean failIfNotNew,
super(pattern, skipNoTestFiles, failIfNotNew, deleteOutputFiles, stopProcessingIfError);
}

@Symbol("CTest")
@Extension
public static class CTestTypeDescriptor extends TestTypeDescriptor<CTestType> {

Expand Down
Expand Up @@ -24,18 +24,28 @@

package org.jenkinsci.plugins.xunit.types;

import hudson.Extension;
import org.jenkinsci.Symbol;
import org.jenkinsci.lib.dtkit.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor;

import hudson.Extension;

/**
* <a href="http://cunit.sourceforge.net">CUnit</a> is a lightweight system for
* writing, administering, and running unit tests in C.
* <p>
* It provides C programmers a basic testing functionality with a flexible
* variety of user interfaces.
*/
public class CUnitJunitHudsonTestType extends TestType {

@DataBoundConstructor
public CUnitJunitHudsonTestType(String pattern, boolean skipNoTestFiles, boolean failIfNotNew, boolean deleteOutputFiles, boolean stopProcessingIfError) {
super(pattern, skipNoTestFiles, failIfNotNew, deleteOutputFiles, stopProcessingIfError);
}

@Symbol("CUnit")
@Extension
public static class DescriptorImpl extends TestTypeDescriptor<CUnitJunitHudsonTestType> {

Expand Down

0 comments on commit f8af22b

Please sign in to comment.