Convert unit tests to Catch framework and fix compilation issues#8760
Open
tautschnig wants to merge 8 commits intodiffblue:developfrom
Open
Convert unit tests to Catch framework and fix compilation issues#8760tautschnig wants to merge 8 commits intodiffblue:developfrom
tautschnig wants to merge 8 commits intodiffblue:developfrom
Conversation
Move unit/cpp_parser.cpp to unit/cpp/cpp_parser.cpp, convert from standalone main() to Catch TEST_CASE, and add module_dependencies.txt. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Move unit/cpp_scanner.cpp to unit/cpp/cpp_scanner.cpp, convert from standalone main() to Catch TEST_CASE, and fix scanner initialization to use the token buffer's internal ansi_c_parser. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Move unit/elf_reader.cpp to unit/goto-programs/elf_reader.cpp, convert from standalone main() to Catch TEST_CASE, and update exception type from const char* to deserialization_exceptiont. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
1e96a2b to
f8710c1
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8760 +/- ##
===========================================
+ Coverage 80.01% 80.05% +0.03%
===========================================
Files 1700 1707 +7
Lines 188338 188791 +453
Branches 73 73
===========================================
+ Hits 150695 151129 +434
- Misses 37643 37662 +19 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR modernizes a set of legacy unit tests by converting them to the Catch framework, fixing prior compilation issues, and ensuring they are built as part of the unit test suite (Fixes #879).
Changes:
- Replaced old standalone
main()-based test programs with CatchTEST_CASEs for JSON parsing, SMT2 parsing, ELF reading, weakest precondition, and C++ parser/scanner. - Updated unit test build integration (CMake and Makefile) and module dependency declarations to include the new tests.
- Removed the previously excluded/non-building legacy unit test sources.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| unit/wp.cpp | Removes legacy standalone WP test program. |
| unit/util/module_dependencies.txt | Adds json dependency for util unit tests. |
| unit/util/json.cpp | Adds Catch-based JSON parser unit tests. |
| unit/util/ieee_float.cpp | Extends IEEE-float unit tests; adds randomized arithmetic/comparison/conversion coverage. |
| unit/solvers/smt2/smt2_parser.cpp | Adds Catch-based SMT2 parser unit tests. |
| unit/smt2_parser.cpp | Removes legacy standalone SMT2 parser test program. |
| unit/json.cpp | Removes legacy standalone JSON parser test program. |
| unit/ieee_float.cpp | Removes legacy standalone IEEE float test program. |
| unit/goto-programs/wp.cpp | Adds Catch-based weakest-precondition unit tests using a temporary C file. |
| unit/goto-programs/module_dependencies.txt | Adds langapi dependency for goto-programs unit tests. |
| unit/goto-programs/elf_reader.cpp | Adds Catch-based ELF reader unit tests. |
| unit/elf_reader.cpp | Removes legacy standalone ELF reader test program. |
| unit/cpp_scanner.cpp | Removes legacy standalone C++ scanner test program. |
| unit/cpp_parser.cpp | Removes legacy standalone C++ parser test program. |
| unit/cpp/module_dependencies.txt | Declares dependencies for new unit/cpp/* tests. |
| unit/cpp/cpp_scanner.cpp | Adds Catch-based C++ scanner/tokenization unit tests. |
| unit/cpp/cpp_parser.cpp | Adds Catch-based C++ parser unit tests. |
| unit/Makefile | Adds new unit test sources to the Makefile build. |
| unit/CMakeLists.txt | Stops excluding the old non-building test sources so new Catch tests are included via glob. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Move unit/wp.cpp to unit/goto-programs/wp.cpp, convert from standalone main() to Catch TEST_CASE, and fix API changes: ansi_c_languaget no longer takes message_handler in constructor, parse()/typecheck() now require message_handlert&, and goto_instructiont members code/guard are now accessed via code()/condition() methods. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Move unit/json.cpp to unit/util/json.cpp and convert from standalone main() to Catch TEST_CASE. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Move unit/smt2_parser.cpp to unit/solvers/smt2/smt2_parser.cpp and rewrite completely. The old test subclassed smt2_parsert with virtual callback overrides, but the parser API has been redesigned and no longer supports that pattern. The new test uses the current API directly (parse(), exit flag, id_map). Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
Move unit/ieee_float.cpp to unit/util/ieee_float.cpp (merging into the existing file), convert from standalone main() to Catch TEST_CASE, and fix API changes: use ieee_floatt with rounding mode for arithmetic operators, change ieee_equal/ieee_not_equal from free functions to member calls, use ieee_floatt for build(), and add #include <cfloat>. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
The old unit/osx_fat_reader.cpp was removed in ad5c4f9. The exclusion line in CMakeLists.txt is now dead code. A proper Catch test already exists at unit/goto-programs/osx_fat_reader.cpp. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
f8710c1 to
9b88166
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We had some pre-Catch-era unit tests still lying around unmaintained and unused. Alas, they wouldn't even compile anymore. Compilation issues are now fixed and they are embedded in the Catch framework.
Fixes: #879