Skip to content

Commit

Permalink
test: add AW_OUTPUT_JUNIT flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedede committed Jul 17, 2022
1 parent 0a7b09f commit cc748cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion awlib/cmake/aw-common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,15 @@ function(aw_add_test NAME)
set(multivalue SOURCES PARAMS)
cmake_parse_arguments(PARSE_ARGV 1 ARG "${options}" "${arguments}" "${multivalue}")

if (AW_OUTPUT_JUNIT)
set(ADDITIONAL_PARAMS)
else()
set(ADDITIONAL_PARAMS "--output-format=junit")
endif()

add_executable(${NAME} ${ARG_SOURCES})
add_test(
NAME ${NAME}
COMMAND ${NAME} ${ARG_PARAMS}
COMMAND ${NAME} ${ARG_PARAMS} ${ADDITIONAL_PARAMS}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endfunction()
2 changes: 1 addition & 1 deletion test/include/aw/test/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int main(int n_param, char** parameters)

report* _report = config.use_junit ? (report*)&junit : (report*)&classic;

int fail_count = aw::test::registry::run(_report);
int fail_count = aw::test::registry::run(_report);

return config.no_exitcode ? 0 : fail_count;
}
Expand Down
4 changes: 3 additions & 1 deletion test/include/aw/test/report_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ class report_junit : public report {
this->total = test_count;
}

void end_suite()
void end_suite() override
{
int skipped = total - succeeded - failed;
println("<testsuites>");
print("<testsuite name=\"", name, "\" tests=\"", total, "\" errors=\"0\" ");
println("failures=\"", failed, "\" skipped=\"", skipped, "\">");
for (const auto& test_case : test_cases)
Expand All @@ -126,6 +127,7 @@ class report_junit : public report {
}
}
println("</testsuite>");
println("</testsuites>");

}

Expand Down

0 comments on commit cc748cd

Please sign in to comment.