aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-04-17 02:06:51 +0900
committerOphestra <cat@gensokyo.uk>2026-04-17 02:06:51 +0900
commita394971dd75d8ad0287197553d3717dfb1d11b74 (patch)
tree49e9f8819a7148d67d2e153c0a7a0eb4bb1fc08d /cmd
parent9daba6080992f7a965873936dc20a85385bbc269 (diff)
cmd/mbf: do not abort cache acquisition during testing
This can sometimes fire during testing due to how short the test is. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/mbf/cache.go4
-rw-r--r--cmd/mbf/cache_test.go3
-rw-r--r--cmd/mbf/main.go127
3 files changed, 62 insertions, 72 deletions
diff --git a/cmd/mbf/cache.go b/cmd/mbf/cache.go
index 16e77cbc..316e303d 100644
--- a/cmd/mbf/cache.go
+++ b/cmd/mbf/cache.go
@@ -4,6 +4,7 @@ import (
"context"
"os"
"path/filepath"
+ "testing"
"hakurei.app/check"
"hakurei.app/internal/pkg"
@@ -53,6 +54,9 @@ func (cache *cache) open() (err error) {
go func() {
select {
case <-cache.ctx.Done():
+ if testing.Testing() {
+ return
+ }
os.Exit(2)
case <-done:
diff --git a/cmd/mbf/cache_test.go b/cmd/mbf/cache_test.go
index 0f036542..a4d33af5 100644
--- a/cmd/mbf/cache_test.go
+++ b/cmd/mbf/cache_test.go
@@ -1,7 +1,6 @@
package main
import (
- "context"
"log"
"os"
"testing"
@@ -14,7 +13,7 @@ func TestCache(t *testing.T) {
t.Parallel()
cm := cache{
- ctx: context.Background(),
+ ctx: t.Context(),
msg: message.New(log.New(os.Stderr, "check: ", 0)),
base: t.TempDir(),
diff --git a/cmd/mbf/main.go b/cmd/mbf/main.go
index 894f5a46..abdc5e94 100644
--- a/cmd/mbf/main.go
+++ b/cmd/mbf/main.go
@@ -164,17 +164,15 @@ func main() {
func(args []string) (err error) {
return commandInfo(&cm, args, os.Stdout, flagStatus, flagReport)
},
- ).
- Flag(
- &flagStatus,
- "status", command.BoolFlag(false),
- "Display cure status if available",
- ).
- Flag(
- &flagReport,
- "report", command.StringFlag(""),
- "Load cure status from this report file instead of cache",
- )
+ ).Flag(
+ &flagStatus,
+ "status", command.BoolFlag(false),
+ "Display cure status if available",
+ ).Flag(
+ &flagReport,
+ "report", command.StringFlag(""),
+ "Load cure status from this report file instead of cache",
+ )
}
c.NewCommand(
@@ -273,12 +271,11 @@ func main() {
" package(s) are out of date"))
}
return errors.Join(errs...)
- }).
- Flag(
- &flagJobs,
- "j", command.IntFlag(32),
- "Maximum number of simultaneous connections",
- )
+ }).Flag(
+ &flagJobs,
+ "j", command.IntFlag(32),
+ "Maximum number of simultaneous connections",
+ )
}
c.NewCommand(
@@ -378,22 +375,19 @@ func main() {
return
},
- ).
- Flag(
- &flagGentoo,
- "gentoo", command.StringFlag(""),
- "Bootstrap from a Gentoo stage3 tarball",
- ).
- Flag(
- &flagChecksum,
- "checksum", command.StringFlag(""),
- "Checksum of Gentoo stage3 tarball",
- ).
- Flag(
- &flagStage0,
- "stage0", command.BoolFlag(false),
- "Create bootstrap stage0 tarball",
- )
+ ).Flag(
+ &flagGentoo,
+ "gentoo", command.StringFlag(""),
+ "Bootstrap from a Gentoo stage3 tarball",
+ ).Flag(
+ &flagChecksum,
+ "checksum", command.StringFlag(""),
+ "Checksum of Gentoo stage3 tarball",
+ ).Flag(
+ &flagStage0,
+ "stage0", command.BoolFlag(false),
+ "Create bootstrap stage0 tarball",
+ )
}
{
@@ -487,27 +481,23 @@ func main() {
return err
}
},
- ).
- Flag(
- &flagDump,
- "dump", command.StringFlag(""),
- "Write IR to specified pathname and terminate",
- ).
- Flag(
- &flagExport,
- "export", command.StringFlag(""),
- "Export cured artifact to specified pathname",
- ).
- Flag(
- &flagEnter,
- "enter", command.BoolFlag(false),
- "Enter cure container with an interactive shell",
- ).
- Flag(
- &flagRemote,
- "daemon", command.BoolFlag(false),
- "Cure artifact on the daemon",
- )
+ ).Flag(
+ &flagDump,
+ "dump", command.StringFlag(""),
+ "Write IR to specified pathname and terminate",
+ ).Flag(
+ &flagExport,
+ "export", command.StringFlag(""),
+ "Export cured artifact to specified pathname",
+ ).Flag(
+ &flagEnter,
+ "enter", command.BoolFlag(false),
+ "Enter cure container with an interactive shell",
+ ).Flag(
+ &flagRemote,
+ "daemon", command.BoolFlag(false),
+ "Cure artifact on the daemon",
+ )
}
{
@@ -647,22 +637,19 @@ func main() {
}
return z.Wait()
},
- ).
- Flag(
- &flagNet,
- "net", command.BoolFlag(false),
- "Share host net namespace",
- ).
- Flag(
- &flagSession,
- "session", command.BoolFlag(true),
- "Retain session",
- ).
- Flag(
- &flagWithToolchain,
- "with-toolchain", command.BoolFlag(false),
- "Include the stage2 LLVM toolchain",
- )
+ ).Flag(
+ &flagNet,
+ "net", command.BoolFlag(false),
+ "Share host net namespace",
+ ).Flag(
+ &flagSession,
+ "session", command.BoolFlag(true),
+ "Retain session",
+ ).Flag(
+ &flagWithToolchain,
+ "with-toolchain", command.BoolFlag(false),
+ "Include the stage2 LLVM toolchain",
+ )
}