Add code coverage enforcement and tests#11
Merged
Conversation
Cover the predicate-to-SQL WHERE clause translation paths: constant and compound predicates, NULL handling, string operators, IN/BETWEEN, to-many relationship membership subqueries, function-call comparisons, and error paths. Raises library line coverage to 94.75%.
COUNT(*) always returns a single integer row, so the guard's else branch is unreachable in practice; document that with an assertion.
Cover the storage-class-mismatch decode errors, integer overflow, decimal conversions, and the Binding accessor helpers.
Cover the to-many-on-to-one rejection and the row decode error paths (missing / non-text primary key).
Cover invalid expression shapes, function-call comparison edge cases (NULL, nested arguments, unsupported operators), and scalar/collection binding paths.
Cover to-many relationship writes, no-op upsert, invalid sort property, and custom-function arguments of every storage class.
Cover the symmetric self-relationship join paths (fetch/delete/membership UNION), a missing inverse relationship, and a fetch offset with no limit.
Emit a Cobertura report (coverage.xml) from the llvm-cov JSON, filtered to the library sources, for GitHub Code Quality's actions/upload-code-coverage.
Add the actions/upload-code-coverage step and code-quality:write permission so the coverage percentage surfaces on pull requests. fail-on-error is disabled while the feature is in public preview.
Code Coverage OverviewLanguages: Swift Swift / code-coverage/llvm-covThe overall coverage in the branch is 100%. Coverage data for the branch is not yet available. Show a code coverage summary of the most covered files.
Code Coverage is in Public Preview. Learn more and provide us with your feedback. |
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.
Adds code coverage tooling to CI, raises library coverage to effectively 100% of reachable code, and publishes coverage to GitHub Code Quality.
Changes
Tooling
Scripts/coverage.sh— runs the test suite with coverage instrumentation, exports LCOV (coverage.lcov) and Cobertura XML (coverage.xml) reports, and enforces a minimum line-coverage threshold (default 80%). Coverage is measured against theCoreModelSQLitelibrary sources only; dependencies, generated sources, and the test target are excluded. The Cobertura report is generated directly from the llvm-cov JSON with no external converter dependency.swift.yml) — newcoveragejob that:actions/upload-code-coverage@v1so the coverage percentage surfaces on pull requests (code-quality: writepermission;fail-on-error: falsewhile Code Quality is in public preview).build/coverage/as a build artifactTests (+51, all exercising behavior through the public API)
PredicateTests.swift— predicate-to-SQLWHEREtranslation: constant/compound predicates, NULL handling, string operators, IN/BETWEEN, to-many membership subqueries (join-table, foreign-key, and symmetric self-relationship branches), function-call comparisons, and error paths.AttributeValueTests.swift— binding round-trips and decode failures for every attribute type.ModelDataTests.swift— row decoding, partial upserts, invalid relationship values.Source
COUNT(*)fallback is now marked withassertionFailure, documenting it as an impossible state rather than an untested path.Result
The only remaining uncovered lines are defensive assertion paths that cannot execute without violating internal invariants.