Skip to content

chore: Migrate tests to cmp package - #760

Merged
SuperQ merged 1 commit into
masterfrom
superq/cmp
Oct 27, 2025
Merged

SuperQ merged 1 commit into
masterfrom
superq/cmp

Conversation

@SuperQ

@SuperQ SuperQ commented Oct 26, 2025

Copy link
Copy Markdown
Member

Migrate the majority of diff tests from reflect.DeepEqual() to cmp.Diff() to improve the test failure readability.

Migrate the majority of diff tests from `reflect.DeepEqual()` to
`cmp.Diff()` to improve the test failure readability.
* Fixup Copyright lines

Signed-off-by: SuperQ <superq@gmail.com>
@SuperQ
SuperQ merged commit b8b5106 into master Oct 27, 2025
8 checks passed
@SuperQ
SuperQ deleted the superq/cmp branch October 27, 2025 07:28
@SuperQ

SuperQ commented Oct 27, 2025

Copy link
Copy Markdown
Member Author

Tool assisted speedrun:

#!/usr/bin/env bash
#
# Description: Convert refelect tests to cmp.
#

if [[ $# -ne 1 ]]; then
  echo "usage: $(basename $0) <file>"
  exit 1
fi

file="$1"

if [[ ! -f "${file}" ]] ; then
  echo "ERROR: ${file} not found"
  exit 1
fi

sed_script="$(cat << 'SEDSCRIPT'
s/if !reflect.DeepEqual\((.+), (.+)\) \{/if diff := cmp.Diff(\1, \2); diff != "" {\nt.Fatalf("unexpected diff (-want +got):\\n\%s", diff)/
SEDSCRIPT
)"

sed -i -E "${sed_script}" "${file}"

goimports -w "${file}"

go fmt "${file}"

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.

2 participants