feat: add support for running failed tests first based on previous ru…#498
Open
shay-dahan wants to merge 1 commit intogotestyourself:mainfrom
Open
feat: add support for running failed tests first based on previous ru…#498shay-dahan wants to merge 1 commit intogotestyourself:mainfrom
shay-dahan wants to merge 1 commit intogotestyourself:mainfrom
Conversation
…n JSON file - Introduced a new flag `--failed-first` to specify the path to a JSON file containing the results of the previous test run. - Implemented logic to read the JSON file and prioritize running failed tests before executing all tests. - Added unit tests to validate the new functionality and ensure correct behavior when handling various scenarios, including no failed tests and invalid file paths. - Updated help text to include the new flag description.
dnephin
reviewed
May 14, 2025
Member
dnephin
left a comment
There was a problem hiding this comment.
Thank you for the PR!
Can you tell me more about the problem this solves for you? Is this to run tests in CI, or running them locally as you make changes?
Member
There was a problem hiding this comment.
I think this file was committed by accident? Let's leave launch config up to the individual developer. If you'd like to add something consider adding it to contrib/vscode/launch.json.sample.
Comment on lines
+289
to
+299
| var failedTests []struct{ Package, Test, Action string } | ||
| for _, line := range strings.Split(string(data), "\n") { | ||
| if strings.TrimSpace(line) == "" { | ||
| continue | ||
| } | ||
| var evt struct{ Package, Test, Action string } | ||
| _ = json.Unmarshal([]byte(line), &evt) | ||
| if evt.Action == "fail" && evt.Test != "" { | ||
| failedTests = append(failedTests, evt) | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
There's code in the testjson package to do this: https://pkg.go.dev/gotest.tools/gotestsum@v1.12.2/testjson#ScanTestOutput
I'd suggest using that to read the JSON.
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.
…n JSON file
--failed-firstto specify the path to a JSON file containing the results of the previous test run.