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");
206 "_" + std::to_string(mpi.rank) +
".vtu";
209 filenames.push_back(filename);
212 if (empty(filenames))
215 "No files from test definitions were added for tests but {} "
217 std::size(vtkdiff_configs),
218 (std::size(vtkdiff_configs) == 1 ?
"test was" :
"tests were"));
221 auto const absolute_tolerance =
223 vtkdiff_config.getConfigParameter<std::string>(
"absolute_tolerance",
225 if (!absolute_tolerance.empty() &&
226 !isConvertibleToDouble(absolute_tolerance))
229 "The absolute tolerance value '{:s}' is not convertible to "
233 std::string
const absolute_tolerance_parameter =
234 "--abs " + absolute_tolerance;
235 auto const relative_tolerance =
237 vtkdiff_config.getConfigParameter<std::string>(
"relative_tolerance",
239 if (!relative_tolerance.empty() &&
240 !isConvertibleToDouble(relative_tolerance))
243 "The relative tolerance value '{:s}' is not convertible to "
247 std::string
const relative_tolerance_parameter =
248 "--rel " + relative_tolerance;
250 for (
auto const& filename : filenames)
252 std::string output_filename =
255 std::string reference_filename =
263 auto const& long_path_indicator = R
"(\\?\)";
266 std::filesystem::absolute(reference_filename).string();
267 reference_filename = std::format("\"{}{}\"", long_path_indicator,
270 std::filesystem::absolute(output_filename).string();
272 std::format(
"\"{}{}\"", long_path_indicator, output_filename);
275 output_filename = safeString(output_filename);
276 reference_filename = safeString(reference_filename);
281 std::string command_line =
282 vtkdiff +
" -a " + safeString(field_name) +
" -b " +
283 safeString(field_name) +
" " + reference_filename +
" " +
284 output_filename +
" " + absolute_tolerance_parameter +
" " +
285 relative_tolerance_parameter;
286 INFO(
"Will run '{:s}'", command_line);
294 std::vector<int> return_values;
296 back_inserter(return_values),
297 [](std::string
const& command_line)
299 INFO(
"---------- vtkdiff begin ----------");
300 int const return_value = std::system(command_line.c_str());
301 if (return_value != 0)
303 WARN(
"Return value {:d} was returned by '{:s}'.",
304 return_value, command_line);
306 INFO(
"---------- vtkdiff end ----------\n");
309 return !return_values.empty() &&
310 all_of(begin(return_values), end(return_values),
311 [](
int const& return_value) {
return return_value == 0; });