aboutsummaryrefslogtreecommitdiffhomepage
path: root/system
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-09-05 05:15:40 +0900
committerOphestra <cat@gensokyo.uk>2025-09-05 05:15:40 +0900
commitecaf43358d5e28554f208fd6eb75bd38a87a68bf (patch)
tree44552adcc99bc7a82aafba0b722a9481c709db52 /system
parent197fa65b8fc8f35270df9cef68442b6a9c380ae1 (diff)
system/dbus: create context in subtest
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>
Diffstat (limited to 'system')
-rw-r--r--system/dbus/dbus_test.go52
1 files changed, 28 insertions, 24 deletions
diff --git a/system/dbus/dbus_test.go b/system/dbus/dbus_test.go
index bf3d3e7f..9d969ba8 100644
--- a/system/dbus/dbus_test.go
+++ b/system/dbus/dbus_test.go
@@ -63,6 +63,10 @@ func TestProxyStartWaitCloseString(t *testing.T) {
t.Run("direct", func(t *testing.T) { testProxyFinaliseStartWaitCloseString(t, false) })
}
+const (
+ stubProxyTimeout = 30 * time.Second
+)
+
func testProxyFinaliseStartWaitCloseString(t *testing.T, useSandbox bool) {
{
oldWaitDelay := helper.WaitDelay
@@ -118,33 +122,33 @@ func testProxyFinaliseStartWaitCloseString(t *testing.T, useSandbox bool) {
}
})
- ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second)
- defer cancel()
- output := new(strings.Builder)
- if !useSandbox {
- p = dbus.NewDirect(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("run", func(t *testing.T) {
+ ctx, cancel := context.WithTimeout(t.Context(), stubProxyTimeout)
+ defer cancel()
+ output := new(strings.Builder)
+ if !useSandbox {
+ p = dbus.NewDirect(ctx, final, output)
+ } else {
+ p = dbus.New(ctx, final, output)
}
- })
- 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("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) {
+ 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 {
t.Fatalf("Start: error = %v",
err)