diff --git a/internal/app/app_nixos_test.go b/internal/app/app_nixos_test.go index c5a31a6..057ced9 100644 --- a/internal/app/app_nixos_test.go +++ b/internal/app/app_nixos_test.go @@ -2,6 +2,7 @@ package app_test import ( "fmt" + "io" "io/fs" "os/user" "strconv" @@ -579,6 +580,10 @@ func (s *stubNixOS) Exit(code int) { panic("called exit on stub with code " + strconv.Itoa(code)) } +func (s *stubNixOS) Stdout() io.Writer { + panic("requested stdout") +} + func (s *stubNixOS) FshimPath() string { return "/nix/store/00000000000000000000000000000000-fortify-0.0.10/bin/.fshim" } diff --git a/internal/linux/interface.go b/internal/linux/interface.go index cf984a3..36f61b1 100644 --- a/internal/linux/interface.go +++ b/internal/linux/interface.go @@ -1,6 +1,7 @@ package linux import ( + "io" "io/fs" "os/user" "path" @@ -31,6 +32,8 @@ type System interface { Open(name string) (fs.File, error) // Exit provides [os.Exit]. Exit(code int) + // Stdout provides [os.Stdout]. + Stdout() io.Writer // FshimPath returns an absolute path to the fshim binary. FshimPath() string diff --git a/internal/linux/std.go b/internal/linux/std.go index 704ba16..e0a0994 100644 --- a/internal/linux/std.go +++ b/internal/linux/std.go @@ -2,6 +2,7 @@ package linux import ( "errors" + "io" "io/fs" "os" "os/exec" @@ -34,6 +35,7 @@ func (s *Std) ReadDir(name string) ([]os.DirEntry, error) { return os.ReadDir(na func (s *Std) Stat(name string) (fs.FileInfo, error) { return os.Stat(name) } func (s *Std) Open(name string) (fs.File, error) { return os.Open(name) } func (s *Std) Exit(code int) { fmsg.Exit(code) } +func (s *Std) Stdout() io.Writer { return os.Stdout } const xdgRuntimeDir = "XDG_RUNTIME_DIR"