Some checks failed
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m5s
Test / Sandbox (race detector) (push) Successful in 3m54s
Test / Planterette (push) Successful in 3m59s
Test / Hakurei (race detector) (push) Successful in 4m49s
Test / Hakurei (push) Failing after 2m21s
Test / Flake checks (push) Has been skipped
This is more elegant and allows for much easier extension of the tests. Mountinfo is still serialised however due to libPaths nondeterminism. Signed-off-by: Ophestra <cat@gensokyo.uk>
45 lines
845 B
Go
45 lines
845 B
Go
package container_test
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
|
|
"hakurei.app/command"
|
|
"hakurei.app/container"
|
|
"hakurei.app/internal"
|
|
"hakurei.app/internal/hlog"
|
|
)
|
|
|
|
const (
|
|
envDoCheck = "HAKUREI_TEST_DO_CHECK"
|
|
pathHelper = "/usr/bin/helper"
|
|
)
|
|
|
|
var helperCommands []func(c command.Command)
|
|
|
|
func TestMain(m *testing.M) {
|
|
container.TryArgv0(hlog.Output{}, hlog.Prepare, internal.InstallOutput)
|
|
|
|
if os.Getenv(envDoCheck) == "1" {
|
|
c := command.New(os.Stderr, log.Printf, "helper", func(args []string) error {
|
|
log.SetFlags(0)
|
|
log.SetPrefix("helper: ")
|
|
return nil
|
|
})
|
|
for _, f := range helperCommands {
|
|
f(c)
|
|
}
|
|
c.MustParse(os.Args[1:], func(err error) {
|
|
if err != nil {
|
|
log.Fatal(err.Error())
|
|
}
|
|
})
|
|
return
|
|
}
|
|
|
|
os.Exit(m.Run())
|
|
}
|
|
|
|
func prepareHelper(c *container.Container) { c.Env = append(c.Env, envDoCheck+"=1") }
|