This commit is contained in:
2023-01-31 22:41:12 +01:00
parent 1990e5d32d
commit fdc590c8c3
3 changed files with 226 additions and 118 deletions

View File

@@ -1,6 +1,9 @@
package cmdext
import "testing"
import (
"testing"
"time"
)
func TestStdout(t *testing.T) {
@@ -57,3 +60,27 @@ func TestStdcombined(t *testing.T) {
}
}
func TestPartialRead(t *testing.T) {
res1, err := Runner("python").
Arg("-c").
Arg("import sys; import time; print(\"first message\", flush=True); time.sleep(5); print(\"cant see me\", flush=True);").
Timeout(100 * time.Millisecond).
Run()
if err != nil {
t.Errorf("%v", err)
}
if !res1.CommandTimedOut {
t.Errorf("!CommandTimedOut")
}
if res1.StdErr != "" {
t.Errorf("res1.StdErr == '%v'", res1.StdErr)
}
if res1.StdOut != "first message\n" {
t.Errorf("res1.StdOut == '%v'", res1.StdOut)
}
if res1.StdCombined != "first message\n" {
t.Errorf("res1.StdCombined == '%v'", res1.StdCombined)
}
}