Skip to content

add ISO 3166-1 source verification test - #17

Open
gronke wants to merge 1 commit into
mikelodder7:mainfrom
gronke:iso-3166-oracle
Open

add ISO 3166-1 source verification test#17
gronke wants to merge 1 commit into
mikelodder7:mainfrom
gronke:iso-3166-oracle

Conversation

@gronke

@gronke gronke commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

This is a proposal, offered as working code so the discussion has something concrete; happy to adjust or drop any part of it.

The country! table in lib.rs is maintained by hand, and it is correct: every (alpha2, alpha3, numeric) triple matches the ISO 3166-1 data of the Debian iso-codes project (the transcription of the official ISO publication that most distributions ship), with XK as the deliberate user-assigned extra.
What the crate cannot currently prove is that this stays true: ISO amends the standard occasionally, and nothing would notice a divergence today.

This PR adds that proof:

  • tests/iso_oracle.rs compares the full table against a committed snapshot of iso-codes' iso_3166-1.json, failing on any difference in either direction, with a documented exception list (XK).
  • The snapshot stays repository-only: the package include list ships tests/*.rs alone, so the published crate remains exactly Apache-2.0 OR MIT. For the repository itself the fixture's terms are handled the way LICENSE-UNICODE already handles the CLDR data: tests/fixtures/README.md carries the source and copyright notice, and the LGPL-2.1 text sits next to the file it covers, scoped to it alone. If you would rather keep the repository entirely free of LGPL material, the same check can instead read /usr/share/iso-codes/json/iso_3166-1.json from the CI runner after installing the iso-codes package (skipping gracefully where it is absent); say the word and I rework it that way.
  • The README gains a short Data provenance section stating the check.

No CI changes required: the existing workflow's cargo test --all-features picks the test up.

The country table is hand-maintained; this proves every (alpha2, alpha3,
numeric) triple against a committed snapshot of the Debian iso-codes
project's ISO 3166-1 data, with XK as the one documented entry beyond
the standard. The snapshot stays repository-only via the package include
list, so its LGPL terms never enter the published crate.

Signed-off-by: Stefan Grönke <stefan@gronke.net>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (431ec6a) to head (c703637).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #17   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          268       268           
=========================================
  Hits           268       268           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mikelodder7

Copy link
Copy Markdown
Owner

hmm, when I do a package and extract test which is what crates.io does, I get

error: couldn't read `tests/fixtures/iso_3166-1.json`: No such file or directory
  --> tests/iso_oracle.rs:31:30

Anyone running the test suite from the crates.io package — which is exactly what distro packagers do, ironically the Debian folks this fixture comes from — get a compile failure. cargo package's verify step doesn't catch it because it only builds the lib. Current main doesn't have this problem, so it's a genuine regression introduced by this PR.

We could just exclude iso_oracle.rs from the package which seems simple enough. Is that something you'd be willing to do?

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.

3 participants