From b0983e36c02e3cdfddee62250f073896a901923a Mon Sep 17 00:00:00 2001 From: Aron Helser Date: Tue, 17 Dec 2019 16:54:39 -0500 Subject: [PATCH] Modify TestReadWrite to not rely on asserts. Should fail in release builds now. --- .gitlab/ci/ctest_exclusions.cmake | 2 -- smtk/attribute/json/jsonGroupItem.cxx | 16 +++++++++------- smtk/attribute/testing/cxx/TestReadWrite.cxx | 17 +++++++++++------ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake index 7751fad9c3..5bb03ca45f 100644 --- a/.gitlab/ci/ctest_exclusions.cmake +++ b/.gitlab/ci/ctest_exclusions.cmake @@ -1,6 +1,4 @@ set(test_exclusions - # Issue #296. - "TestReadWrite" ) string(REPLACE ";" "|" test_exclusions "${test_exclusions}") if (test_exclusions) diff --git a/smtk/attribute/json/jsonGroupItem.cxx b/smtk/attribute/json/jsonGroupItem.cxx index f28796cc8b..d8e6e34d87 100644 --- a/smtk/attribute/json/jsonGroupItem.cxx +++ b/smtk/attribute/json/jsonGroupItem.cxx @@ -120,7 +120,7 @@ SMTKCORE_EXPORT void from_json(const json& j, smtk::attribute::GroupItemPtr& ite else { smtkErrorMacro(smtk::io::Logger::instance(), "JSON missing NumberOfGroups " - << "for extensible group item:" << itemPtr->name()); + << " for extensible group item: " << itemPtr->name()); return; } } @@ -139,8 +139,8 @@ SMTKCORE_EXPORT void from_json(const json& j, smtk::attribute::GroupItemPtr& ite auto cluster = groupClusters->find(clusterName); if (cluster == groupClusters->end()) { - smtkErrorMacro(smtk::io::Logger::instance(), "JSON missing " - << clusterName << "for group item:" << itemPtr->name()); + smtkErrorMacro(smtk::io::Logger::instance(), + "JSON missing: " << clusterName << " for group item: " << itemPtr->name()); continue; } for (size_t itemPGIter = 0; itemPGIter < m; itemPGIter++) @@ -149,15 +149,17 @@ SMTKCORE_EXPORT void from_json(const json& j, smtk::attribute::GroupItemPtr& ite auto itemJson = cluster->find(itemName); if (itemJson == cluster->end()) { - smtkErrorMacro(smtk::io::Logger::instance(), "JSON missing index:" - << itemName << "for cluster:" << clusterName << "for group item:" << itemPtr->name()); + smtkErrorMacro(smtk::io::Logger::instance(), + "JSON missing index: " << itemName << " for cluster: " << clusterName + << " for group item: " << itemPtr->name()); continue; } auto itemValue = itemJson->find("ItemValue"); if (itemValue == itemJson->end()) { - smtkErrorMacro(smtk::io::Logger::instance(), "JSON missing ItemValue for index:" - << itemName << "for cluster:" << clusterName << "for group item:" << itemPtr->name()); + smtkErrorMacro(smtk::io::Logger::instance(), + "JSON missing ItemValue for index: " << itemName << " for cluster: " << clusterName + << " for group item: " << itemPtr->name()); continue; } auto groupItemPtr = itemPtr->item(groupIter, itemPGIter); diff --git a/smtk/attribute/testing/cxx/TestReadWrite.cxx b/smtk/attribute/testing/cxx/TestReadWrite.cxx index bc57b8e721..a087ed426f 100644 --- a/smtk/attribute/testing/cxx/TestReadWrite.cxx +++ b/smtk/attribute/testing/cxx/TestReadWrite.cxx @@ -63,7 +63,7 @@ int main(int argc, char** argv) { if (argc == 1) { - std::cout << "Usage: TestReadWrite /path/to/input1.sbi /path/to/input2.sbi..." << std::endl; + std::cerr << "Usage: TestReadWrite /path/to/input1.sbi /path/to/input2.sbi..." << std::endl; return 1; } @@ -73,7 +73,7 @@ int main(int argc, char** argv) { std::string inputFileName(argv[i]); - std::cout << "Testing " << inputFileName << std::endl; + std::cerr << "Testing " << inputFileName << std::endl; // 1. Read the .sbi file into a new attribute resource @@ -187,6 +187,7 @@ int main(int argc, char** argv) { std::cerr << "Encountered Errors while writing " << sbi2FileName << "\n"; std::cerr << logger.convertToString(); + cleanup(sbi2FileName); return -2; } else if (smtk::io::Logger::instance().numberOfRecords()) @@ -199,6 +200,7 @@ int main(int argc, char** argv) // 6. Compare the .sbi files generated in steps 2 and 5 + int status = 0; { std::ifstream f1(sbi1FileName, std::ifstream::binary | std::ifstream::ate); std::ifstream f2(sbi2FileName, std::ifstream::binary | std::ifstream::ate); @@ -209,7 +211,7 @@ int main(int argc, char** argv) std::cerr << "generated smtk file: " << smtkFileName << "\n"; std::cerr << "generated sbi1 file: " << sbi1FileName << "\n"; std::cerr << "generated sbi2 file: " << sbi2FileName << "\n"; - assert(false); + status = -1; } if (f1.tellg() != f2.tellg()) @@ -218,7 +220,7 @@ int main(int argc, char** argv) std::cerr << "generated smtk file: " << smtkFileName << "\n"; std::cerr << "generated sbi1 file: " << sbi1FileName << "\n"; std::cerr << "generated sbi2 file: " << sbi2FileName << "\n"; - assert(false); + status = -1; } f1.seekg(0, std::ifstream::beg); @@ -230,15 +232,18 @@ int main(int argc, char** argv) std::cerr << "generated smtk file: " << smtkFileName << "\n"; std::cerr << "generated sbi1 file: " << sbi1FileName << "\n"; std::cerr << "generated sbi2 file: " << sbi2FileName << "\n"; - assert(false); + status = -1; } } // Clean up all generated files - cleanup(smtkFileName); cleanup(sbi1FileName); cleanup(sbi2FileName); + if (status != 0) + { + return status; + } } std::cout << "Pass all file tests" << std::endl; -- GitLab