Skip to content

Minor refactoring of acceptance_test.go: print warnings on closing errors #2545

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

Closed
wants to merge 1 commit into from

Conversation

anton-107
Copy link
Contributor

@anton-107 anton-107 commented Mar 21, 2025

Changes

  1. Explicitly print errors on closing files and pipes
  2. Fix typos
  3. Omit variable type declaration for VerboseTest
  4. Remove if condition which is always true

Why

  1. While the ignored errors are subtle, printing them can be useful to catch possible edge cases in acceptance tests
    2-4. These changes suggest slightly more idiomatic source code

Tests

existing tests

@anton-107 anton-107 temporarily deployed to test-trigger-is March 21, 2025 11:13 — with GitHub Actions Inactive
@anton-107 anton-107 changed the title minor refactoring of acceptance_test.go: print warnings on closing er… Minor refactoring of acceptance_test.go: print warnings on closing er… Mar 21, 2025
@anton-107 anton-107 changed the title Minor refactoring of acceptance_test.go: print warnings on closing er… Minor refactoring of acceptance_test.go: print warnings on closing errors Mar 21, 2025
w.Close()
err := w.Close()
if err != nil {
t.Logf("Warning: failed to close pipe writer: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

was this caused by a real issue you saw?

prepares := []string{}
cleanups := []string{}
var prepares []string
var cleanups []string
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless we have agreed to one style over whole codebase let's avoid this type of changes.

@@ -542,7 +542,7 @@ func doComparison(t *testing.T, repls testdiff.ReplacementsContext, dirRef, dirN
}

// The test produced an unexpected output file.
if !okRef && okNew {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this changed? This deserves its own PR with explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this statement, if okRef is false, then okNew is always true due to a previous if !okRef && !okNew { return } statement in this method. Removing the second condition here makes it easier to comprehend this check. If you agree this is valuable, i will open a separate PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's easier to read (and more resilient to refactorings) if you don't need to know all the code before it.

Copy link

This PR has not received an update in a while. If you want to keep this PR open, please leave a comment below or push a new commit and auto-close will be canceled.

@github-actions github-actions bot added the Stale label May 21, 2025
@anton-107 anton-107 closed this May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants