container: enter init path early

There is generally no use case where any setup is required before init, and requiring the explicit function call is error-prone and unnecessary. It also causes trouble with packages using a similar trick. This change moves argv0 check early and makes it an import side effect. The stub will be removed in v0.5.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
cat
2026-08-25 14:53:29 +09:00
parent ac7abbbe3f
commit 1c3761bb53
22 changed files with 32 additions and 72 deletions
+1 -2
View File
@@ -4,8 +4,7 @@ import (
"os"
"testing"
"hakurei.app/container"
"hakurei.app/internal/helper"
)
func TestMain(m *testing.M) { container.TryArgv0(nil); helper.InternalHelperStub(); os.Exit(m.Run()) }
func TestMain(m *testing.M) { helper.InternalHelperStub(); os.Exit(m.Run()) }
+1 -2
View File
@@ -4,8 +4,7 @@ import (
"os"
"testing"
"hakurei.app/container"
"hakurei.app/internal/helper"
)
func TestMain(m *testing.M) { container.TryArgv0(nil); helper.InternalHelperStub(); os.Exit(m.Run()) }
func TestMain(m *testing.M) { helper.InternalHelperStub(); os.Exit(m.Run()) }
-2
View File
@@ -85,8 +85,6 @@ func newRContext(tb testing.TB, c *pkg.Cache) *pkg.RContext {
return &r
}
func TestMain(m *testing.M) { container.TryArgv0(nil); os.Exit(m.Run()) }
// overrideIdent overrides the ID method of [Artifact].
type overrideIdent struct {
id pkg.ID
-3
View File
@@ -10,7 +10,6 @@ import (
"testing"
"hakurei.app/check"
"hakurei.app/container"
"hakurei.app/internal/pkg"
"hakurei.app/internal/rosa"
"hakurei.app/message"
@@ -28,8 +27,6 @@ var (
)
func TestMain(m *testing.M) {
container.TryArgv0(nil)
code := m.Run()
if buildTestCache != nil {
buildTestCacheCancel()