152 std::string
const& reference_path,
153 std::string
const& output_directory)
155 if (reference_path.empty())
158 "Reference path containing expected result files can not be "
162 std::string
const vtkdiff = findVtkdiff();
168 for (
auto const& vtkdiff_config : vtkdiff_configs)
170 std::string
const& field_name =
172 vtkdiff_config.getConfigParameter<std::string>(
"field");
173 DBUG(
"vtkdiff will compare field '{:s}'.", field_name);
175 std::vector<std::string> filenames;
176 if (
auto const regex_string =
178 vtkdiff_config.getConfigParameterOptional<std::string>(
"regex"))
181 DBUG(
"vtkdiff regex is '{}'.", *regex_string);
182 auto const regex = std::regex(*regex_string);
183 for (
auto const& p : std::filesystem::directory_iterator(
184 std::filesystem::path(reference_path)))
186 auto const filename = p.path().filename().string();
187 if (std::regex_match(filename, regex))
189 DBUG(
" -> matched '{}'", filename);
190 filenames.push_back(filename);
196 std::string filename =
198 vtkdiff_config.getConfigParameter<std::string>(
"file");
201 MPI_Comm_size(PETSC_COMM_WORLD, &mpi_size);
205 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
209 "_" + std::to_string(rank) +
".vtu";
212 filenames.push_back(filename);
215 if (empty(filenames))
218 "No files from test definitions were added for tests but {} "
220 std::size(vtkdiff_configs),
221 (std::size(vtkdiff_configs) == 1 ?
"test was" :
"tests were"));
224 auto const absolute_tolerance =
226 vtkdiff_config.getConfigParameter<std::string>(
"absolute_tolerance",
228 if (!absolute_tolerance.empty() &&
229 !isConvertibleToDouble(absolute_tolerance))
232 "The absolute tolerance value '{:s}' is not convertible to "
236 std::string
const absolute_tolerance_parameter =
237 "--abs " + absolute_tolerance;
238 auto const relative_tolerance =
240 vtkdiff_config.getConfigParameter<std::string>(
"relative_tolerance",
242 if (!relative_tolerance.empty() &&
243 !isConvertibleToDouble(relative_tolerance))
246 "The relative tolerance value '{:s}' is not convertible to "
250 std::string
const relative_tolerance_parameter =
251 "--rel " + relative_tolerance;
253 for (
auto const& filename : filenames)
255 std::string output_filename =
258 std::string reference_filename =
266 auto const& long_path_indicator = R
"(\\?\)";
269 std::filesystem::absolute(reference_filename).string();
270 reference_filename = std::format("\"{}{}\"", long_path_indicator,
273 std::filesystem::absolute(output_filename).string();
275 std::format(
"\"{}{}\"", long_path_indicator, output_filename);
278 output_filename = safeString(output_filename);
279 reference_filename = safeString(reference_filename);
284 std::string command_line =
285 vtkdiff +
" -a " + safeString(field_name) +
" -b " +
286 safeString(field_name) +
" " + reference_filename +
" " +
287 output_filename +
" " + absolute_tolerance_parameter +
" " +
288 relative_tolerance_parameter;
289 INFO(
"Will run '{:s}'", command_line);
297 std::vector<int> return_values;
299 back_inserter(return_values),
300 [](std::string
const& command_line)
302 INFO(
"---------- vtkdiff begin ----------");
303 int const return_value = std::system(command_line.c_str());
304 if (return_value != 0)
306 WARN(
"Return value {:d} was returned by '{:s}'.",
307 return_value, command_line);
309 INFO(
"---------- vtkdiff end ----------\n");
312 return !return_values.empty() &&
313 all_of(begin(return_values), end(return_values),
314 [](
int const& return_value) {
return return_value == 0; });