Generate and convert JUnit reports for xunit-viewer
This commit is contained in:
parent
6ca53a2e87
commit
80fac24b4d
2 changed files with 63 additions and 15 deletions
|
@ -1,11 +1,12 @@
|
||||||
bld.downloadExtensionJavadoc=false
|
bld.downloadExtensionJavadoc=false
|
||||||
bld.downloadExtensionSources=true
|
bld.downloadExtensionSources=true
|
||||||
bld.downloadLocation=
|
bld.downloadLocation=
|
||||||
bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.9
|
bld.extension-detekt=com.uwyn.rife2:bld-detekt:0.9.10-SNAPSHOT
|
||||||
bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.3
|
bld.extension-dokka=com.uwyn.rife2:bld-dokka:1.0.4-SNAPSHOT
|
||||||
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.0.4
|
bld.extension-exec=com.uwyn.rife2:bld-exec:1.0.5
|
||||||
bld.extension-gv=com.uwyn.rife2:bld-generated-version:1.0.1
|
bld.extension-gv=com.uwyn.rife2:bld-generated-version:1.0.1
|
||||||
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.10
|
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.11-SNAPSHOT
|
||||||
|
bld.extension-kotlin=com.uwyn.rife2:bld-kotlin:1.1.0-SNAPSHOT
|
||||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||||
bld.sourceDirectories=
|
bld.sourceDirectories=
|
||||||
bld.version=2.2.1
|
bld.version=2.2.1
|
||||||
|
|
|
@ -47,6 +47,8 @@ import rife.tools.exceptions.FileUtilsErrorException;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.ConsoleHandler;
|
import java.util.logging.ConsoleHandler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -56,6 +58,7 @@ import static rife.bld.dependencies.Repository.*;
|
||||||
import static rife.bld.dependencies.Scope.*;
|
import static rife.bld.dependencies.Scope.*;
|
||||||
|
|
||||||
public class AkismetBuild extends Project {
|
public class AkismetBuild extends Project {
|
||||||
|
static final String TEST_RESULTS_DIR = "build/test-results/test/";
|
||||||
private static final String DETEKT_BASELINE = "config/detekt/baseline.xml";
|
private static final String DETEKT_BASELINE = "config/detekt/baseline.xml";
|
||||||
final File srcMainKotlin = new File(srcMainDirectory(), "kotlin");
|
final File srcMainKotlin = new File(srcMainDirectory(), "kotlin");
|
||||||
|
|
||||||
|
@ -66,8 +69,8 @@ public class AkismetBuild extends Project {
|
||||||
|
|
||||||
javaRelease = 11;
|
javaRelease = 11;
|
||||||
|
|
||||||
downloadSources = true;
|
|
||||||
autoDownloadPurge = true;
|
autoDownloadPurge = true;
|
||||||
|
downloadSources = true;
|
||||||
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
|
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
|
||||||
|
|
||||||
var okHttp = version(4, 12, 0);
|
var okHttp = version(4, 12, 0);
|
||||||
|
@ -201,10 +204,60 @@ public class AkismetBuild extends Project {
|
||||||
|
|
||||||
@BuildCommand(summary = "Generates JaCoCo Reports")
|
@BuildCommand(summary = "Generates JaCoCo Reports")
|
||||||
public void jacoco() throws Exception {
|
public void jacoco() throws Exception {
|
||||||
new JacocoReportOperation()
|
var op = new JacocoReportOperation().fromProject(this);
|
||||||
.fromProject(this)
|
op.testToolOptions("--reports-dir=" + TEST_RESULTS_DIR);
|
||||||
.sourceFiles(srcMainKotlin)
|
|
||||||
.execute();
|
Exception ex = null;
|
||||||
|
try {
|
||||||
|
op.execute();
|
||||||
|
} catch (Exception e) {
|
||||||
|
ex = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderWithXunitViewer();
|
||||||
|
|
||||||
|
if (ex != null) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory")
|
||||||
|
public void pomRoot() throws FileUtilsErrorException {
|
||||||
|
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
|
||||||
|
new File(workDirectory, "pom.xml"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderWithXunitViewer() throws Exception {
|
||||||
|
var xunitViewer = new File("/usr/bin/xunit-viewer");
|
||||||
|
if (xunitViewer.exists() && xunitViewer.canExecute()) {
|
||||||
|
var reportsDir = "build/reports/tests/test/";
|
||||||
|
|
||||||
|
Files.createDirectories(Path.of(reportsDir));
|
||||||
|
|
||||||
|
new ExecOperation()
|
||||||
|
.fromProject(this)
|
||||||
|
.command(xunitViewer.getPath(), "-r", TEST_RESULTS_DIR, "-o", reportsDir + "index.html")
|
||||||
|
.execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void test() throws Exception {
|
||||||
|
var op = testOperation().fromProject(this);
|
||||||
|
op.testToolOptions().reportsDir(new File(TEST_RESULTS_DIR));
|
||||||
|
|
||||||
|
Exception ex = null;
|
||||||
|
try {
|
||||||
|
op.execute();
|
||||||
|
} catch (Exception e) {
|
||||||
|
ex = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderWithXunitViewer();
|
||||||
|
|
||||||
|
if (ex != null) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -232,10 +285,4 @@ public class AkismetBuild extends Project {
|
||||||
super.publishLocal();
|
super.publishLocal();
|
||||||
pomRoot();
|
pomRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory")
|
|
||||||
public void pomRoot() throws FileUtilsErrorException {
|
|
||||||
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
|
|
||||||
new File(workDirectory, "pom.xml"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue