system/dbus: create context in subtest
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 41s
Test / Hakurei (push) Successful in 43s
Test / Sandbox (race detector) (push) Successful in 2m11s
Test / Hakurei (race detector) (push) Successful in 2m53s
Test / Hpkg (push) Successful in 3m17s
Test / Flake checks (push) Successful in 1m29s

This is causing a huge amount of spurious test failures due to the poor performance of the integration vm. This should finally put an end to the annoyance.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-09-05 05:15:40 +09:00
parent 197fa65b8f
commit ecaf43358d
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q

View File

@ -63,6 +63,10 @@ func TestProxyStartWaitCloseString(t *testing.T) {
t.Run("direct", func(t *testing.T) { testProxyFinaliseStartWaitCloseString(t, false) }) t.Run("direct", func(t *testing.T) { testProxyFinaliseStartWaitCloseString(t, false) })
} }
const (
stubProxyTimeout = 30 * time.Second
)
func testProxyFinaliseStartWaitCloseString(t *testing.T, useSandbox bool) { func testProxyFinaliseStartWaitCloseString(t *testing.T, useSandbox bool) {
{ {
oldWaitDelay := helper.WaitDelay oldWaitDelay := helper.WaitDelay
@ -118,33 +122,33 @@ func testProxyFinaliseStartWaitCloseString(t *testing.T, useSandbox bool) {
} }
}) })
ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second) t.Run("run", func(t *testing.T) {
defer cancel() ctx, cancel := context.WithTimeout(t.Context(), stubProxyTimeout)
output := new(strings.Builder) defer cancel()
if !useSandbox { output := new(strings.Builder)
p = dbus.NewDirect(ctx, final, output) if !useSandbox {
} else { p = dbus.NewDirect(ctx, final, output)
p = dbus.New(ctx, final, output) } else {
} p = dbus.New(ctx, final, output)
t.Run("invalid wait", func(t *testing.T) {
wantErr := "dbus: not started"
if err := p.Wait(); err == nil || err.Error() != wantErr {
t.Errorf("Wait: error = %v, wantErr %v",
err, wantErr)
} }
})
t.Run("string", func(t *testing.T) { t.Run("invalid wait", func(t *testing.T) {
want := "(unused dbus proxy)" wantErr := "dbus: not started"
if got := p.String(); got != want { if err := p.Wait(); err == nil || err.Error() != wantErr {
t.Errorf("String: %q, want %q", t.Errorf("Wait: error = %v, wantErr %v",
got, want) err, wantErr)
return }
} })
})
t.Run("string", func(t *testing.T) {
want := "(unused dbus proxy)"
if got := p.String(); got != want {
t.Errorf("String: %q, want %q",
got, want)
return
}
})
t.Run("start", func(t *testing.T) {
if err := p.Start(); err != nil { if err := p.Start(); err != nil {
t.Fatalf("Start: error = %v", t.Fatalf("Start: error = %v",
err) err)