Daily Test Coverage Improver: Add comprehensive API Datalog tests #7921
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.
Summary
This PR adds comprehensive test coverage for Z3's Datalog/fixedpoint API functions, improving coverage from 0% to 17% (84/486 lines) in
src/api/api_datalog.cpp.Problem Found
The Datalog API functions had zero test coverage despite being important functionality for logic programming and fixedpoint computation:
src/api/api_datalog.cpp: 0% coverage (0/486 lines covered)Actions Taken
src/test/api_datalog.cppsrc/test/main.cppandsrc/test/CMakeLists.txtZ3_mk_finite_domain_sort- Create finite domain sorts with specified sizeZ3_get_finite_domain_sort_size- Retrieve size of finite domain sortsZ3_mk_fixedpoint- Create fixedpoint contextZ3_fixedpoint_inc_ref/Z3_fixedpoint_dec_ref- Reference countingZ3_fixedpoint_to_string- String conversion for debuggingZ3_fixedpoint_get_statistics- Statistics retrievalZ3_fixedpoint_get_reason_unknown- Reason for unknown resultsTest Coverage Results
Before:
src/api/api_datalog.cpp: 0% coverage (0/486 lines)After:
src/api/api_datalog.cpp: 17% coverage (84/486 lines) - +84 lines coveredCoverage improvement breakdown:
Replicating the Test Coverage Measurements
Build and run the new test:
Expected Output:
Commands to install dependencies, build, run tests, and generate coverage reports:
Future Improvement Areas
Based on remaining uncovered areas in
api_datalog.cpp(17% → 100% potential):Z3_fixedpoint_query,Z3_fixedpoint_query_relationsfor executing datalog queriesZ3_fixedpoint_add_rulefor adding inference rulesZ3_fixedpoint_add_factfor adding base factsZ3_fixedpoint_from_string,Z3_fixedpoint_from_filefor loading datalog programsZ3_fixedpoint_get_answerfor retrieving query resultsZ3_fixedpoint_set_predicate_representationfor configuring predicatesZ3_get_relation_arity,Z3_get_relation_columnfor introspectionOther high-impact areas for future coverage improvements:
src/api/api_fpa.cpp(0% coverage, 1090 lines) - Floating-point arithmetic APIsrc/api/api_commands.cpp(0% coverage, 5687 lines) - Command interface functionsWorkflow Details
Bash Commands Run
git checkout -b daily-test-improver-api-datalog-testsninja test-z3./test-z3 api_dataloggcovr --merge-mode-functions=separate --gcov-ignore-parse-errors --gcov-executable "llvm-cov gcov" --filter ".*api_datalog.*" .git add src/test/api_datalog.cpp src/test/main.cpp src/test/CMakeLists.txtgit commit --author "Daily Test Coverage Improver <github-actions[bot]@users.noreply.github.com>" -m "..."Web Searches Performed
None
Web Pages Fetched
None