Skip to content

Commit

Permalink
Provide a bogus result (a newline) when a skipped result has no context
Browse files Browse the repository at this point in the history
This allows kyua to function in a backwards compatible manner, allowing
previous versions to read databases from newer versions.

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
  • Loading branch information
ngie-eign committed May 20, 2019
1 parent 147024c commit 6348bf0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
5 changes: 3 additions & 2 deletions engine/googletest_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ engine::googletest_result::parse(std::istream& input)
context = invalid_output_message;
status = "broken";
}

if (context == "")
if (status == "skipped" && context.empty())
context = bogus_googletest_skipped_nul_message;
if (context.empty())
return parse_without_reason(status, context);
else
return parse_with_reason(status, context);
Expand Down
6 changes: 6 additions & 0 deletions engine/googletest_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ model::test_result calculate_googletest_result(
const utils::fs::path&);


/// A bogus identifier for nul reasons provided by the test writer.
///
/// TODO: Support nul messages with skipped results in the schema, etc.
const std::string bogus_googletest_skipped_nul_message = "\n";


} // namespace engine

#endif // !defined(ENGINE_GOOGLETEST_RESULT_HPP)
3 changes: 2 additions & 1 deletion engine/googletest_result_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ const char skipped_message[] = (
);

PARSE(skipped,
engine::googletest_result::skipped, NULL,
engine::googletest_result::skipped,
engine::bogus_googletest_skipped_nul_message.c_str(),
skipped_message
);

Expand Down
13 changes: 2 additions & 11 deletions store/read_transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,13 @@ parse_result(sqlite::statement& stmt, const char* type_column,
try {
const model::test_result_type type =
store::column_test_result_type(stmt, type_column);
switch (type) {
case model::test_result_passed:
if (type == model::test_result_passed) {
if (stmt.column_type(stmt.column_id(reason_column)) !=
sqlite::type_null)
throw store::integrity_error("Result of type 'passed' has a "
"non-NULL reason");
return model::test_result(type);
/// Some test interfaces don't have to provide a reason when skipping a
/// test, e.g., Google Test.
case model::test_result_skipped:
if (stmt.column_type(stmt.column_id(reason_column)) ==
sqlite::type_null) {
return model::test_result(type);
}
/// FALLTHROUGH
default:
} else {
return model::test_result(type,
stmt.safe_column_text(reason_column));
}
Expand Down

0 comments on commit 6348bf0

Please sign in to comment.