acceptance: exit cleanly from -update when only regenerating outputs#5424
Draft
janniklasrose wants to merge 1 commit into
Draft
acceptance: exit cleanly from -update when only regenerating outputs#5424janniklasrose wants to merge 1 commit into
janniklasrose wants to merge 1 commit into
Conversation
The acceptance harness exited non-zero whenever `-update` applied a change: doComparison called AssertEqualTexts (which flags the test failed) and only overwrote the golden file afterwards. Since the test flag, not the write, drives the exit code, every regenerated file made `go test ... -update` exit 1 even though the update succeeded. Regenerating outputs is the goal of -update, not a failure. Move the OverwriteMode write/remove handling into an early-return block so a successful update returns without marking the test failed; only genuine problems still fail (read errors via tryReading, write errors via require/testutil, and the "both files missing" case). The non-update comparison path is unchanged. This lets generate-refschema drop its `ignore_error: true` workaround (and the `&> /dev/null` redirect that hid genuine errors), and makes test-update / test-update-templates / test-update-aws exit 0 on changes as intended. Co-authored-by: Isaac
denik
reviewed
Jun 3, 2026
| // The test no longer produces this output; drop the stale reference. | ||
| t.Logf("Removing output file: %s", relPath) | ||
| require.NoError(t, os.Remove(pathRef)) | ||
| case !okRef && okNew: |
Contributor
There was a problem hiding this comment.
this also handled below and produces error there
|
|
||
| // The test did not produce an expected output file. | ||
| if okRef && !okNew { | ||
| t.Errorf("Missing output file: %s", relPath) |
Contributor
There was a problem hiding this comment.
would not removing t.Errorf be enough? (for cleaner diff)
Collaborator
|
Commit: 5279b90 |
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.
Changes
Why
The acceptance harness exited non-zero whenever
-updateapplied a change: doComparison called AssertEqualTexts (which flags the test failed) and only overwrote the golden file afterwards. Since the test flag, not the write, drives the exit code, every regenerated file madego test ... -updateexit 1 even though the update succeeded.Regenerating outputs is the goal of -update, not a failure. Move the OverwriteMode write/remove handling into an early-return block so a successful update returns without marking the test failed; only genuine problems still fail (read errors via tryReading, write errors via require/testutil, and the "both files missing" case). The non-update comparison path is unchanged.
This lets generate-refschema drop its
ignore_error: trueworkaround (and the&> /dev/nullredirect that hid genuine errors), and makes test-update / test-update-templates / test-update-aws exit 0 on changes as intended.Tests
Co-authored-by: Isaac