Configure test fixture using CTest for Windows build

- Added new test/test_suite.in with list of regression and unit tests
  previously in Makefile.am, to be shared between Unix and Windows
  builds.
- Updated regression.cc & unit.cc to return the number of failed tests
  to indicate to CTest that the test failed. Similarly, a crash or
  unhandled exception terminates the process with a non-zero exit code.
  - This change doesn't affect running the tests with autotest in Unix
    builds because this processes test output from custom-test-driver &
    test-suite.sh, and ignores the exit code of the test runner.
- Removed comment in test/test-cases/regression-offset-variable.json as
  this is not supported by JSON and prevents strict parsers to read and
  process the file.
- Minor change in regression.cc's clearAuditLog to replace std::ifstream
  with std::ofstream as the mode to open the flag applies to an output
  stream.
- Minor change in unit.cc to simplify code that deletes tests.
- Minor changes to test/custom-test-driver to correct usage information.
This commit is contained in:
Eduardo Arias
2024-05-11 14:52:32 +00:00
parent a8e132f3a1
commit e6e2989bd5
9 changed files with 338 additions and 282 deletions

View File

@@ -195,6 +195,10 @@ int main(int argc, char **argv) {
std::cout << t->print() << std::endl;
}
const int skp = std::count_if(results.cbegin(), results.cend(), [](const auto &i)
{ return i->skipped; });
const int failed = results.size() - skp;
if (!test.m_automake_output) {
std::cout << std::endl;
@@ -202,13 +206,7 @@ int main(int argc, char **argv) {
if (results.size() == 0) {
std::cout << KGRN << "All tests passed" << RESET << std::endl;
} else {
int skp = 0;
for (const auto &i : results) {
if (i->skipped == true) {
skp++;
}
}
std::cout << KRED << results.size()-skp << " failed.";
std::cout << KRED << failed << " failed.";
std::cout << RESET << std::endl;
if (skp > 0) {
std::cout << " " << std::to_string(skp) << " ";
@@ -217,13 +215,12 @@ int main(int argc, char **argv) {
}
}
for (std::pair<std::string, std::vector<UnitTest *> *> a : test) {
std::vector<UnitTest *> *vec = a.second;
for (int i = 0; i < vec->size(); i++) {
delete vec->at(i);
}
for (auto a : test) {
auto *vec = a.second;
for(auto *t : *vec)
delete t;
delete vec;
}
return failed;
}