internal/stub: move from container
All checks were successful
Test / Create distribution (push) Successful in 1m2s
Test / Sandbox (push) Successful in 2m40s
Test / Hakurei (push) Successful in 3m39s
Test / ShareFS (push) Successful in 3m39s
Test / Sandbox (race detector) (push) Successful in 5m4s
Test / Hakurei (race detector) (push) Successful in 6m8s
Test / Flake checks (push) Successful in 1m19s

This package solves a very specific stubbing use case, in a less than elegant manner.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-03-17 16:09:14 +09:00
parent 722989c682
commit bac583f89e
57 changed files with 60 additions and 57 deletions

View File

@@ -5,7 +5,7 @@ import (
"strings"
"testing"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestDecodeJSON(t *testing.T) {

View File

@@ -6,7 +6,7 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestAutoEtcOp(t *testing.T) {

View File

@@ -7,7 +7,7 @@ import (
"hakurei.app/check"
"hakurei.app/container/std"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
"hakurei.app/message"
)

View File

@@ -18,7 +18,7 @@ import (
"hakurei.app/container/seccomp"
"hakurei.app/container/std"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
"hakurei.app/message"
)

View File

@@ -9,7 +9,7 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
"hakurei.app/vfs"
)

View File

@@ -10,7 +10,7 @@ import (
"hakurei.app/check"
"hakurei.app/container/seccomp"
"hakurei.app/container/std"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestInitEntrypoint(t *testing.T) {

View File

@@ -8,7 +8,7 @@ import (
"hakurei.app/check"
"hakurei.app/container/std"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestBindMountOp(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
"hakurei.app/message"
)

View File

@@ -5,7 +5,7 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestMountDevOp(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestMkdirOp(t *testing.T) {

View File

@@ -6,7 +6,7 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestMountOverlayOp(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestTmpfileOp(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestMountProcOp(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestRemountOp(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestSymlinkOp(t *testing.T) {

View File

@@ -6,7 +6,7 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestMountTmpfsOp(t *testing.T) {

View File

@@ -5,7 +5,7 @@ import (
"syscall"
"testing"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
"hakurei.app/vfs"
)

View File

@@ -9,8 +9,8 @@ import (
"syscall"
"testing"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/stub"
"hakurei.app/message"
)

View File

@@ -7,10 +7,10 @@ import (
"hakurei.app/check"
"hakurei.app/container"
"hakurei.app/container/stub"
"hakurei.app/fhs"
"hakurei.app/hst"
"hakurei.app/internal/env"
"hakurei.app/internal/stub"
)
func TestPaths(t *testing.T) {

View File

@@ -22,8 +22,8 @@ import (
"hakurei.app/container"
"hakurei.app/container/seccomp"
"hakurei.app/container/std"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/stub"
"hakurei.app/internal/system"
"hakurei.app/message"
)

View File

@@ -9,8 +9,8 @@ import (
"testing"
"unsafe"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/stub"
)
func TestHsu(t *testing.T) {

View File

@@ -12,11 +12,11 @@ import (
"hakurei.app/container"
"hakurei.app/container/seccomp"
"hakurei.app/container/std"
"hakurei.app/container/stub"
"hakurei.app/ext"
"hakurei.app/fhs"
"hakurei.app/hst"
"hakurei.app/internal/env"
"hakurei.app/internal/stub"
)
func TestShimEntrypoint(t *testing.T) {

View File

@@ -6,8 +6,8 @@ import (
"testing"
"hakurei.app/container"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/stub"
)
func TestSpAccountOp(t *testing.T) {

View File

@@ -11,11 +11,11 @@ import (
"hakurei.app/container"
"hakurei.app/container/seccomp"
"hakurei.app/container/std"
"hakurei.app/container/stub"
"hakurei.app/fhs"
"hakurei.app/hst"
"hakurei.app/internal/acl"
"hakurei.app/internal/dbus"
"hakurei.app/internal/stub"
"hakurei.app/internal/system"
)

View File

@@ -5,11 +5,11 @@ import (
"testing"
"hakurei.app/container"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/acl"
"hakurei.app/internal/dbus"
"hakurei.app/internal/helper"
"hakurei.app/internal/stub"
"hakurei.app/internal/system"
"hakurei.app/message"
)

View File

@@ -4,9 +4,9 @@ import (
"testing"
"hakurei.app/container"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/pipewire"
"hakurei.app/internal/stub"
"hakurei.app/internal/system"
)

View File

@@ -9,9 +9,9 @@ import (
"hakurei.app/check"
"hakurei.app/container"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/acl"
"hakurei.app/internal/stub"
"hakurei.app/internal/system"
)

View File

@@ -5,10 +5,10 @@ import (
"hakurei.app/container"
"hakurei.app/container/std"
"hakurei.app/container/stub"
"hakurei.app/fhs"
"hakurei.app/hst"
"hakurei.app/internal/acl"
"hakurei.app/internal/stub"
"hakurei.app/internal/system"
)

View File

@@ -5,10 +5,10 @@ import (
"hakurei.app/container"
"hakurei.app/container/std"
"hakurei.app/container/stub"
"hakurei.app/fhs"
"hakurei.app/hst"
"hakurei.app/internal/acl"
"hakurei.app/internal/stub"
"hakurei.app/internal/system"
)

View File

@@ -4,9 +4,9 @@ import (
"testing"
"hakurei.app/container"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/acl"
"hakurei.app/internal/stub"
"hakurei.app/internal/system"
"hakurei.app/internal/wayland"
)

View File

@@ -5,9 +5,9 @@ import (
"testing"
"hakurei.app/container"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/acl"
"hakurei.app/internal/stub"
)
func TestSpX11Op(t *testing.T) {

View File

@@ -8,8 +8,8 @@ import (
"testing"
"time"
"hakurei.app/container/stub"
"hakurei.app/internal/pipewire"
"hakurei.app/internal/stub"
)
func TestContext(t *testing.T) {

View File

@@ -14,9 +14,9 @@ import (
"unique"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/pkg"
"hakurei.app/internal/stub"
)
// testtoolBin is the container test tool binary made available to the

View File

@@ -23,9 +23,9 @@ import (
"hakurei.app/check"
"hakurei.app/container"
"hakurei.app/container/stub"
"hakurei.app/fhs"
"hakurei.app/internal/pkg"
"hakurei.app/internal/stub"
"hakurei.app/message"
)

View File

@@ -13,8 +13,8 @@ import (
"testing/fstest"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/internal/pkg"
"hakurei.app/internal/stub"
)
func TestTar(t *testing.T) {

View File

@@ -11,8 +11,8 @@ import (
"testing"
"time"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/stub"
)
func TestEntryData(t *testing.T) {

View File

@@ -13,9 +13,9 @@ import (
_ "unsafe" // for go:linkname
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/store"
"hakurei.app/internal/stub"
)
// Made available here for direct validation of state entry files.

View File

@@ -4,7 +4,7 @@ import (
"reflect"
"testing"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestCallError(t *testing.T) {

View File

@@ -9,11 +9,14 @@ var (
ErrCheck = errors.New("one or more arguments did not match")
)
// UniqueError is an error that only equivalates to other [UniqueError] with the same magic value.
// UniqueError is an error that only equivalates to another [UniqueError] with
// the same magic value.
type UniqueError uintptr
func (e UniqueError) Error() string {
return "unique error " + strconv.FormatUint(uint64(e), 10) + " injected by the test suite"
return "unique error " +
strconv.FormatUint(uint64(e), 10) +
" injected by the test suite"
}
func (e UniqueError) Is(target error) bool {

View File

@@ -5,7 +5,7 @@ import (
"syscall"
"testing"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestUniqueError(t *testing.T) {

View File

@@ -4,12 +4,12 @@ import (
"testing"
_ "unsafe" // for go:linkname
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
// Made available here to check panic recovery behaviour.
//
//go:linkname handleExitNew hakurei.app/container/stub.handleExitNew
//go:linkname handleExitNew hakurei.app/internal/stub.handleExitNew
func handleExitNew(t testing.TB)
// overrideTFailNow overrides the Fail and FailNow method.

View File

@@ -1,5 +1,5 @@
// Package stub provides function call level stubbing and validation
// for library functions that are impossible to check otherwise.
// Package stub provides function call level stubbing and validation for library
// functions that are impossible to check otherwise.
package stub
import (

View File

@@ -5,9 +5,9 @@ import (
"syscall"
"testing"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/acl"
"hakurei.app/internal/stub"
)
func TestACLUpdateOp(t *testing.T) {

View File

@@ -9,10 +9,10 @@ import (
"syscall"
"testing"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/dbus"
"hakurei.app/internal/helper"
"hakurei.app/internal/stub"
)
func TestDBusProxyOp(t *testing.T) {

View File

@@ -10,11 +10,11 @@ import (
"unsafe"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/acl"
"hakurei.app/internal/dbus"
"hakurei.app/internal/pipewire"
"hakurei.app/internal/stub"
"hakurei.app/internal/xcb"
)

View File

@@ -3,8 +3,8 @@ package system
import (
"testing"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/stub"
)
func TestHardlinkOp(t *testing.T) {

View File

@@ -4,7 +4,7 @@ import (
"os"
"testing"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestMkdirOp(t *testing.T) {

View File

@@ -8,9 +8,9 @@ import (
"testing"
"time"
"hakurei.app/container/stub"
"hakurei.app/internal/acl"
"hakurei.app/internal/pipewire"
"hakurei.app/internal/stub"
)
func TestPipeWireOp(t *testing.T) {

View File

@@ -9,8 +9,8 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/stub"
"hakurei.app/internal/xcb"
"hakurei.app/message"
)

View File

@@ -4,8 +4,8 @@ import (
"os"
"testing"
"hakurei.app/container/stub"
"hakurei.app/internal/acl"
"hakurei.app/internal/stub"
)
func TestWaylandOp(t *testing.T) {

View File

@@ -3,8 +3,8 @@ package system
import (
"testing"
"hakurei.app/container/stub"
"hakurei.app/hst"
"hakurei.app/internal/stub"
"hakurei.app/internal/xcb"
)

View File

@@ -7,7 +7,7 @@ import (
"syscall"
"testing"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
)
func TestError(t *testing.T) {

View File

@@ -10,7 +10,7 @@ import (
"testing"
"hakurei.app/container"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
"hakurei.app/message"
)

View File

@@ -8,7 +8,7 @@ import (
"syscall"
"testing"
"hakurei.app/container/stub"
"hakurei.app/internal/stub"
"hakurei.app/message"
)