debian-forge-cli/bib/pkg/progress/export_test.go
Michael Vogt 655b6bbd0f progress: tweak progress error reporting
This commit adds catpure of os.Std{out,err} when running osbuild so
that we capture the error log and can display it as part of
an error from osbuild, e.g. when osbuild itself crashes.

This gives us more accurate error reporting if anything fails
during the osbuild building.
2025-03-31 19:42:59 +00:00

35 lines
593 B
Go

package progress
import (
"io"
)
type (
TerminalProgressBar = terminalProgressBar
DebugProgressBar = debugProgressBar
VerboseProgressBar = verboseProgressBar
)
func MockOsStderr(w io.Writer) (restore func()) {
saved := osStderr
osStderr = w
return func() {
osStderr = saved
}
}
func MockIsattyIsTerminal(fn func(uintptr) bool) (restore func()) {
saved := isattyIsTerminal
isattyIsTerminal = fn
return func() {
isattyIsTerminal = saved
}
}
func MockOsbuildCmd(s string) (restore func()) {
saved := osbuildCmd
osbuildCmd = s
return func() {
osbuildCmd = saved
}
}