summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/ctest_test
diff options
context:
space:
mode:
authorZack Galbreath <zack.galbreath@kitware.com>2021-06-04 15:22:34 (GMT)
committerZack Galbreath <zack.galbreath@kitware.com>2021-06-08 13:27:19 (GMT)
commitcbcb92d1cb4230426761fb7d08f9135546c98881 (patch)
tree18fa4c3f5e3b53700aa2f9cf18bd9ad34116b6bb /Tests/RunCMake/ctest_test
parentacb25d50d9d37e93cafcbbc4401e1b45029b6461 (diff)
downloadCMake-cbcb92d1cb4230426761fb7d08f9135546c98881.zip
CMake-cbcb92d1cb4230426761fb7d08f9135546c98881.tar.gz
CMake-cbcb92d1cb4230426761fb7d08f9135546c98881.tar.bz2
ctest: add support for attaching files to tests at run time
Allow tests to specify files to upload at runtime. Previously this was only possible to specify at configure time with the ATTACHED_FILES test properties. This commit also fixes a bug in how our test data tarballs were generated by CTest. Previously, if you tried to attach a file outside of the binary directory, CTest would generate a tar file with a relative path, and tar would not allow you to extract it. We resolve this problem by creating tar files with a flat directory structure instead. Fixes: #22284
Diffstat (limited to 'Tests/RunCMake/ctest_test')
-rw-r--r--Tests/RunCMake/ctest_test/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/ctest_test/TestMeasurements-check.cmake5
2 files changed, 9 insertions, 0 deletions
diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
index b559e89..76a63f0 100644
--- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
@@ -161,6 +161,10 @@ add_test(
NAME img_measurement
COMMAND ${CMAKE_COMMAND} -E
echo <DartMeasurementFile name="TestImage" type="image/png">]] ${IMAGE_DIR}/cmake-logo-16.png [[</DartMeasurementFile>)
+add_test(
+ NAME file_measurement
+ COMMAND ${CMAKE_COMMAND} -E
+ echo <DartMeasurementFile name="my_test_input_data" type="file">]] ${IMAGE_DIR}/cmake-logo-16.png [[</DartMeasurementFile>)
]])
run_ctest(TestMeasurements)
endfunction()
diff --git a/Tests/RunCMake/ctest_test/TestMeasurements-check.cmake b/Tests/RunCMake/ctest_test/TestMeasurements-check.cmake
index 9ff9447..0095db0 100644
--- a/Tests/RunCMake/ctest_test/TestMeasurements-check.cmake
+++ b/Tests/RunCMake/ctest_test/TestMeasurements-check.cmake
@@ -15,3 +15,8 @@ if(NOT _test_contents MATCHES [[NamedMeasurement name="TestImage" type="image/pn
string(APPEND RunCMake_TEST_FAILED
"Could not find expected <NamedMeasurement> tag for type='image/png' in Test.xml")
endif()
+# Check file measurement.
+if(NOT _test_contents MATCHES [[NamedMeasurement name="my_test_input_data" encoding="base64" compression="tar/gzip" filename="cmake-logo-16.png" type="file"]])
+ string(APPEND RunCMake_TEST_FAILED
+ "Could not find expected <NamedMeasurement> tag for type='file' in Test.xml")
+endif()