Skip to content
Permalink
Browse files
[FIXED JENKINS-20924] Make plans optional in TAP via a configuration
  • Loading branch information
kinow committed Dec 10, 2013
1 parent c890b89 commit 0491b7e6e95c31deca30b4905a929f8ae02e22d7
Showing with 52 additions and 52 deletions.
  1. +16 −16 pom.xml
  2. +19 −20 src/main/java/org/tap4j/plugin/TapParser.java
  3. +17 −16 src/test/java/org/tap4j/plugin/issue16647/TestIssue16647.java
32 pom.xml
@@ -1,34 +1,34 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.488</version><!-- which version of Jenkins is this plugin built
<version>1.488</version><!-- which version of Jenkins is this plugin built
against? -->
</parent>

<inceptionYear>2011</inceptionYear>

<groupId>org.tap4j</groupId>
<artifactId>tap</artifactId>
<name>Jenkins TAP Plugin</name>
<version>1.17-SNAPSHOT</version>
<packaging>hpi</packaging>

<description>This plugin publishes TAP test results.</description>

<url>http://wiki.jenkins-ci.org/display/JENKINS/TAP+Plugin</url>

<organization>
<name>Jenkins</name>
<url>http://www.jenkins-ci.org</url>
</organization>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<issueManagement>
<system>JIRA</system>
<url>https://issues.jenkins-ci.org/browse/JENKINS/component/15874</url>
@@ -40,7 +40,7 @@
<url>http://maven.jenkins-ci.org:8081/content/repositories/releases/</url>
</repository>
</distributionManagement>

<developers>
<developer>
<id>kinow</id>
@@ -52,7 +52,7 @@
</roles>
</developer>
</developers>

<build>
<pluginManagement>
<plugins>
@@ -141,21 +141,21 @@
</plugins>
</pluginManagement>
</build>

<scm>
<connection>scm:git:git://github.com/jenkinsci/tap-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/tap-plugin.git</developerConnection>
<url>http://github.com/jenkinsci/tap-plugin</url>
</scm>

<dependencies>
<dependency>
<groupId>org.tap4j</groupId>
<artifactId>tap4j</artifactId>
<version>4.0.5</version>
<version>4.0.7</version>
</dependency>
</dependencies>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
@@ -169,6 +169,6 @@
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>


</project>
@@ -1,18 +1,18 @@
/*
/*
* The MIT License
*
*
* Copyright (c) 2010 Bruno P. Kinoshita <http://www.kinoshita.eti.br>
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -42,7 +42,7 @@

/**
* Executes remote TAP Stream retrieval and execution.
*
*
* @author Bruno P. Kinoshita - http://www.kinoshita.eti.br
* @since 1.1
*/
@@ -54,7 +54,7 @@ public class TapParser {
private Boolean outputTapToConsole;
private Boolean enableSubtests;
private Boolean todoIsFailure;

/** Build's logger to print logs as part of build's console output */
private PrintStream logger;
private boolean parserErrors;
@@ -75,7 +75,7 @@ public TapParser(Boolean outputTapToConsole, Boolean enableSubtests, Boolean tod
this.parserErrors = false;
this.hasFailedTests = false;
}

/**
* @deprecated
*/
@@ -88,7 +88,7 @@ public TapParser(Boolean outputTapToConsole, Boolean enableSubtests, Boolean tod
this.parserErrors = false;
this.includeCommentDiagnostics = includeCommentDiagnostics;
}

/**
* @deprecated
*/
@@ -102,9 +102,9 @@ public TapParser(Boolean outputTapToConsole, Boolean enableSubtests, Boolean tod
this.validateNumberOfTests = validateNumberOfTests;
}

public TapParser(Boolean outputTapToConsole2, Boolean enableSubtests2, Boolean todoIsFailure2,
Boolean includeCommentDiagnostics2, Boolean validateNumberOfTests2, Boolean planRequired,
PrintStream logger2) {
public TapParser(Boolean outputTapToConsole, Boolean enableSubtests, Boolean todoIsFailure,
Boolean includeCommentDiagnostics, Boolean validateNumberOfTests, Boolean planRequired,
PrintStream logger) {
this.outputTapToConsole = outputTapToConsole;
this.enableSubtests = enableSubtests;
this.todoIsFailure = todoIsFailure;
@@ -122,7 +122,7 @@ public boolean hasParserErrors() {
public boolean hasFailedTests() {
return this.hasFailedTests;
}

public TapResult parse(FilePath[] results, AbstractBuild<?, ?> build) {
this.parserErrors = Boolean.FALSE;
this.hasFailedTests = Boolean.FALSE;
@@ -141,25 +141,24 @@ public TapResult parse(FilePath[] results, AbstractBuild<?, ?> build) {
}
try {
log("Parsing TAP test result [" + tapFile + "].");

final Tap13Parser parser;
parser = new Tap13Parser();
//TODO: parser = new Tap13Parser("UTF-8", enableSubtests, planRequired);
parser = new Tap13Parser("UTF-8", enableSubtests, planRequired);
final TestSet testSet = parser.parseFile(tapFile);

if (this.validateNumberOfTests) {
if (testSet.getPlan().getLastTestNumber() != testSet.getNumberOfTestResults()) {
throw new ParserException("Number of tests results didn't go to plan");
}
}

if (testSet.containsNotOk() || testSet.containsBailOut()) {
this.hasFailedTests = Boolean.TRUE;
}

final TestSetMap map = new TestSetMap(tapFile.getAbsolutePath(), testSet);
testSets.add(map);

if (this.outputTapToConsole) {
try {
log(FileUtils.readFileToString(tapFile));
@@ -20,14 +20,14 @@ public class TestIssue16647 extends HudsonTestCase {

public void testDurationMs() throws IOException, InterruptedException, ExecutionException {
FreeStyleProject project = this.hudson.createProject(FreeStyleProject.class, "tap-bug-16647");
final String tap = "1..2\n" +
"ok 1 - Input file opened\n" +

final String tap = "1..2\n" +
"ok 1 - Input file opened\n" +
"not ok 2 - First line of the input valid\n" +
" ---\n" +
" duration_ms: 100.66\n" +
" duration_ms: 100.66\n" +
" ...\n";

project.getBuildersList().add(new TestBuilder() {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher arg1,
@@ -36,26 +36,27 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher arg1,
return true;
}
});

TapPublisher publisher = new TapPublisher(
"result.tap",
true,
true,
true,
true,
true,
"result.tap",
true,
true,
true,
true,
true,
true);
true,
true,
true,
false);
project.getPublishersList().add(publisher);
project.save();
FreeStyleBuild build = (FreeStyleBuild) project.scheduleBuild2(0).get();

TapTestResultAction action = build.getAction(TapTestResultAction.class);
TapStreamResult result = (TapStreamResult) action.getResult();

TapTestResultResult[] results = result.getChildren().toArray(new TapTestResultResult[0]);
assertEquals(100.66f, results[1].getDuration());
}

}

0 comments on commit 0491b7e

Please sign in to comment.