support adding images to the gitlab ci archive for regression tests

This commit is contained in:
nadavi 2020-10-14 17:15:28 +00:00
parent a1c3752dfb
commit b883b2d92b
4 changed files with 62 additions and 4 deletions

@ -173,6 +173,14 @@ stages:
#for running failed tests multiple times so failures #for running failed tests multiple times so failures
#due to system load are not reported #due to system load are not reported
- "ctest-latest -VV -S .gitlab/ci/ctest_test.cmake" - "ctest-latest -VV -S .gitlab/ci/ctest_test.cmake"
artifacts:
expire_in: 24 hours
when: always
paths:
# The generated regression testing images
- build/*.png
- build/*.pnm
- build/*.pmm
.cmake_memcheck_linux: &cmake_memcheck_linux .cmake_memcheck_linux: &cmake_memcheck_linux
stage: test stage: test
@ -180,6 +188,14 @@ stages:
interruptible: true interruptible: true
script: script:
- "ctest-latest -VV -S .gitlab/ci/ctest_memcheck.cmake" - "ctest-latest -VV -S .gitlab/ci/ctest_memcheck.cmake"
artifacts:
expire_in: 24 hours
when: always
paths:
# The generated regression testing images
- build/*.png
- build/*.pnm
- build/*.pmm
include: include:
- local: '/.gitlab/ci/centos7.yml' - local: '/.gitlab/ci/centos7.yml'

@ -178,6 +178,9 @@ function(vtkm_unit_tests)
# Add the path to the location where regression test images are to be stored # Add the path to the location where regression test images are to be stored
list(APPEND VTKm_UT_TEST_ARGS "--baseline-dir=${VTKm_SOURCE_DIR}/data/baseline") list(APPEND VTKm_UT_TEST_ARGS "--baseline-dir=${VTKm_SOURCE_DIR}/data/baseline")
# Add the path to the location where generated regression test images should be written
list(APPEND VTKm_UT_TEST_ARGS "--write-dir=${VTKm_BINARY_DIR}")
if(VTKm_UT_MPI) if(VTKm_UT_MPI)
if (VTKm_ENABLE_MPI) if (VTKm_ENABLE_MPI)
vtkm_create_test_executable( vtkm_create_test_executable(

@ -39,8 +39,9 @@ namespace testing
enum TestOptionsIndex enum TestOptionsIndex
{ {
TEST_UNKNOWN, TEST_UNKNOWN,
DATADIR, // base dir containing test data files DATADIR, // base dir containing test data files
BASELINEDIR // base dir for regression test images BASELINEDIR, // base dir for regression test images
WRITEDIR // base dir for generated regression test images
}; };
struct TestVtkmArg : public opt::Arg struct TestVtkmArg : public opt::Arg
@ -116,6 +117,13 @@ public:
return GetRegressionTestImageBasePath() + filename; return GetRegressionTestImageBasePath() + filename;
} }
static VTKM_CONT const std::string GetWriteDirBasePath() { return SetAndGetWriteDirBasePath(); }
static VTKM_CONT const std::string WriteDirPath(const std::string& filename)
{
return GetWriteDirBasePath() + filename;
}
template <class Func> template <class Func>
static VTKM_CONT int Run(Func function, int& argc, char* argv[]) static VTKM_CONT int Run(Func function, int& argc, char* argv[])
{ {
@ -227,6 +235,22 @@ private:
return RegressionTestImageBasePath; return RegressionTestImageBasePath;
} }
static std::string& SetAndGetWriteDirBasePath(std::string path = "")
{
static std::string WriteDirBasePath;
if (path != "")
{
WriteDirBasePath = path;
if ((WriteDirBasePath.back() != '/') && (WriteDirBasePath.back() != '\\'))
{
WriteDirBasePath = WriteDirBasePath + '/';
}
}
return WriteDirBasePath;
}
// Method to parse the extra arguments given to unit tests // Method to parse the extra arguments given to unit tests
static VTKM_CONT void ParseAdditionalTestArgs(int& argc, char* argv[]) static VTKM_CONT void ParseAdditionalTestArgs(int& argc, char* argv[])
{ {
@ -252,6 +276,16 @@ private:
"\tPath to the base dir " "\tPath to the base dir "
"for regression test " "for regression test "
"images" }); "images" });
usage.push_back({ WRITEDIR,
0,
"",
"write-dir",
TestVtkmArg::Required,
" --write-dir "
"<write-dir-path> "
"\tPath to the write dir "
"to store generated "
"regression test images" });
// Required to collect unknown arguments when help is off. // Required to collect unknown arguments when help is off.
usage.push_back({ TEST_UNKNOWN, 0, "", "", TestVtkmArg::Unknown, "" }); usage.push_back({ TEST_UNKNOWN, 0, "", "", TestVtkmArg::Unknown, "" });
usage.push_back({ 0, 0, 0, 0, 0, 0 }); usage.push_back({ 0, 0, 0, 0, 0, 0 });
@ -282,6 +316,11 @@ private:
SetAndGetRegressionImageBasePath(options[BASELINEDIR].arg); SetAndGetRegressionImageBasePath(options[BASELINEDIR].arg);
} }
if (options[WRITEDIR])
{
SetAndGetWriteDirBasePath(options[WRITEDIR].arg);
}
for (const opt::Option* opt = options[TEST_UNKNOWN]; opt != nullptr; opt = opt->next()) for (const opt::Option* opt = options[TEST_UNKNOWN]; opt != nullptr; opt = opt->next())
{ {
VTKM_LOG_S(vtkm::cont::LogLevel::Info, VTKM_LOG_S(vtkm::cont::LogLevel::Info,

@ -81,7 +81,7 @@ inline vtkm::cont::testing::TestEqualResult test_equal_images(
VTKM_LOG_S(vtkm::cont::LogLevel::Error, error.what()); VTKM_LOG_S(vtkm::cont::LogLevel::Error, error.what());
imageResult.PushMessage(error.GetMessage()); imageResult.PushMessage(error.GetMessage());
const std::string outputImagePath = vtkm::cont::testing::Testing::BuildDirPath(fileName); const std::string outputImagePath = vtkm::cont::testing::Testing::WriteDirPath(fileName);
vtkm::io::WriteImageFile(view->GetCanvas().GetDataSet(), outputImagePath, "color"); vtkm::io::WriteImageFile(view->GetCanvas().GetDataSet(), outputImagePath, "color");
imageResult.PushMessage("File '" + fileName + "' did not exist but has been generated"); imageResult.PushMessage("File '" + fileName + "' did not exist but has been generated");
@ -114,7 +114,7 @@ inline vtkm::cont::testing::TestEqualResult test_equal_images(
if (writeDiff && resultDataSet.HasPointField("image-diff")) if (writeDiff && resultDataSet.HasPointField("image-diff"))
{ {
const std::string diffName = "diff-" + fileName; const std::string diffName = vtkm::cont::testing::Testing::WriteDirPath("diff-" + fileName);
vtkm::io::WriteImageFile(resultDataSet, diffName, "image-diff"); vtkm::io::WriteImageFile(resultDataSet, diffName, "image-diff");
} }