Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9151adf
commit c991264
Showing
6 changed files
with
517 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/main/java/org/jenkinsci/plugins/xunit/types/CTestInputMetric.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.jenkinsci.plugins.xunit.types; | ||
|
||
import com.thalesgroup.dtkit.junit.model.JUnitModel; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetricXSL; | ||
import com.thalesgroup.dtkit.metrics.model.InputType; | ||
import com.thalesgroup.dtkit.metrics.model.OutputMetric; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CTestInputMetric extends InputMetricXSL { | ||
|
||
@Override | ||
public InputType getToolType() { | ||
return InputType.TEST; | ||
} | ||
|
||
@Override | ||
public String getToolVersion() { | ||
return "Version N/A"; | ||
} | ||
|
||
@Override | ||
public String getToolName() { | ||
return "CTest"; | ||
} | ||
|
||
@Override | ||
public boolean isDefault() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getXslName() { | ||
return "ctest-to-junit.xsl"; | ||
} | ||
|
||
@Override | ||
public String[] getInputXsdNameList() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public OutputMetric getOutputFormatType() { | ||
return JUnitModel.OUTPUT_JUNIT_5; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/org/jenkinsci/plugins/xunit/types/CTestType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.jenkinsci.plugins.xunit.types; | ||
|
||
import com.thalesgroup.dtkit.metrics.hudson.api.descriptor.TestTypeDescriptor; | ||
import com.thalesgroup.dtkit.metrics.hudson.api.type.TestType; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetric; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetricException; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetricFactory; | ||
import hudson.Extension; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CTestType extends TestType { | ||
|
||
@DataBoundConstructor | ||
public CTestType(String pattern, boolean ignoreNoResultFiles, boolean failIfNotNew, boolean deleteOutputFiles, boolean stopProcessingIfError) { | ||
super(pattern, failIfNotNew, ignoreNoResultFiles, deleteOutputFiles, stopProcessingIfError); | ||
} | ||
|
||
@Extension | ||
public static class CTestTypeDescriptor extends TestTypeDescriptor<CTestType> { | ||
|
||
public CTestTypeDescriptor() { | ||
super(CTestType.class, null); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return this.getClass().getName(); | ||
} | ||
|
||
@Override | ||
public InputMetric getInputMetric() { | ||
try { | ||
return InputMetricFactory.getInstance(CTestInputMetric.class); | ||
} catch (InputMetricException e) { | ||
throw new RuntimeException("Can't create the inputMetric object for the class " + CTestInputMetric.class); | ||
} | ||
} | ||
} | ||
} | ||
|
35 changes: 35 additions & 0 deletions
35
src/main/resources/org/jenkinsci/plugins/xunit/types/ctest-to-junit.xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
<xsl:output method="xml" indent="yes"/> | ||
<xsl:template match="/"> | ||
<testsuites> | ||
<xsl:variable name="buildName" select="//Site/@BuildName"/> | ||
<xsl:variable name="numberOfTests" select="count(//Site/Testing/Test)"/> | ||
<xsl:variable name="numberOfFailures" select="count(//Site/Testing/Test[@Status!='passed'])"/> | ||
<testsuite name="CTest" | ||
tests="{$numberOfTests}" time="0" | ||
failures="{$numberOfFailures}" errors="0" | ||
skipped="0"> | ||
<xsl:for-each select="//Site/Testing/Test"> | ||
<xsl:variable name="testName" select="translate(Name, '-', '_')"/> | ||
<xsl:variable name="duration" select="Results/NamedMeasurement[@name='Execution Time']/Value"/> | ||
<xsl:variable name="status" select="@Status"/> | ||
<xsl:variable name="output" select="Results/Measurement/Value"/> | ||
<xsl:variable name="className" select="translate(Path, '/.', '.')"/> | ||
<testcase classname="projectroot{$className}" | ||
name="{$testName}" | ||
time="{$duration}"> | ||
<xsl:if test="@Status!='passed'"> | ||
<failure> | ||
<xsl:value-of select="$output"/> | ||
</failure> | ||
</xsl:if> | ||
<system-out> | ||
<xsl:value-of select="$output"/> | ||
</system-out> | ||
</testcase> | ||
</xsl:for-each> | ||
</testsuite> | ||
</testsuites> | ||
</xsl:template> | ||
</xsl:stylesheet> |
15 changes: 15 additions & 0 deletions
15
src/test/java/org/jenkinsci/plugins/xunit/types/CTestTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.jenkinsci.plugins.xunit.types; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CTestTest extends AbstractTest { | ||
|
||
@Test | ||
public void testTestCase1() throws Exception { | ||
convertAndValidate(CTestInputMetric.class, "ctest/testcase1/input.xml", "ctest/testcase1/result.xml"); | ||
} | ||
|
||
} |
Oops, something went wrong.