diff options
| author | Ophestra <cat@gensokyo.uk> | 2026-03-30 18:15:56 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2026-03-30 18:24:53 +0900 |
| commit | a6600be34ad812ff13c89f45c3cadaac6d994e67 (patch) | |
| tree | 48c8cd6daab8084eb9391c7ee16f2b38f1cf280f /test | |
| parent | b5592633f5b980970808fc5be43b0fb4f4d4e784 (diff) | |
all: use filepath
This makes package check portable, and removes nonportable behaviour from package pkg, pipewire, and system. All other packages remain nonportable due to their nature. No latency increase was observed due to this change on amd64 and arm64 linux.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'test')
| -rw-r--r-- | test/internal/sandbox/assert.go | 6 | ||||
| -rw-r--r-- | test/internal/sandbox/assert_test.go | 4 | ||||
| -rw-r--r-- | test/internal/sandbox/fs.go | 4 | ||||
| -rw-r--r-- | test/internal/sandbox/mount_test.go | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/test/internal/sandbox/assert.go b/test/internal/sandbox/assert.go index 82c928b0..343c1586 100644 --- a/test/internal/sandbox/assert.go +++ b/test/internal/sandbox/assert.go @@ -17,7 +17,7 @@ import ( "log" "net" "os" - "path" + "path/filepath" "syscall" ) @@ -54,7 +54,7 @@ func (t *T) MustCheckFile(wantFilePath string) { } func mustAbs(s string) string { - if !path.IsAbs(s) { + if !filepath.IsAbs(s) { fatalf("[FAIL] %q is not absolute", s) panic("unreachable") } @@ -68,7 +68,7 @@ func (t *T) MustCheck(want *TestCase) { os.Getenv("XDG_RUNTIME_DIR"), } for _, a := range checkWritableDirPaths { - pathname := path.Join(mustAbs(a), ".hakurei-check") + pathname := filepath.Join(mustAbs(a), ".hakurei-check") if err := os.WriteFile(pathname, make([]byte, 1<<8), 0600); err != nil { fatalf("[FAIL] %s", err) } else if err = os.Remove(pathname); err != nil { diff --git a/test/internal/sandbox/assert_test.go b/test/internal/sandbox/assert_test.go index efeb7cb3..012ae23d 100644 --- a/test/internal/sandbox/assert_test.go +++ b/test/internal/sandbox/assert_test.go @@ -5,7 +5,7 @@ package sandbox import ( "encoding/json" "os" - "path" + "path/filepath" "testing" ) @@ -15,7 +15,7 @@ func SwapPrint(f F) (old F) { old = printfFunc; printfFunc = f; return } func SwapFatal(f F) (old F) { old = fatalfFunc; fatalfFunc = f; return } func MustWantFile(t *testing.T, v any) (wantFile string) { - wantFile = path.Join(t.TempDir(), "want.json") + wantFile = filepath.Join(t.TempDir(), "want.json") if f, err := os.OpenFile(wantFile, os.O_CREATE|os.O_WRONLY, 0400); err != nil { t.Fatalf("cannot create %q: %v", wantFile, err) } else if err = json.NewEncoder(f).Encode(v); err != nil { diff --git a/test/internal/sandbox/fs.go b/test/internal/sandbox/fs.go index 36d6c6d3..b37d30b9 100644 --- a/test/internal/sandbox/fs.go +++ b/test/internal/sandbox/fs.go @@ -6,7 +6,7 @@ import ( "errors" "fmt" "io/fs" - "path" + "path/filepath" "strings" ) @@ -68,7 +68,7 @@ func (s *FS) Compare(prefix string, e fs.FS) error { printDir(prefix, dir) return ErrFSInvalidEnt } else { - name = path.Join(prefix, name) + name = filepath.Join(prefix, name) if fi, err := got.Info(); err != nil { return err diff --git a/test/internal/sandbox/mount_test.go b/test/internal/sandbox/mount_test.go index 65bcec43..a565b0a0 100644 --- a/test/internal/sandbox/mount_test.go +++ b/test/internal/sandbox/mount_test.go @@ -4,7 +4,7 @@ package sandbox_test import ( "os" - "path" + "path/filepath" "testing" "hakurei.app/test/internal/sandbox" @@ -87,7 +87,7 @@ func TestMountinfo(t *testing.T) { } for _, tc := range testCases { - name := path.Join(t.TempDir(), "sample") + name := filepath.Join(t.TempDir(), "sample") if err := os.WriteFile(name, []byte(tc.sample), 0400); err != nil { t.Fatalf("cannot write sample: %v", err) } |
