Documentation
¶
Index ¶
- func CaptureStdout(t testing.TB, fn func()) string
- func CreateTestTAR(t *testing.T, files map[string]string) string
- func CreateTestTARBzip2(t *testing.T, files map[string]string) string
- func CreateTestTARGzip(t *testing.T, files map[string]string) string
- func CreateTestTARWithSymlink(t *testing.T, linkTarget string) string
- func CreateTestZIP(t *testing.T, files map[string]string) string
- func CreateTestZIPWithCompressionRatio(t *testing.T) string
- func CreateTestZIPWithSymlink(t *testing.T) string
- func WithArgs(t testing.TB, progName string, args []string, fn func())
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaptureStdout ¶
CaptureStdout redirects os.Stdout during fn and returns all captured output.
Reading from the pipe runs in a separate goroutine concurrently with fn(), avoiding deadlock when output exceeds the pipe buffer size (~64KB on Linux).
Incompatible with t.Parallel() due to mutation of the global os.Stdout.
func CreateTestTAR ¶
CreateTestTAR creates a plain .tar file from a name-to-content map.
func CreateTestTARBzip2 ¶
CreateTestTARBzip2 creates a .tar.bz2 file.
compress/bzip2 in Go stdlib has no Writer, so the system bzip2 utility is used via os/exec. If bzip2 is not available the test is skipped.
The intermediate .tar file is removed after compression.
func CreateTestTARGzip ¶
CreateTestTARGzip creates a .tar.gz file.
func CreateTestTARWithSymlink ¶
CreateTestTARWithSymlink creates a plain .tar with a symlink entry pointing to the given target. Also includes an ordinary readme.txt to verify mixed content.
func CreateTestZIP ¶
CreateTestZIP creates a ZIP file from a name-to-content map. Returns the file path.
func CreateTestZIPWithCompressionRatio ¶
CreateTestZIPWithCompressionRatio creates a ZIP with a highly compressible entry (1 MB of zeros) that Deflate compresses to ~1 KB, for testing the zip_bomb detection rule.
func CreateTestZIPWithSymlink ¶
CreateTestZIPWithSymlink creates a ZIP file containing a symlink entry.
func WithArgs ¶
WithArgs temporarily replaces os.Args with [progName, args...], calls fn, then restores the original value.
progName is set as the program name (os.Args[0]). The value does not need to match the real binary name — tests may pass any value.
Incompatible with t.Parallel() due to mutation of the global os.Args.
Types ¶
This section is empty.