41 redirectstream.close();
46 cout <<
"Performing regression tests" << endl;
54 cerr <<
"No test output file found given file path " << test_file <<
"!" << endl;
56 }
else if (status == -2) {
57 cerr <<
"No baseline file found given file path " << baseline_file <<
"!" << endl;
59 }
else if (status != 0) {
60 cerr <<
"Files " << test_file <<
" and " << baseline_file <<
" differ!" << endl;
66 cerr <<
"No test output file found given file path " << test_file <<
"!" << endl;
68 }
else if (status == -2) {
69 cerr <<
"No baseline file found given file path " << baseline_file <<
"!" << endl;
71 }
else if (status != 0) {
72 cerr <<
"Files " << test_file <<
" and " << baseline_file <<
" differ by more than the allowed " <<
regression_tests[i].max_number_of_differences <<
" lines!" << endl;
77 string bestmatch = baseline_file;
78 int beststatus = numeric_limits<int>::max();
79 if (baseline_files.empty()) {
80 bestmatch +=
" not found";
81 cerr <<
"No baseline images found given file path " << baseline_file <<
"!" << endl;
83 for (
size_t j = 0; j < baseline_files.size(); j++) {
86 baseline_files[j].c_str(),
91 if (status < beststatus) {
92 bestmatch = baseline_files[j];
95 if (beststatus == 0) {
101 if (beststatus != 0) {
104 baseline_files[0].c_str(),
113 cout <<
"<DartMeasurement name=\"BaselineImageName\" type=\"text/string\">";
115 cout <<
"</DartMeasurement>" << std::endl;
116 result += beststatus;
118 cerr <<
"Invalid test method: " <<
regression_tests[i].method <<
"! Check testdriver implementation." << endl;
128 }
catch (
const exception&
e) {
129 cerr <<
"Test driver caught an exception:\n";
130 cerr << e.what() <<
"\n";
133 cerr <<
"Test driver caught an unknown exception!!!\n";
SwitchArg orientation_insensitive("", "orientation-insensitive", "Allow the test and baseline images to have different orientation." " When this option is given, the orientation of both images is made" " identical before they are compared. It is suitable if the test" " and baseline images are simply stored with different orientation," " but with proper orientation information in the file header.")
std::string getcwd()
Get absolute path of the (current) working directory.
int text_diff_lines(const char *testfile, const char *baseline, unsigned int max_number_of_differences=0)
Compare two text files line by line.
DoubleArg intensity_tolerance("", "intensity-tolerance", "The accepted maximum difference between image intensities" " to use for the following regression tests." " (default: 2.0)", false, 2.0, "<float>", true)
bool emptydir(const std::string &path)
Remove files and directories from directory.
std::string basename(const std::string &path)
Get file name.
UIntArg max_number_of_differences("", "max-number-of-differences", "When comparing images specified with the following --compare option(s)," " allow the given number of image elements to differ.", false, 0, "<n>", true)
UIntArg tolerance_radius("", "tolerance-radius", "At most one image element in the neighborhood specified by the" " given radius has to fulfill the criteria of the following" " regression tests", false, 0, "<int>", true)
MultiSwitchArg verbose("v", "verbose", "Increase verbosity of output messages.", false)
int binary_diff(const char *testfile, const char *baseline)
Compare two files byte by byte.
int image_regression_test(const char *imagefile, const char *baseline, double intensity_tolerance=2.0, unsigned int max_number_of_differences=0, unsigned int tolerance_radius=0, bool orientation_insensitive=false, int report=0)
Compare output image to baseline image.
SwitchArg clean_cwd_after_test("", "clean-cwd-after", "Request the removal of all files and directories from the current" " working directory after the successful execution of the test." " This option is in particular useful if the test writes any results" " to the current working directory.", false)
vector< string > get_baseline_filenames(string filename_template)
Generate list of names of baseline files from a given template filename.
vector< RegressionTest > regression_tests
Container storing added regression tests.