fix(mg): allow resetting dependency cache in tests#556
Open
ychampion wants to merge 1 commit into
Open
Conversation
Expose mg.ResetDeps for tests that run multiple Mage targets in one process without changing normal once-per-run dependency semantics. Constraint: Issue magefile#524 needs a way for same-process tests to rerun dependency functions. Rejected: clearing the cache automatically between Deps calls | that would change normal Mage dependency semantics. Confidence: high Scope-risk: narrow Directive: Do not call ResetDeps while dependencies are running; it only clears the process-global dependency cache. Tested: go test ./mg -run TestResetDepsAllowsDependenciesToRunAgain -count=1; go test ./mg -count=1; GOPATH="/root/go" go test -vet=all -tags CI -race ./... -count=1; golangci-lint run ./...; git diff --check Not-tested: full GitHub Actions matrix
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
mg.ResetDepsto clear the dependency cache between same-process test casesWhy
mg.Depscorrectly caches dependencies for a Mage run, but tests that execute Mage targets multiple times in the same process currently have no way to clear the global cache. This follows theResetDepshelper direction discussed in #524.Fixes #524.
Validation
go test ./mg -run TestResetDepsAllowsDependenciesToRunAgain -count=1go test ./mg -count=1GOPATH="$(go env GOPATH)" go test -vet=all -tags CI -race ./... -count=1golangci-lint run ./...git diff --check