Skip to content

test: cover a few small pre-existing coverage gaps - #1126

Open
soloturn wants to merge 2 commits into
openzim:mainfrom
soloturn:test/misc-coverage-gaps
Open

soloturn wants to merge 2 commits into
openzim:mainfrom
soloturn:test/misc-coverage-gaps

Conversation

@soloturn

@soloturn soloturn commented Sep 1, 2026

Copy link
Copy Markdown

AI-assisted change proposal. Filed by agent driven by @soloturn via GDD.

Split out of #1119 - these tests aren't related to that PR's fd-based Xapian fix, they cover pre-existing gaps found while looking at overall project coverage.

Three small, targeted additions, each amending an existing test rather than adding new fixtures where one already existed:

  • Archive::getChecksum() had zero test coverage anywhere - added a check that it returns a valid 32-char hex digest.
  • Archive::getIllustrationItem(size) (the size-only overload, and its not-found EntryNotFound throw) was never called by any test, despite openCreatedArchive already building an archive with two real illustrations to exercise it on.
  • SearchIterator::getDbData()'s uninitialized-guard path was the one method missing from the otherwise-thorough search_iterator.uninitialized test.

(getIllustrationSizes() and SearchIterator::getSize() are both deprecated - left alone rather than fighting -Werror for soon-to-be-removed APIs.)

Verified: full local build + meson test, 31/31 passing, on top of plain main.

@kelson42 kelson42 added this to the 9.9.0 milestone Sep 1, 2026
@kelson42 kelson42 added the task label Sep 1, 2026
@soloturn
soloturn marked this pull request as draft September 1, 2026 15:21
@soloturn

soloturn commented Sep 2, 2026

Copy link
Copy Markdown
Author

AI-assisted change proposal comment. Filed by agent driven by @soloturn via GDD.

Local coverage measurement, main vs this branch's current head, full test suite both times (meson -Db_coverage=true + gcovr, src/ only):

Metric main this branch Δ
Lines 85.3% (5299/6209) 86.2% (5355/6209) +56 lines, +0.9pp
Functions 93.0% (1184/1273) 93.8% (1194/1273) +10 functions
Branches 43.4% (4360/10044) 44.0% (4424/10044) +64 branches, +0.6pp

Files newly at or near 100% that weren't before: buffer_reader.cpp (100%), entry.cpp (100%), version.cpp (100%, new file), writer/item.cpp (96%, was 64%), writer/contentProvider.cpp (96%, picked up incidentally from the StringItem/FileItem test).

This is my own gcovr methodology, not codecov's exact algorithm, so codecov's reported numbers may differ - but the underlying coverage gain is real and verified, each commit checked in isolation to confirm it actually hits the specific line/branch it targets, not just returns correct output through some other path.

@soloturn
soloturn marked this pull request as ready for review September 8, 2026 01:16

@veloman-yunkan veloman-yunkan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some commit messages mention "this PR" while obviously referring to a different PR.

Comment thread test/archive.cpp Outdated
Comment thread test/reader.cpp
Comment thread test/reader.cpp Outdated
Comment thread test/reader.cpp Outdated
Comment thread test/version.cpp Outdated
Comment thread test/version.cpp Outdated
Comment thread test/creator.cpp
soloturn added a commit to soloturn/libzim that referenced this pull request Oct 4, 2026
FileCompound::locate(offset,size) queried the part map with a single wide
Range covering the whole read. less_range's comparator isn't a strict weak
ordering for that case: the wide query can compare "equivalent" to two
disjoint stored part ranges at once, breaking transitivity. With 3+ parts
this can land lower_bound on the wrong part, underflowing the local-offset
computation in MultiPartFileReader (PR openzim#1126's expanded multiPartReads
test hits this on libc++).

Fixed by querying the two boundary points instead (locate(offset) above
already does this safely for a single point).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@soloturn
soloturn force-pushed the test/misc-coverage-gaps branch from 19cdba3 to c1c944e Compare October 4, 2026 17:36
soloturn added a commit to soloturn/libzim that referenced this pull request Oct 4, 2026
FileCompound::locate(offset,size) queried the part map with a single wide
Range covering the whole read. less_range's comparator isn't a strict weak
ordering for that case: the wide query can compare "equivalent" to two
disjoint stored part ranges at once, breaking transitivity. With 3+ parts
this can land lower_bound on the wrong part, underflowing the local-offset
computation in MultiPartFileReader (PR openzim#1126's expanded multiPartReads
test hits this on libc++).

Fixed by querying the two boundary points instead (locate(offset) above
already does this safely for a single point).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@soloturn
soloturn force-pushed the test/misc-coverage-gaps branch from c1c944e to 64e764e Compare October 4, 2026 17:47
@soloturn
soloturn force-pushed the test/misc-coverage-gaps branch from 64e764e to a5b214a Compare October 5, 2026 05:23
@kelson42

kelson42 commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

@veloman-yunkan I would like to consider closing this PR, I see no opportunity to get a full fix within a few iterations. What do you think?

soloturn and others added 2 commits October 5, 2026 18:50
FileCompound::locate(offset,size) queried the part map with a single wide
Range covering the whole read. less_range's comparator isn't a strict weak
ordering for that case: the wide query can compare "equivalent" to two
disjoint stored part ranges at once, breaking transitivity. With 3+ parts
this can land lower_bound on the wrong part, underflowing the local-offset
computation in MultiPartFileReader (PR openzim#1126's expanded multiPartReads
test hits this on libc++).

Fixed by querying the two boundary points instead (locate(offset) above
already does this safely for a single point).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Scanned overall project coverage for easy, self-contained gaps and
added tests for each, checking real content/behavior rather than
shape (hex-string length, non-empty, substring) wherever a reviewer
flagged that distinction:

- Archive::getChecksum(): checks the archive's actual checksum value,
  one expected hex digest per zim-testing-suite category.
- Archive::getIllustrationItem(size): the delegating overload and the
  not-found EntryNotFound throw, both previously uncalled.
- SearchIterator::getDbData(): the uninitialized-guard path.
- Reader::getMemorySize(): across all three Reader implementations,
  branching on real type (dynamic_cast) rather than factory identity.
- MultiPartFileReader: small/whole/boundary/large reads, aligned or
  not, against a synthetic 3-part compound (all 8 access patterns).
- Entry::getItem()'s redirect guard and multi-hop redirect chains.
- zim::getVersions()/printVersions(): full expected content, built the
  same way src/version.cpp does, not substring/non-empty checks.
- StringItem/FileItem round-trip, Item::getHints()'s base default, and
  getAmendedHints()'s FRONT_ARTICLE/COMPRESS mimetype guesses (both the
  zero and non-zero cases for each).

Verified: full local build + `meson test`, all passing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@soloturn
soloturn force-pushed the test/misc-coverage-gaps branch from a5b214a to b0ddd96 Compare October 5, 2026 16:50
@soloturn

soloturn commented Oct 8, 2026

Copy link
Copy Markdown
Author

@veloman-yunkan I would like to consider closing this PR, I see no opportunity to get a full fix within a few iterations. What do you think?

addressed @veloman-yunkan comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants