Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Because of the semantics of the JUnit output, it does not make much sense to try to shovel this format into the 'report' command. For example: there is no reason to honor the --show-context flag, and honoring the --results-filter flag means that the generated reports are misleading due to invalid total test counts. (My original separation of the HTML format into 'report-html' seems to have proven right...) Removal of the JUnit support from the 'report' command, as well as other reorganizations, will come later.
- Loading branch information
Showing
14 changed files
with
443 additions
and
15 deletions.
There are no files selected for viewing
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
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
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,94 @@ | ||
// Copyright 2014 Google Inc. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// * Neither the name of Google Inc. nor the names of its contributors | ||
// may be used to endorse or promote products derived from this software | ||
// without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
#include "cli/cmd_report_junit.hpp" | ||
|
||
#include <cstddef> | ||
#include <cstdlib> | ||
|
||
#include "cli/common.ipp" | ||
#include "cli/report_junit.hpp" | ||
#include "engine/drivers/scan_action.hpp" | ||
#include "engine/test_result.hpp" | ||
#include "utils/cmdline/parser.ipp" | ||
#include "utils/defs.hpp" | ||
#include "utils/optional.ipp" | ||
|
||
namespace cmdline = utils::cmdline; | ||
namespace config = utils::config; | ||
namespace fs = utils::fs; | ||
namespace scan_action = engine::drivers::scan_action; | ||
|
||
using cli::cmd_report_junit; | ||
using utils::optional; | ||
|
||
|
||
/// Default constructor for cmd_report. | ||
cmd_report_junit::cmd_report_junit(void) : cli_command( | ||
"report-junit", "", 0, 0, | ||
"Generates a JUnit report with the result of a previous action") | ||
{ | ||
add_option(store_option); | ||
add_option(cmdline::int_option( | ||
"action", "The action to report; if not specified, defaults to the " | ||
"latest action in the database", "id")); | ||
add_option(cmdline::path_option("output", "Path to the output file", "path", | ||
"/dev/stdout")); | ||
} | ||
|
||
|
||
/// Entry point for the "report" subcommand. | ||
/// | ||
/// \param ui Object to interact with the I/O of the program. | ||
/// \param cmdline Representation of the command line to the subcommand. | ||
/// \param unused_user_config The runtime configuration of the program. | ||
/// | ||
/// \return 0 if everything is OK, 1 if the statement is invalid or if there is | ||
/// any other problem. | ||
int | ||
cmd_report_junit::run(cmdline::ui* ui, const cmdline::parsed_cmdline& cmdline, | ||
const config::tree& UTILS_UNUSED_PARAM(user_config)) | ||
{ | ||
optional< int64_t > action_id; | ||
if (cmdline.has_option("action")) | ||
action_id = cmdline.get_option< cmdline::int_option >("action"); | ||
|
||
result_types no_filter; | ||
no_filter.push_back(engine::test_result::passed); | ||
no_filter.push_back(engine::test_result::skipped); | ||
no_filter.push_back(engine::test_result::expected_failure); | ||
no_filter.push_back(engine::test_result::broken); | ||
no_filter.push_back(engine::test_result::failed); | ||
|
||
report_junit_hooks hooks( | ||
ui, cmdline.get_option< cmdline::path_option >("output"), true, | ||
no_filter); | ||
scan_action::drive(store_path(cmdline), action_id, hooks); | ||
|
||
return EXIT_SUCCESS; | ||
} |
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,54 @@ | ||
// Copyright 2014 Google Inc. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// * Neither the name of Google Inc. nor the names of its contributors | ||
// may be used to endorse or promote products derived from this software | ||
// without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
/// \file cli/cmd_report_junit.hpp | ||
/// Provides the cmd_report_junit class. | ||
|
||
#if !defined(CLI_CMD_REPORT_JUNIT_HPP) | ||
#define CLI_CMD_REPORT_JUNIT_HPP | ||
|
||
#include "cli/common.hpp" | ||
|
||
namespace cli { | ||
|
||
|
||
/// Implementation of the "report-junit" subcommand. | ||
class cmd_report_junit : public cli_command | ||
{ | ||
public: | ||
cmd_report_junit(void); | ||
|
||
int run(utils::cmdline::ui*, const utils::cmdline::parsed_cmdline&, | ||
const utils::config::tree&); | ||
}; | ||
|
||
|
||
} // namespace cli | ||
|
||
|
||
#endif // !defined(CLI_CMD_REPORT_JUNIT_HPP) |
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
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
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
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
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
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,71 @@ | ||
.\" Copyright 2014 Google Inc. | ||
.\" All rights reserved. | ||
.\" | ||
.\" Redistribution and use in source and binary forms, with or without | ||
.\" modification, are permitted provided that the following conditions are | ||
.\" met: | ||
.\" | ||
.\" * Redistributions of source code must retain the above copyright | ||
.\" notice, this list of conditions and the following disclaimer. | ||
.\" * Redistributions in binary form must reproduce the above copyright | ||
.\" notice, this list of conditions and the following disclaimer in the | ||
.\" documentation and/or other materials provided with the distribution. | ||
.\" * Neither the name of Google Inc. nor the names of its contributors | ||
.\" may be used to endorse or promote products derived from this software | ||
.\" without specific prior written permission. | ||
.\" | ||
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
.\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
.Dd May 26, 2014 | ||
.Dt KYUA-REPORT-JUNIT 1 | ||
.Os | ||
.Sh NAME | ||
.Nm report-junit | ||
.Nd Generates a JUnit report with the results of a test action | ||
.Sh SYNOPSIS | ||
.Nm | ||
.Op Fl -action Ar id | ||
.Op Fl -output Ar path | ||
.Op Fl -store Ar file | ||
.Sh DESCRIPTION | ||
The | ||
.Nm | ||
command provides a simple mechanism to generate JUnit reports of the | ||
execution of a test suite. The command processes an action stored in the | ||
database and then generates a single XML file that complies to the JUnit | ||
XSchema. | ||
.Pp | ||
The JUnit output is static and self-contained, so it can easily be plugged | ||
into any continuous integration system, like Jenkins. | ||
.Pp | ||
The following subcommand options are recognized: | ||
.Bl -tag -width XX | ||
.It Fl -action Ar id | ||
Specifies the action for which to generate a report. If not provided, | ||
defaults to the latest action stored in the database. | ||
.It Fl -output Ar directory | ||
Specifies the file into which to store the JUnit report. | ||
.It Fl -store Ar path , Fl s Ar path | ||
Specifies the database to use. Defaults to | ||
.Pa ~/.kyua/store.db . | ||
The database is created if it does not exist. | ||
.El | ||
.Sh EXIT STATUS | ||
The | ||
.Nm | ||
command always returns 0. | ||
.Pp | ||
Additional exit codes may be returned as described in | ||
.Xr kyua 1 . | ||
.Sh SEE ALSO | ||
.Xr kyua 1 , | ||
.Xr kyua-report 1 |
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
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
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
Oops, something went wrong.