@@ -20,35 +20,41 @@ import (
20
20
"testing"
21
21
"time"
22
22
23
+ "github.com/arduino/arduino-cli/executils"
23
24
"github.com/stretchr/testify/require"
24
25
)
25
26
26
27
func TestDiscoveryStdioHandling (t * testing.T ) {
27
- disc , err := New ("test" , "go" , "run" , "testdata/cat/main.go" ) // copy stdin to stdout
28
+ builder , err := executils .NewProcess ("go" , "build" )
29
+ require .NoError (t , err )
30
+ builder .SetDir ("testdata/cat" )
31
+ require .NoError (t , builder .Run ())
32
+
33
+ disc , err := New ("test" , "testdata/cat/cat" ) // copy stdin to stdout
28
34
require .NoError (t , err )
29
35
30
36
_ , err = disc .outgoingCommandsPipe .Write ([]byte (`{ "eventType":` )) // send partial JSON
31
37
require .NoError (t , err )
32
- msg , err := disc .waitMessage (time .Millisecond * 1000 )
38
+ msg , err := disc .waitMessage (time .Millisecond * 100 )
33
39
require .Error (t , err )
34
40
require .Nil (t , msg )
35
41
36
42
_ , err = disc .outgoingCommandsPipe .Write ([]byte (`"ev1" }{ ` )) // complete previous json and start another one
37
43
require .NoError (t , err )
38
44
39
- msg , err = disc .waitMessage (time .Millisecond * 1000 )
45
+ msg , err = disc .waitMessage (time .Millisecond * 100 )
40
46
require .NoError (t , err )
41
47
require .NotNil (t , msg )
42
48
require .Equal (t , "ev1" , msg .EventType )
43
49
44
- msg , err = disc .waitMessage (time .Millisecond * 1000 )
50
+ msg , err = disc .waitMessage (time .Millisecond * 100 )
45
51
require .Error (t , err )
46
52
require .Nil (t , msg )
47
53
48
54
_ , err = disc .outgoingCommandsPipe .Write ([]byte (`"eventType":"ev2" }` )) // complete previous json
49
55
require .NoError (t , err )
50
56
51
- msg , err = disc .waitMessage (time .Millisecond * 1000 )
57
+ msg , err = disc .waitMessage (time .Millisecond * 100 )
52
58
require .NoError (t , err )
53
59
require .NotNil (t , msg )
54
60
require .Equal (t , "ev2" , msg .EventType )
@@ -57,7 +63,7 @@ func TestDiscoveryStdioHandling(t *testing.T) {
57
63
58
64
err = disc .outgoingCommandsPipe .(io.ReadCloser ).Close ()
59
65
require .NoError (t , err )
60
- time .Sleep (time .Millisecond * 200 )
66
+ time .Sleep (time .Millisecond * 100 )
61
67
62
68
require .False (t , disc .IsAlive ())
63
69
}
0 commit comments