Skip to content

Commit

Permalink
[JENKINS-37611] Add "@symbol" annotation to xunit and parameters
Browse files Browse the repository at this point in the history
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 6, 2018
1 parent fadb799 commit e52107f
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> <parent>
<groupId>org.jenkins-ci.plugins</groupId> <groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId> <artifactId>plugin</artifactId>
<version>2.37</version> <version>3.9</version>
</parent> </parent>


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


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


<repositories> <repositories>
Expand All @@ -63,6 +63,26 @@
</pluginRepository> </pluginRepository>
</pluginRepositories> </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> <dependencies>
<dependency> <dependency>
<groupId>org.jenkins-ci.lib.dtkit</groupId> <groupId>org.jenkins-ci.lib.dtkit</groupId>
Expand All @@ -75,7 +95,6 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>

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

<dependency> <dependency>
<groupId>org.jenkins-ci.lib.dtkit</groupId> <groupId>org.jenkins-ci.lib.dtkit</groupId>
<artifactId>dtkit-metrics-hudson-api</artifactId> <artifactId>dtkit-metrics-hudson-api</artifactId>
Expand All @@ -100,34 +118,17 @@
<version>${dry.run.version}</version> <version>${dry.run.version}</version>
</dependency> </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> <dependency>
<groupId>net.sourceforge.saxon</groupId> <groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId> <artifactId>saxon</artifactId>
<version>${saxon.version}</version> <version>${saxon.version}</version>
</dependency> </dependency>

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

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


<dependency> <dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId> <groupId>org.jenkins-ci.plugins</groupId>
<artifactId>workflow-aggregator</artifactId> <artifactId>structs</artifactId>
<version>1.7</version> <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> <scope>test</scope>
</dependency> </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> </dependencies>


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


<build> <build>
<pluginManagement> <pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId> <artifactId>findbugs-maven-plugin</artifactId>
<configuration> <configuration>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile> <excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
</pluginManagement> </pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-dependency-plugin</artifactId> <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 int thresholdMode;
private ExtraConfiguration extraConfiguration; 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 @DataBoundConstructor
public XUnitBuilder(@CheckForNull TestType[] tools, @CheckForNull XUnitThreshold[] thresholds, int thresholdMode, @CheckForNull String testTimeMargin) { 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; this.thresholdMode = thresholdMode;
long longTestTimeMargin = XUnitDefaultValues.TEST_REPORT_TIME_MARGING; long longTestTimeMargin = XUnitDefaultValues.TEST_REPORT_TIME_MARGING;
if (testTimeMargin != null && testTimeMargin.trim().length() != 0) { 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 javax.annotation.CheckForNull;


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


import com.thoughtworks.xstream.annotations.XStreamAlias;

import hudson.DescriptorExtensionList; import hudson.DescriptorExtensionList;
import hudson.Extension; import hudson.Extension;
import hudson.FilePath; import hudson.FilePath;
Expand Down Expand Up @@ -70,15 +73,10 @@ public class XUnitPublisher extends Recorder implements DryRun, Serializable, Si
private int thresholdMode; private int thresholdMode;
private ExtraConfiguration extraConfiguration; 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 @DataBoundConstructor
public XUnitPublisher(@CheckForNull TestType[] tools, @CheckForNull XUnitThreshold[] thresholds, int thresholdMode, @CheckForNull String testTimeMargin) { 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; this.thresholdMode = thresholdMode;
long longTestTimeMargin = XUnitDefaultValues.TEST_REPORT_TIME_MARGING; long longTestTimeMargin = XUnitDefaultValues.TEST_REPORT_TIME_MARGING;
if (testTimeMargin != null && testTimeMargin.trim().length() != 0) { 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; return true;
} }



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


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


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


package org.jenkinsci.plugins.xunit.threshold; package org.jenkinsci.plugins.xunit.threshold;


import org.jenkinsci.Symbol;

import hudson.Extension; import hudson.Extension;


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


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


package org.jenkinsci.plugins.xunit.threshold; package org.jenkinsci.plugins.xunit.threshold;


import org.jenkinsci.Symbol;

import hudson.Extension; import hudson.Extension;


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


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


package org.jenkinsci.plugins.xunit.types; 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.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType; import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor; 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 { public class AUnitJunitHudsonTestType extends TestType {


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


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


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


package org.jenkinsci.plugins.xunit.types; 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.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType; import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor; 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 { public class BoostTestJunitHudsonTestType extends TestType {


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


@Symbol("BoostTest")
@Extension @Extension
public static class DescriptorImpl extends TestTypeDescriptor<BoostTestJunitHudsonTestType> { 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; 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.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType; import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor; 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 * @author Gregory Boissinot
*/ */
public class CTestType extends TestType { 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); super(pattern, skipNoTestFiles, failIfNotNew, deleteOutputFiles, stopProcessingIfError);
} }


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


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


package org.jenkinsci.plugins.xunit.types; 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.descriptor.TestTypeDescriptor;
import org.jenkinsci.lib.dtkit.type.TestType; import org.jenkinsci.lib.dtkit.type.TestType;
import org.kohsuke.stapler.DataBoundConstructor; 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 { public class CUnitJunitHudsonTestType extends TestType {


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


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


Expand Down

0 comments on commit e52107f

Please sign in to comment.