{{ message }}
Repository navigation
chore(tests): parallelize pkg/config tests (partial — t.Setenv users stay serial) - #175
Merged
Merged
Conversation
Contributor
Member
Author
|
@coderabbitai review |
Contributor
✅ Actions performedReview triggered.
|
Member
Author
|
@coderabbitai review |
Contributor
✅ Actions performedReview triggered.
|
Contributor
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/config/config_test.go (1)
58-60: Handle working-directory setup/teardown errors explicitly.Line 58 and Line 60 currently ignore errors; if either fails, the test can leak state or mask root cause.
Suggested hardening
- orig, _ := os.Getwd() + orig, err := os.Getwd() + require.NoError(t, err) require.NoError(t, os.Chdir(dir)) - t.Cleanup(func() { os.Chdir(orig) }) + t.Cleanup(func() { require.NoError(t, os.Chdir(orig)) })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/config/config_test.go` around lines 58 - 60, The test currently ignores errors from os.Getwd() and the cleanup os.Chdir(orig); update the setup to check and fail the test on error (use require.NoError or t.Fatalf) for os.Getwd() and the initial os.Chdir(dir), and change the t.Cleanup closure to capture and handle the error returned by os.Chdir(orig) (call require.NoError or log/fatal inside the closure) so any failure to restore the working directory is surfaced; reference the os.Getwd, os.Chdir and t.Cleanup calls in pkg/config/config_test.go when making these changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/config/config_test.go`:
- Around line 58-60: The test currently ignores errors from os.Getwd() and the
cleanup os.Chdir(orig); update the setup to check and fail the test on error
(use require.NoError or t.Fatalf) for os.Getwd() and the initial os.Chdir(dir),
and change the t.Cleanup closure to capture and handle the error returned by
os.Chdir(orig) (call require.NoError or log/fatal inside the closure) so any
failure to restore the working directory is surfaced; reference the os.Getwd,
os.Chdir and t.Cleanup calls in pkg/config/config_test.go when making these
changes.
cristim
added a commit
that referenced
this pull request
Apr 28, 2026
Per CodeRabbit nitpick on PR #175: TestLoad_MissingDefaultFile_NoError ignored errors from os.Getwd() and the t.Cleanup os.Chdir(orig). If either fails the test could leak working-directory state into other tests or mask the root cause of a failure. Wrap both in require.NoError.
…stay serial) Per-test classification (10 parallel + 8 documented-serial): Parallel (10) — pure, no env/chdir/global mutation: - TestLoad_Defaults - TestLoad_ExplicitMissingFile_Error - TestLoad_YAMLFile - TestLoad_InvalidYAML_Error - TestLoad_DryRunAndPurchaseConflict - TestLoad_PurchaseFlagSetsDryRunFalse - TestLoad_UnknownCloud_Error - TestLoad_NegativeThreshold_Error - TestValidate_EmptyEnabledClouds_Error - TestLoad_YAMLRoundtrip Serial (8) — Go's t.Setenv / os.Chdir mutate process-wide state and panic if combined with t.Parallel(). Each gets an inline NOT-parallel comment so future contributors don't accidentally add t.Parallel(): - TestLoad_MissingDefaultFile_NoError (os.Chdir) - TestLoad_EnvOverridesYAML (t.Setenv) - TestLoad_EnvVars (t.Setenv x11) - TestLoad_InvalidEnvVar_Error (t.Setenv) - TestLoad_InvalidDurationEnvVar_Error (t.Setenv) - TestLoad_FlagOverridesEnvAndYAML (t.Setenv) - TestLoad_CUDLYCONFIGEnv (t.Setenv) - TestLoad_ArgPathTakesPrecedenceOverCUDLYCONFIG (t.Setenv) Verified: `go test -race -count=2 ./config/...` (from pkg/) passes cleanly twice. Refs #58
Per CodeRabbit nitpick on PR #175: TestLoad_MissingDefaultFile_NoError ignored errors from os.Getwd() and the t.Cleanup os.Chdir(orig). If either fails the test could leak working-directory state into other tests or mask the root cause of a failure. Wrap both in require.NoError.
cristim
force-pushed
the
chore/tparallel-pkg-config
branch
from
April 29, 2026 22:50
e33cbcf to
e963008
Compare
Member
Author
|
Rebased onto current |
Contributor
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.

Summary
Continues the
t.Parallel()adoption sweep from #58. This PR targetspkg/config/and uses the standard Go testing mixed-mode pattern: 10 pure tests are parallelised, while 8 tests that mutate process-wide state (t.Setenv/os.Chdir) intentionally remain serial — Go'st.Setenvpanics if combined witht.Parallel(), so making them parallel is not a "fix" but a regression.To prevent future contributors from accidentally adding
t.Parallel()to the serial tests, each one carries an inline// NOT parallel: ...comment explaining why.Per-test classification
Parallel (10) — pure, no env/chdir/global mutation:
TestLoad_DefaultsTestLoad_ExplicitMissingFile_ErrorTestLoad_YAMLFileTestLoad_InvalidYAML_ErrorTestLoad_DryRunAndPurchaseConflictTestLoad_PurchaseFlagSetsDryRunFalseTestLoad_UnknownCloud_ErrorTestLoad_NegativeThreshold_ErrorTestValidate_EmptyEnabledClouds_ErrorTestLoad_YAMLRoundtripSerial (8) — documented in-source:
TestLoad_MissingDefaultFile_NoError—os.ChdirTestLoad_EnvOverridesYAML—t.SetenvTestLoad_EnvVars—t.Setenv(×11)TestLoad_InvalidEnvVar_Error—t.SetenvTestLoad_InvalidDurationEnvVar_Error—t.SetenvTestLoad_FlagOverridesEnvAndYAML—t.SetenvTestLoad_CUDLYCONFIGEnv—t.SetenvTestLoad_ArgPathTakesPrecedenceOverCUDLYCONFIG—t.SetenvOut of scope
internal/config/(Postgres integration tests — explicitly deferred per chore(tests): finish t.Parallel() adoption sweep across remaining packages #58 body, needs a separate refactor).t.Setenvusers to a different env-injection pattern — would change the test design rather than just parallelise.Test plan
cd pkg && go test -race -count=2 ./config/...passes cleanly twice locallyRefs #58
Summary by CodeRabbit