Skip to content

Commit

Permalink
test: Add more context to panic in envtest helper (#641)
Browse files Browse the repository at this point in the history
**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.
-->
  • Loading branch information
dlipovetsky authored May 9, 2024
1 parent d89f74f commit 2563c71
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/helpers/envtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ func getModulePath(moduleDir, moduleName string) string {
cmd.Dir = moduleDir
out, err := cmd.CombinedOutput()
if err != nil {
panic(err)
// We include the combined output because the error is usually
// an exit code, which does not explain why the command failed.
panic(fmt.Sprintf("err=%q, output=%q", err, out))
}
return strings.TrimSpace(string(out))
}

0 comments on commit 2563c71

Please sign in to comment.