diff options
author | Zack Galbreath <zack.galbreath@kitware.com> | 2021-04-22 23:38:43 (GMT) |
---|---|---|
committer | Zack Galbreath <zack.galbreath@kitware.com> | 2021-04-26 12:55:22 (GMT) |
commit | 25bf514447501963a31934b5b03c65aeb53a351f (patch) | |
tree | 9a8392707d6376d588da56100a9ab214abd2ef43 /Tests/RunCMake/ctest_test | |
parent | eeb771e4d6b9a1127a0818a211cafb722a2dc387 (diff) | |
download | CMake-25bf514447501963a31934b5b03c65aeb53a351f.zip CMake-25bf514447501963a31934b5b03c65aeb53a351f.tar.gz CMake-25bf514447501963a31934b5b03c65aeb53a351f.tar.bz2 |
ctest: Add support for writing test results in JUnit XML format
Addresses #18654
Diffstat (limited to 'Tests/RunCMake/ctest_test')
-rw-r--r-- | Tests/RunCMake/ctest_test/OutputJUnit-check.cmake | 24 | ||||
-rw-r--r-- | Tests/RunCMake/ctest_test/RunCMakeTest.cmake | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/Tests/RunCMake/ctest_test/OutputJUnit-check.cmake b/Tests/RunCMake/ctest_test/OutputJUnit-check.cmake new file mode 100644 index 0000000..00310a4 --- /dev/null +++ b/Tests/RunCMake/ctest_test/OutputJUnit-check.cmake @@ -0,0 +1,24 @@ +file(GLOB junit_xml_file "${RunCMake_TEST_BINARY_DIR}/junit.xml") +if(junit_xml_file) + file(READ "${junit_xml_file}" junit_xml LIMIT 4096) + if(NOT "${junit_xml}" MATCHES "tests=\"1\"") + set(RunCMake_TEST_FAILED "tests=\"1\" not found when expected") + endif() + if(NOT "${junit_xml}" MATCHES "failures=\"0\"") + set(RunCMake_TEST_FAILED "failures=\"0\" not found when expected") + endif() + if(NOT "${junit_xml}" MATCHES "disabled=\"0\"") + set(RunCMake_TEST_FAILED "disabled=\"0\" not found when expected") + endif() + if(NOT "${junit_xml}" MATCHES "skipped=\"0\"") + set(RunCMake_TEST_FAILED "skipped=\"0\" not found when expected") + endif() + if(NOT "${junit_xml}" MATCHES "<testcase name=\"RunCMakeVersion\" classname=\"RunCMakeVersion\"") + set(RunCMake_TEST_FAILED "RunCMakeVersion not found when expected") + endif() + if(NOT "${junit_xml}" MATCHES "<system-out>cmake version") + set(RunCMake_TEST_FAILED "<system-out>cmake version not found when expected") + endif() +else() + set(RunCMake_TEST_FAILED "junit.xml not found") +endif() diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index 8cf6a61..901ac11 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -146,3 +146,6 @@ set_property(TEST RunCMakeVersion PROPERTY ENVIRONMENT "ENV1=env1;ENV2=env2") run_ctest(TestEnvironment) endfunction() run_environment() + +# test for OUTPUT_JUNIT +run_ctest_test(OutputJUnit OUTPUT_JUNIT junit.xml REPEAT UNTIL_FAIL:2) |