From 5b3fd479fce1fc1190c1b1cee0f5930227ca21ac Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Wed, 22 Jul 2015 15:26:08 -0300 Subject: [PATCH] regression: better format errors, making easy to read the output --- test/regression/regression.cc | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/regression/regression.cc b/test/regression/regression.cc index a102f11f..13ea3a31 100644 --- a/test/regression/regression.cc +++ b/test/regression/regression.cc @@ -71,13 +71,26 @@ void perform_unit_test(std::vector *tests, r.status = 200; (*count)++; + size_t offset = t->filename.find_last_of("/\\"); + std::string filename(""); + if (offset != std::string::npos) { + filename = std::string(t->filename, offset + 1, + t->filename.length() - offset - 1); + } else { + filename = t->filename; + } + std::cout << std::setw(3) << std::right << + std::to_string(*count) << " "; + std::cout << std::setw(50) << std::left << filename; + std::cout << std::setw(60) << std::left << t->name; + modsec = new ModSecurity::ModSecurity(); modsec->setConnectorInformation("ModSecurity-regression v0.0.1-alpha" \ " (ModSecurity regression test utility)"); modsec_rules = new ModSecurity::Rules(debug_log); if (modsec_rules->load(t->rules.c_str()) == false) { - std::cerr << "Problems parsing the rules, aborting!" << std::endl; + std::cerr << "parse failed." << std::endl; return; } modsec_assay = new ModSecurity::Assay(modsec, modsec_rules); @@ -146,19 +159,6 @@ end: CustomDebugLog *d = reinterpret_cast (modsec_rules->debug_log); - size_t offset = t->filename.find_last_of("/\\"); - std::string filename(""); - if (offset != std::string::npos) { - filename = std::string(t->filename, offset + 1, - t->filename.length() - offset - 1); - } else { - filename = t->filename; - } - std::cout << std::setw(3) << std::right << - std::to_string(*count) << " "; - std::cout << std::setw(50) << std::left << filename; - std::cout << std::setw(60) << std::left << t->name; - if (!d->contains(t->debug_log)) { std::cout << "Debug log was not matching the expected results."; std::cout << std::endl;