Skip to content

Extract mod-comparison logic into cmd/moddiff tool - #122

Merged
argonui merged 1 commit into
mainfrom
refactor/moddiff-tool
Aug 4, 2026
Merged

Extract mod-comparison logic into cmd/moddiff tool#122
argonui merged 1 commit into
mainfrom
refactor/moddiff-tool

Conversation

@argonui

@argonui argonui commented Aug 3, 2026

Copy link
Copy Markdown
Owner

compare_test.go held TestDiff, which returned immediately unless -moda/-modb flags were passed. It therefore never ran in CI and left the root package reporting a misleading ok ... 0.0%. It was a manual mod-comparison CLI, not a test.

This PR moves the comparison logic (compareDelta, toObjArray, compareObjArrays, convertToMetaMap, compareObjs, ignoreUnpredictable) out of the test and into a real command, cmd/moddiff/main.go:

  • Takes two mod-file paths via -a/-b.
  • Prints the differences and exits non-zero when the mods differ or a file can't be read; exits 0 when equivalent.
  • The parts that used *testing.T/t.Errorf now accumulate differences on a small differ type and print them, rather than failing a test.
  • github.com/google/go-cmp still does the actual diffing.
  • TestDiff and its now-unused helpers are removed; the root package no longer has a test file (it never exercised the root package anyway).

Verification:

  • go build ./..., go vet ./..., go test ./... all clean/green.
  • Running the tool on two copies of tests/testdata/e2e/basic_objects.json prints no differences and exits 0; diffing against a different file exits non-zero.

Fixes #102

TestDiff in compare_test.go was never a real test: it returned early
unless -moda/-modb flags were passed, so it never ran in CI and left the
root package reporting a misleading "ok ... 0.0%" coverage. It was really
a manual mod-comparison CLI wearing a test's clothes.

Move the comparison logic (compareDelta, toObjArray, compareObjArrays,
convertToMetaMap, compareObjs, ignoreUnpredictable) into a real command,
cmd/moddiff, that takes two mod-file paths via -a/-b, prints the
differences, and exits non-zero when the mods differ or a file can't be
read. The parts that leaned on *testing.T now accumulate differences on a
small differ type and print them. go-cmp still does the actual diffing.

Removing TestDiff leaves the root package with no test file, which is
fine given the "test" never exercised the root package anyway.

Fixes #102

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@argonui
argonui force-pushed the refactor/moddiff-tool branch from a82cb3b to c45017f Compare August 4, 2026 03:09
@argonui
argonui merged commit e3c48c5 into main Aug 4, 2026
1 check passed
@argonui
argonui deleted the refactor/moddiff-tool branch August 4, 2026 03:09
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.

TestDiff never runs in CI

1 participant