Problem
The test suite contains many t.Logf() statements that are helpful for debugging but can be noisy during normal test runs. Currently, there's no way to conditionally enable/disable verbose test output.
Proposed Solution
Add support for conditional test logging via environment variable:
// Helper function
func logIfVerbose(t *testing.T, format string, args ...interface{}) {
t.Helper()
if os.Getenv("CMS_TEST_VERBOSE") == "1" {
t.Logf(format, args...)
}
}
// Usage in tests
logIfVerbose(t, "✓ SignDataWithSigner produced valid CMS signature")
logIfVerbose(t, "CMS signature length: %d bytes", len(signature))
Benefits
- Cleaner test output by default (no debug logs)
- Easy debugging when needed:
CMS_TEST_VERBOSE=1 go test
- Maintains existing debugging information for troubleshooting test failures
- Consistent with Go testing patterns (similar to
-v flag but more granular)
Implementation Notes
- Add
logIfVerbose helper to signer_test.go and verifier_test.go
- Replace existing
t.Logf() calls with logIfVerbose()
- Document in test files and potentially in README/CONTRIBUTING.md
- Could also support levels:
CMS_TEST_VERBOSE=2 for even more detailed output
Related
This came up during code review feedback on PR #6 where Copilot suggested removing test logging statements. This enhancement would satisfy both needs: keep the valuable debugging info but make it opt-in.
Problem
The test suite contains many
t.Logf()statements that are helpful for debugging but can be noisy during normal test runs. Currently, there's no way to conditionally enable/disable verbose test output.Proposed Solution
Add support for conditional test logging via environment variable:
Benefits
CMS_TEST_VERBOSE=1 go test-vflag but more granular)Implementation Notes
logIfVerbosehelper tosigner_test.goandverifier_test.got.Logf()calls withlogIfVerbose()CMS_TEST_VERBOSE=2for even more detailed outputRelated
This came up during code review feedback on PR #6 where Copilot suggested removing test logging statements. This enhancement would satisfy both needs: keep the valuable debugging info but make it opt-in.