Skip to content

test: simplify parser tests (#380 part 5) - #392

Merged
oglassdev merged 7 commits into
mainfrom
cleanup/parser-tests
Sep 24, 2026
Merged

oglassdev merged 7 commits into
mainfrom
cleanup/parser-tests

Conversation

@oglassdev

Copy link
Copy Markdown
Owner

Part 5 of #380: simplify the jet3 parser crate's tests. Only test code changed: *_tests.rs, tests.rs, testkit.rs, crates/jet3/tests/**, and the #[cfg(test)] mod lines for deleted files. Production code is unchanged.

Numbers

Before (origin/main) After
Tests (cargo test -p jet3) 843 passed + 6 ignored 633 passed + 6 ignored
Unit test files (src/) 122 102
Unit test lines (src/) 41,499 32,481
Integration test lines (tests/) 1,213 904
Prod line coverage (src/, tests excluded) 92.655% (24,257 / 26,180) 92.659% (24,258 / 26,180)
Prod region coverage 89.839% 89.832%

Coverage was measured with cargo llvm-cov -p jet3, excluding _tests.rs, tests.rs, testkit.rs and tests/. A diff-aligned per-line comparison found 0 prod lines that ran at baseline and no longer run. That includes every error, refusal and budget branch. Two branches lost coverage mid-cleanup, and each got a focused case back:

  • the encoded-bytes budget refusal in row/data_page.rs write_free
  • the duplicate-name refusal on the with-rows path in composer/table_create.rs

row/delete_page.rs gained one covered line. Region coverage fell by 7 regions (-0.007 pp), but no line lost coverage.

What changed

Shared builders (testkit). Added:

  • TestResult
  • table(name, columns, indexes) and index(name, fields, kind)
  • create(path, tables) and create_spec(path, spec)
  • validate_file(path)
  • TempDir::{target, is_empty, entries}

These replace 37 per-file TestResult aliases and 5 per-file temp-directory wrappers. About 250 TableSpec {..}/IndexSpec {..} literals and about 230 create_database(.., &mut budget()) calls were migrated to the new builders.

Relationships (18 → 16 files):

  • larger_relationship_graph merged into api_relationship_graph.
  • The composer's relationship_parameterized merged into relationship_tests, with its refusal cases table-driven and the exact detail strings kept.
  • Pairs of tests sharing a fixture were merged: orphan/generated-key, duplicate-name/self-orphan/budget, the self-reference pair and the one-to-one row pair.
  • Dropped a re-test of the reciprocal-index helper that every mutation test already uses, and a self-reference case covered by the composite full-replacement test.

Row mutation:

  • update_fixed and update_indexed folded into update_field_rewrite and update_key.
  • delete_compaction and delete_release folded into delete_tests, with one budget table over tail, compaction and release that keeps the exact and one-below limits.
  • insert_text_guid moved into insert_scalar_index.
  • mutation_empty moved into mutation_field.
  • The long-value corruption tests became one 11-case table that checks each error variant.
  • The create-index refusal loop was dropped because index_matrix covers it.
  • Per-operation publish-stage loops were dropped because every row write reaches the same write/driver.rs publish. The full stage loop stays in update_tests and write/atomic_tests.

Creation:

  • Files folded together:
    • memo_option into empty_value_options
    • initial_long_values into multiple_long_values
    • index_capacity into multiple_index
    • composite_index and multi_level_index into initial_index
  • 16 schema_plan refusals and the append/whole-file plan rejections are now table-driven.
  • Tests were deleted only when a per-test coverage run showed they covered no unique prod lines and another test made the same assertion. Examples are repeated "existing destination is refused" steps inside large tests, and duplicate case-folded-name and continuation checks.

Storage decoders:

  • Small files testing the same decoder were merged: table_pages/table_index_alias, catalog/overflow, reader_key_inventory/reader_prefix, writer_binary.
  • catalog/record_writer_tests was deleted. It tested an encoder defined inside the test file. Its one prod check, the catalog_record_len limits, moved to record_tests.
  • Copy-pasted corruption cases are now labelled tables: definition header/column/index, usage map, allocation map, traversal, row directory, index tree, name keys, scalar values.
  • Removed tests that only asserted Display/source() text of thiserror errors.

Format, validation and integration:

  • Near-identical exact / one-below / one-over limit tests are now tables across header, candidate, page, raw stream, commit state, binary writer and resource budget tests.
  • database_tests went from 24 tests to 9 table-driven tests.
  • tests/header_composition_properties.rs was deleted. It is uncited and repeated candidate and commit-region accounting that the unit tests already assert.
  • tests/atomic_publication.rs dropped its per-stage fault loop, which write/atomic_tests covers through the same hook. It keeps the concurrent-observer test.
  • Removed defaults_match_documented_policy, which asserted constants against themselves.

Deliberately kept

  • Every boundary check: 31/32 and 15/16 index counts, exact 1024-page limits, row capacity 2012/2013, inline map bit 1023/1024, name-length limits, and every exact / one-below budget limit.
  • Every corruption and malformed-input path, with its specific error variant.
  • Every atomic refusal: "leaves no file", "file unchanged", "no private copy left", "nothing charged on refusal".
  • Every DAO-derived byte and offset assertion tied to EXP-/SRC- entries, the ignored DAO export tools, and the locale collation vectors.
  • Every file cited in docs/validation/support-matrix.json, along with the tests demonstrating its capability. No doc or matrix path references a deleted file or test.

Checks

  • just ready passes: fmt, clippy -D warnings, workspace tests, docs, source size (≤800 lines per file) and contracts.
  • cargo check --target x86_64-pc-windows-gnu -p jet3 --all-targets is clean.

🤖 Generated with Claude Code

Add table/index/create/create_spec/validate_file helpers, TestResult and
TempDir::{target,is_empty,entries} to the parser testkit and migrate the
per-file TestResult aliases, directory wrappers and plain schema literals
to them. No test behavior changes.
Fold the fixed-field, indexed-update, text/GUID insert, delete compaction
and release, and empty-OLE files into their family files; share one
table-driven exact-budget/verification test across the delete shapes;
drop tests that re-assert the shared publish layer through each operation;
collapse repeated insert/delete boilerplate into fixture helpers.
Merge files that exercise the same decoder (table pages/alias into the
table-definition tests, catalog overflow into the cursor tests, index key
inventory/prefix into the tree reader tests, binary row trailers into the
wide-row tests), table-drive repeated corruption cases, share row-cursor
and read helpers, and drop Display/source-only error tests plus the
catalog record-writer tests that only exercised a test-local encoder.
…tests

Table-drive parallel boundary and limit cases, drop Display/source-chain checks and duplicated candidate/header-page failure paths, and remove integration tests that repeat unit-tested atomic publication and header composition paths.
@oglassdev
oglassdev merged commit 4c89384 into main Sep 24, 2026
10 checks passed
@oglassdev
oglassdev deleted the cleanup/parser-tests branch September 24, 2026 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant