Streamline run log and update handling

This commit is contained in:
npc0-hue
2026-09-03 18:24:39 +08:00
parent 330b1c0130
commit 26c07e232d
3 changed files with 59 additions and 8 deletions
+21
View File
@@ -553,6 +553,27 @@ func TestOSProcessSupervisorRelaysRawCarriageReturn(t *testing.T) {
if len(output) != 1 || output[0] != "stdout:raw\r" {
t.Fatalf("expected raw CR to be relayed, got %+v", output)
}
if result.Stdout != "" || result.Stderr != "" {
t.Fatalf("relayed process output must not be duplicated into result buffers, got %+v", result)
}
}
func TestOSProcessSupervisorChunksLongRelayedLinesWithoutRewriting(t *testing.T) {
var output []string
result, err := (OSProcessSupervisor{}).Run(context.Background(), ProcessCommand{
Args: []string{"sh", "-c", "printf %70000s | tr ' ' x"},
OutputLine: func(stream string, line string) {
if stream == "stdout" {
output = append(output, line)
}
},
})
if err != nil || result.ExitCode != 0 {
t.Fatalf("run process: result=%+v err=%v", result, err)
}
if len(output) < 2 || strings.Join(output, "") != strings.Repeat("x", 70000) {
t.Fatalf("expected long relayed line to reassemble exactly, chunks=%d", len(output))
}
}
func TestProcessCommandJSONOmitsOutputCallback(t *testing.T) {