cmd/mbf: do not abort cache acquisition during testing
All checks were successful
Test / Create distribution (push) Successful in 1m15s
Test / Sandbox (push) Successful in 2m59s
Test / Hakurei (push) Successful in 3m58s
Test / ShareFS (push) Successful in 4m7s
Test / Sandbox (race detector) (push) Successful in 5m29s
Test / Hakurei (race detector) (push) Successful in 6m32s
Test / Flake checks (push) Successful in 1m22s

This can sometimes fire during testing due to how short the test is.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-04-17 02:06:51 +09:00
parent 9daba60809
commit a394971dd7
3 changed files with 62 additions and 72 deletions

View File

@@ -4,6 +4,7 @@ import (
"context" "context"
"os" "os"
"path/filepath" "path/filepath"
"testing"
"hakurei.app/check" "hakurei.app/check"
"hakurei.app/internal/pkg" "hakurei.app/internal/pkg"
@@ -53,6 +54,9 @@ func (cache *cache) open() (err error) {
go func() { go func() {
select { select {
case <-cache.ctx.Done(): case <-cache.ctx.Done():
if testing.Testing() {
return
}
os.Exit(2) os.Exit(2)
case <-done: case <-done:

View File

@@ -1,7 +1,6 @@
package main package main
import ( import (
"context"
"log" "log"
"os" "os"
"testing" "testing"
@@ -14,7 +13,7 @@ func TestCache(t *testing.T) {
t.Parallel() t.Parallel()
cm := cache{ cm := cache{
ctx: context.Background(), ctx: t.Context(),
msg: message.New(log.New(os.Stderr, "check: ", 0)), msg: message.New(log.New(os.Stderr, "check: ", 0)),
base: t.TempDir(), base: t.TempDir(),

View File

@@ -164,13 +164,11 @@ func main() {
func(args []string) (err error) { func(args []string) (err error) {
return commandInfo(&cm, args, os.Stdout, flagStatus, flagReport) return commandInfo(&cm, args, os.Stdout, flagStatus, flagReport)
}, },
). ).Flag(
Flag(
&flagStatus, &flagStatus,
"status", command.BoolFlag(false), "status", command.BoolFlag(false),
"Display cure status if available", "Display cure status if available",
). ).Flag(
Flag(
&flagReport, &flagReport,
"report", command.StringFlag(""), "report", command.StringFlag(""),
"Load cure status from this report file instead of cache", "Load cure status from this report file instead of cache",
@@ -273,8 +271,7 @@ func main() {
" package(s) are out of date")) " package(s) are out of date"))
} }
return errors.Join(errs...) return errors.Join(errs...)
}). }).Flag(
Flag(
&flagJobs, &flagJobs,
"j", command.IntFlag(32), "j", command.IntFlag(32),
"Maximum number of simultaneous connections", "Maximum number of simultaneous connections",
@@ -378,18 +375,15 @@ func main() {
return return
}, },
). ).Flag(
Flag(
&flagGentoo, &flagGentoo,
"gentoo", command.StringFlag(""), "gentoo", command.StringFlag(""),
"Bootstrap from a Gentoo stage3 tarball", "Bootstrap from a Gentoo stage3 tarball",
). ).Flag(
Flag(
&flagChecksum, &flagChecksum,
"checksum", command.StringFlag(""), "checksum", command.StringFlag(""),
"Checksum of Gentoo stage3 tarball", "Checksum of Gentoo stage3 tarball",
). ).Flag(
Flag(
&flagStage0, &flagStage0,
"stage0", command.BoolFlag(false), "stage0", command.BoolFlag(false),
"Create bootstrap stage0 tarball", "Create bootstrap stage0 tarball",
@@ -487,23 +481,19 @@ func main() {
return err return err
} }
}, },
). ).Flag(
Flag(
&flagDump, &flagDump,
"dump", command.StringFlag(""), "dump", command.StringFlag(""),
"Write IR to specified pathname and terminate", "Write IR to specified pathname and terminate",
). ).Flag(
Flag(
&flagExport, &flagExport,
"export", command.StringFlag(""), "export", command.StringFlag(""),
"Export cured artifact to specified pathname", "Export cured artifact to specified pathname",
). ).Flag(
Flag(
&flagEnter, &flagEnter,
"enter", command.BoolFlag(false), "enter", command.BoolFlag(false),
"Enter cure container with an interactive shell", "Enter cure container with an interactive shell",
). ).Flag(
Flag(
&flagRemote, &flagRemote,
"daemon", command.BoolFlag(false), "daemon", command.BoolFlag(false),
"Cure artifact on the daemon", "Cure artifact on the daemon",
@@ -647,18 +637,15 @@ func main() {
} }
return z.Wait() return z.Wait()
}, },
). ).Flag(
Flag(
&flagNet, &flagNet,
"net", command.BoolFlag(false), "net", command.BoolFlag(false),
"Share host net namespace", "Share host net namespace",
). ).Flag(
Flag(
&flagSession, &flagSession,
"session", command.BoolFlag(true), "session", command.BoolFlag(true),
"Retain session", "Retain session",
). ).Flag(
Flag(
&flagWithToolchain, &flagWithToolchain,
"with-toolchain", command.BoolFlag(false), "with-toolchain", command.BoolFlag(false),
"Include the stage2 LLVM toolchain", "Include the stage2 LLVM toolchain",