Extract mod-comparison logic into cmd/moddiff tool - #122
Merged
Conversation
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
force-pushed
the
refactor/moddiff-tool
branch
from
August 4, 2026 03:09
a82cb3b to
c45017f
Compare
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.
compare_test.goheldTestDiff, which returned immediately unless-moda/-modbflags were passed. It therefore never ran in CI and left the root package reporting a misleadingok ... 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:-a/-b.*testing.T/t.Errorfnow accumulate differences on a smalldiffertype and print them, rather than failing a test.github.com/google/go-cmpstill does the actual diffing.TestDiffand 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.tests/testdata/e2e/basic_objects.jsonprintsno differencesand exits 0; diffing against a different file exits non-zero.Fixes #102