Skip to content

Commit 2563c71

Browse files
authored
test: Add more context to panic in envtest helper (#641)
**What problem does this PR solve?**: Adds context to panic message: **Before:** ```log [PANICKED] Test Panicked In [BeforeSuite] at: /home/dlipovetsky/nutanix/capi-runtime-extensions/test/helpers/envtest.go:205 @ 05/09/24 08:05:57.622 exit status 1 ``` **After:** ```log [PANICKED] Test Panicked In [BeforeSuite] at: /home/dlipovetsky/nutanix/capi-runtime-extensions/test/helpers/envtest.go:205 @ 05/09/24 08:05:12.059 err="exit status 1", output="go: module sigs.k8s.io/cluster-api-provider-aws/v2: not a known dependency\n" ``` **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 d89f74f commit 2563c71

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

test/helpers/envtest.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ func getModulePath(moduleDir, moduleName string) string {
202202
cmd.Dir = moduleDir
203203
out, err := cmd.CombinedOutput()
204204
if err != nil {
205-
panic(err)
205+
// We include the combined output because the error is usually
206+
// an exit code, which does not explain why the command failed.
207+
panic(fmt.Sprintf("err=%q, output=%q", err, out))
206208
}
207209
return strings.TrimSpace(string(out))
208210
}

0 commit comments

Comments
 (0)