on main help sign in
chore: remove flaky tests
a8f90ffKujtim Hoxha
internal/agent/tools/job_test.go−42
@@ -2,7 +2,6 @@ package tools
2
2
3import (
3import (
4 "context"
4 "context"
5− "strings"
6 "testing"
5 "testing"
7 "time"
6 "time"
8
7
@@ -60,24 +59,6 @@ func TestBackgroundShell_Kill(t *testing.T) {
60 require.True(t, bgShell.IsDone())
59 require.True(t, bgShell.IsDone())
61}
60}
62
61
63−func TestBackgroundShell_GetOutput_NoHang(t *testing.T) {
64− t.Parallel()
65−
66− workingDir := t.TempDir()
67− ctx := context.Background()
68−
69− // Start a long-running background shell
70− bgManager := shell.GetBackgroundShellManager()
71− bgShell, err := bgManager.Start(ctx, workingDir, nil, "while true; do echo \"Hello from background job - $(date +%T)\"; sleep 1; done", "")
72− require.NoError(t, err)
73− defer bgManager.Kill(bgShell.ID)
74− // wait for 2 seconds
75− time.Sleep(2 * time.Second)
76− stdout, _, _, err := bgShell.GetOutput()
77− require.NoError(t, err)
78− require.Len(t, strings.Split(stdout, "\n"), 3)
79−}
80−
81func TestBackgroundShell_MultipleOutputCalls(t *testing.T) {
62func TestBackgroundShell_MultipleOutputCalls(t *testing.T) {
82 t.Parallel()
63 t.Parallel()
83
64
@@ -345,27 +326,4 @@ func TestBackgroundShell_AutoBackground(t *testing.T) {
345 require.True(t, ok, "Should be able to retrieve background shell")
326 require.True(t, ok, "Should be able to retrieve background shell")
346 require.Equal(t, bgShell.ID, retrieved.ID)
327 require.Equal(t, bgShell.ID, retrieved.ID)
347 })
328 })
348−
349− // Test that we can check output of long-running command later
350− t.Run("can check output after completion", func(t *testing.T) {
351− t.Parallel()
352− bgManager := shell.GetBackgroundShellManager()
353− bgShell, err := bgManager.Start(ctx, workingDir, nil, "sleep 3 && echo 'completed'", "")
354− require.NoError(t, err)
355− defer bgManager.Kill(bgShell.ID)
356−
357− // Initially should be running
358− _, _, done, _ := bgShell.GetOutput()
359− require.False(t, done, "Should be running initially")
360−
361− // Wait for completion
362− time.Sleep(4 * time.Second)
363−
364− // Now should be done
365− stdout, stderr, done, err := bgShell.GetOutput()
366− require.NoError(t, err)
367− require.True(t, done, "Should be done after waiting")
368− require.Contains(t, stdout, "completed")
369− require.Empty(t, stderr)
370− })
371}
329}