Skip to content

Commit 3d2b788

Browse files
committed
tests: Run cargo with --verbose flag if AUTHD_TEST_VERBOSITY is set
1 parent 4156337 commit 3d2b788

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

internal/testutils/args.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,24 @@ var (
1616
isRaceOnce sync.Once
1717
sleepMultiplier float64
1818
sleepMultiplierOnce sync.Once
19+
testVerbosity int
20+
testVerbosityOnce sync.Once
1921
)
2022

23+
// TestVerbosity returns the verbosity level that should be used in tests.
24+
func TestVerbosity() int {
25+
testVerbosityOnce.Do(func() {
26+
if v := os.Getenv("AUTHD_TEST_VERBOSITY"); v != "" {
27+
var err error
28+
testVerbosity, err = strconv.Atoi(v)
29+
if err != nil {
30+
panic(err)
31+
}
32+
}
33+
})
34+
return testVerbosity
35+
}
36+
2137
func haveBuildFlag(flag string) bool {
2238
b, ok := debug.ReadBuildInfo()
2339
if !ok {

internal/testutils/rust.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ func BuildRustNSSLib(t *testing.T, disableCoverage bool, features ...string) (li
100100
// Builds the nss library.
101101
// #nosec:G204 - we control the command arguments in tests
102102
cmd := exec.Command(cargo, "build", "--features", strings.Join(features, ","), "--target-dir", target)
103+
if TestVerbosity() > 0 {
104+
cmd.Args = append(cmd.Args, "--verbose")
105+
}
103106
cmd.Env = append(os.Environ(), rustCovEnv...)
104107
cmd.Dir = projectRoot
105108
cmd.Stdout = os.Stdout

0 commit comments

Comments
 (0)