Repository navigation
Start each cobra run in the cli tests with the usage block on, and put the pipeline flags back when a test ends (#43) - #44
Merged
Conversation
…t the pipeline flags back when a test ends (#43) scanPipeline turns the usage block off on the command it runs, and in the test binary scanCmd kept that setting after executeScan, runScanWith and the tests that call scanTarget(scanCmd, ...) directly. When one of them ran before TestUsageErrorsStillPrintUsage with no executeRoot test in between, cobra printed only "Error: accepts 1 arg(s), received 0" and the test failed. executeRoot and executeScan now turn the usage block back on before they run the command, and executeScan also turns it back on when its test ends, as executeRoot already did. resetPipelineFlags put only outputFormat and outputFile back when a test ended. The two skipped-file tests set failOn to "low" after calling it, and TestRunScanExcludesFromFlagConfigAndDefaults, run directly after either of them, ended the test binary with exit code 1 inside runScan. resetPipelineFlags now puts back every variable it sets when the test ends, as well as when it starts. Two tests cover this: a usage error through executeRoot or executeScan prints the usage block after a scan through executeScan or runScanWith, and resetPipelineFlags puts failOn and four other variables back when a test ends. Both failed before this change. go test -count=1 -shuffle=1792442745693168000 ./internal/cli, which failed before, passes. Shuffle seeds 1 to 40 failed 27 times on the previous commit; seeds 1 to 300 pass, and each of the 102 top-level tests passes when it runs directly after any other one. Fixes #43
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.
This pull request lands 1 commit in
internal/cli.Included
Verified on this exact tree
go build -v ./...: exit 0go vet ./...: exit 0gofmt -l ./internal ./pkg ./cmd: no files listedgolangci-lint run --concurrency 4 ./...(golangci-lint 2.12.2): exit 1, 21 issues (errcheck: 15, staticcheck: 6); pre-existing: the same command in a worktree oforigin/main(0fb15c5) prints the same 21 issues by file and messagego test -race -count=1 -p 4 -json ./...: exit 0; 9 packages: 8 ok, 1 with no test files; top-level tests: 311 passed, 0 failed, 0 skipped; subtests: 740 passed, 0 failed, 0 skippedTestChangelogEntriesandTestChangelogSaysWhereSARIFAndCSVCarryTheCryptoJSTextinpkg/reporter(in the run above): passedgo test -count=1 -shuffle=1792442745693168000 ./internal/cli: okinternal/clitest binary fromgo test -c, run with-test.count=1 -test.shuffle=Nfor N from 1 to 40: 40 runs, 0 failedNot included
None
Closes
Fixes #43
How to merge
Rebase and merge, so that each change stays its own commit on
main.