Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename *test.Test* identifiers #3260

Merged
merged 15 commits into from
Aug 5, 2024

Conversation

ARR4N
Copy link
Contributor

@ARR4N ARR4N commented Aug 2, 2024

Why this should be merged

Because Stephen said so. Also https://google.github.io/styleguide/go/decisions#repetition but mainly the former.

How this works

  1. Functions that explicitly run tests maintain the Test*(*testing.T... prefix, in keeping with stdlib fstest, iotest, and slogtest. This signals at the call site that a test is actually being performed. Similarly for Benchmark and Fuzz.
  2. Test doubles and other top-level identifiers have the Test prefix/suffix elided because they are always referred to by their package-qualified name *test.Thing.
  3. tb.Helper() is not added to Test* and Benchmark* functions as this would report the call site as being in the package under test, which isn't useful in debugging.
  4. Argument order is updated to ([context.Context], testing.TB, ...) because pedantry.
  5. Tests accepting require.Assertions are changed to accept testing.TB as require is an implementation detail.
  6. Suites of tests are run as sub tests with t.Run(). A failure in one causing others to not run results in whack-a-mole debugging. This may not be comprehensive.

All *test packages were checked for conformity with the above. Those that have no changes were already compliant.

How this was tested

CI

@ARR4N ARR4N marked this pull request as ready for review August 2, 2024 14:13
Base automatically changed from arr4n/test-packages-over-tags to master August 2, 2024 15:44
codec/hierarchycodec/codec_test.go Outdated Show resolved Hide resolved
ids/galiasreader/alias_reader_test.go Outdated Show resolved Hide resolved
snow/engine/enginetest/sender.go Show resolved Hide resolved
Comment on lines +26 to +29
// TestState is an alias for State because ava-labs/coreth uses the original
// identifier and this change would otherwise break the build.
//
// Deprecated: use [State].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so there will be a subsequent coreth PR to clean it up, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember. Otherwise this will become lost to the sands of time. But at least nobody else will use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StephenButtolph StephenButtolph added this pull request to the merge queue Aug 5, 2024
@StephenButtolph StephenButtolph added this to the v1.11.11 milestone Aug 5, 2024
@StephenButtolph StephenButtolph added testing This primarily focuses on testing cleanup Code quality improvement labels Aug 5, 2024
Merged via the queue into master with commit 7e985b5 Aug 5, 2024
20 checks passed
@StephenButtolph StephenButtolph deleted the arr4n/stutter-test-pkgs branch August 5, 2024 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code quality improvement testing This primarily focuses on testing
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants