Skip to content

Commit 3e3407a

Browse files
authored
test: Add even more context to panic in envtest helper (#650)
**What problem does this PR solve?**: Adds more context (working directory, command arguments) to panic. Helpful to understand why command fails. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 748c7e4 commit 3e3407a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/helpers/envtest.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ func getModulePath(moduleDir, moduleName string) string {
204204
if err != nil {
205205
// We include the combined output because the error is usually
206206
// an exit code, which does not explain why the command failed.
207-
panic(fmt.Sprintf("err=%q, output=%q", err, out))
207+
panic(
208+
fmt.Sprintf("cmd.Dir=%q, cmd.Args=%q, err=%q, output=%q",
209+
cmd.Dir,
210+
cmd.Args,
211+
err,
212+
out),
213+
)
208214
}
209215
return strings.TrimSpace(string(out))
210216
}

0 commit comments

Comments
 (0)