aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-11-04 22:55:46 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-11-04 22:55:46 +0900
commit69cc64ef56c4b46954514d7ef1b93b3861443255 (patch)
treee7a334465e270450b39191697d4561bb21076559
parentfc25ac2523c512c67d73db5bbbd47224dc0b2001 (diff)
linux: provide access to stdout
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
-rw-r--r--internal/app/app_nixos_test.go5
-rw-r--r--internal/linux/interface.go3
-rw-r--r--internal/linux/std.go2
3 files changed, 10 insertions, 0 deletions
diff --git a/internal/app/app_nixos_test.go b/internal/app/app_nixos_test.go
index c5a31a65..057ced98 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 cf984a32..36f61b1a 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 704ba162..e0a0994c 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"