v0.0.77
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cmdext
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -196,3 +197,30 @@ func TestPartialReadUnflushedStderr(t *testing.T) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestListener(t *testing.T) {
|
||||
|
||||
_, err := Runner("python").
|
||||
Arg("-c").
|
||||
Arg("import sys;" +
|
||||
"import time;" +
|
||||
"print(\"message 1\", flush=True);" +
|
||||
"time.sleep(1);" +
|
||||
"print(\"message 2\", flush=True);" +
|
||||
"time.sleep(1);" +
|
||||
"print(\"message 3\", flush=True);" +
|
||||
"time.sleep(1);" +
|
||||
"print(\"message 4\", file=sys.stderr, flush=True);" +
|
||||
"time.sleep(1);" +
|
||||
"print(\"message 5\", flush=True);" +
|
||||
"time.sleep(1);" +
|
||||
"print(\"final\");").
|
||||
ListenStdout(func(s string) { fmt.Printf("@@STDOUT <<- %v (%v)\n", s, time.Now().Format(time.RFC3339Nano)) }).
|
||||
ListenStderr(func(s string) { fmt.Printf("@@STDERR <<- %v (%v)\n", s, time.Now().Format(time.RFC3339Nano)) }).
|
||||
Timeout(10 * time.Second).
|
||||
Run()
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user