Release Notes v0.2.0¶
Released: 2026-04-26
Highlights¶
New testutil package for cross-platform stdout/stderr capture in tests.
New Package: testutil¶
The testutil package provides utilities for capturing stdout and stderr during function execution, useful for testing CLI output.
Problem Solved¶
Capturing stdout/stderr for testing requires careful handling of file descriptor manipulation. This is error-prone and varies subtly across platforms.
Key Functions¶
CaptureStdout(fn)- Execute function and capture its stdoutCaptureStderr(fn)- Execute function and capture its stderrCaptureOutput(fn)- Execute function and capture both stdout and stderr
Example Usage¶
import "github.com/grokify/oscompat/testutil"
func TestMyCommand(t *testing.T) {
stdout := testutil.CaptureStdout(func() {
myCommand.Execute()
})
if !strings.Contains(stdout, "expected output") {
t.Errorf("unexpected output: %s", stdout)
}
}
Infrastructure¶
- Added shared CI workflows for consistent testing across platforms
- Bump codecov/codecov-action from 5 to 6