@@ -39,12 +39,15 @@ test('[ Connection ] ::_listPorts (UNIX)', function(t) {
3939 SerialPort : require ( './helpers/mockSerial' ) . SerialPort
4040 } } ) ;
4141
42- var c = new ConnectionTest ( DEF_OPTS1 ) ;
43- c . _listPorts ( function ( error , ports ) {
44- t . ok ( ports . length , 'got a list of ports' ) ;
45- t . ok ( ports [ 2 ] . _standardPid , 'added _standardPid property' ) ;
46- t . error ( error , 'no error on listing' ) ;
47- } ) ;
42+ // nodejs 0.10.x race condition needs this
43+ setTimeout ( function ( ) {
44+ var c = new ConnectionTest ( DEF_OPTS1 ) ;
45+ c . _listPorts ( function ( error , ports ) {
46+ t . ok ( ports . length , 'got a list of ports' ) ;
47+ t . ok ( ports [ 2 ] . _standardPid , 'added _standardPid property' ) ;
48+ t . error ( error , 'no error on listing' ) ;
49+ } ) ;
50+ } , 200 ) ;
4851} ) ;
4952
5053test ( '[ Connection ] ::_listPorts (WINDOWS)' , function ( t ) {
@@ -61,12 +64,15 @@ test('[ Connection ] ::_listPorts (WINDOWS)', function(t) {
6164 SerialPort : require ( './helpers/mockSerial' ) . SerialPort
6265 } } ) ;
6366
64- var c = new ConnectionTest ( DEF_OPTS1 ) ;
65- c . _listPorts ( function ( error , ports ) {
66- t . ok ( ports . length , 'got a list of ports' ) ;
67- t . ok ( ports [ 0 ] . _standardPid , 'added _standardPid property' ) ;
68- t . error ( error , 'no error on listing' ) ;
69- } ) ;
67+ // nodejs 0.10.x race condition needs this
68+ setTimeout ( function ( ) {
69+ var c = new ConnectionTest ( DEF_OPTS1 ) ;
70+ c . _listPorts ( function ( error , ports ) {
71+ t . ok ( ports . length , 'got a list of ports' ) ;
72+ t . ok ( ports [ 0 ] . _standardPid , 'added _standardPid property' ) ;
73+ t . error ( error , 'no error on listing' ) ;
74+ } ) ;
75+ } , 200 ) ;
7076} ) ;
7177
7278test ( '[ Connection ] ::_sniffPort (UNIX)' , function ( t ) {
@@ -88,12 +94,15 @@ test('[ Connection ] ::_sniffPort (UNIX)', function(t) {
8894 SerialPort : require ( './helpers/mockSerial' ) . SerialPort
8995 } } ) ;
9096
91- var c = new ConnectionTest ( DEF_OPTS1 ) ;
92- c . _sniffPort ( function ( error , match ) {
93- t . ok ( match . length , 'board was detected' ) ;
94- t . equal ( match [ 0 ] . comName , '/dev/cu.usbmodem1421' , 'correct comName to match against' ) ;
95- t . error ( error , 'no error on return' ) ;
96- } ) ;
97+ // nodejs 0.10.x race condition needs this
98+ setTimeout ( function ( ) {
99+ var c = new ConnectionTest ( DEF_OPTS1 ) ;
100+ c . _sniffPort ( function ( error , match ) {
101+ t . ok ( match . length , 'board was detected' ) ;
102+ t . equal ( match [ 0 ] . comName , '/dev/cu.usbmodem1421' , 'correct comName to match against' ) ;
103+ t . error ( error , 'no error on return' ) ;
104+ } ) ;
105+ } , 200 ) ;
97106} ) ;
98107
99108test ( '[ Connection ] ::_sniffPort (WINDOWS)' , function ( t ) {
@@ -110,12 +119,15 @@ test('[ Connection ] ::_sniffPort (WINDOWS)', function(t) {
110119 SerialPort : require ( './helpers/mockSerial' ) . SerialPort
111120 } } ) ;
112121
113- var c = new ConnectionTest ( DEF_OPTS1 ) ;
114- c . _sniffPort ( function ( error , match ) {
115- t . ok ( match . length , 'board was detected' ) ;
116- t . equal ( match [ 0 ] . comName , 'COM3' , 'correct comName to match against' ) ;
117- t . error ( error , 'no error on return' ) ;
118- } ) ;
122+ // nodejs 0.10.x race condition needs this
123+ setTimeout ( function ( ) {
124+ var c = new ConnectionTest ( DEF_OPTS1 ) ;
125+ c . _sniffPort ( function ( error , match ) {
126+ t . ok ( match . length , 'board was detected' ) ;
127+ t . equal ( match [ 0 ] . comName , 'COM3' , 'correct comName to match against' ) ;
128+ t . error ( error , 'no error on return' ) ;
129+ } ) ;
130+ } , 200 ) ;
119131} ) ;
120132
121133test ( '[ Connection ] ::_cycleDTR' , function ( t ) {
@@ -161,8 +173,12 @@ test('[ Connection ] ::_pollForPort', function(t) {
161173 port : '/dev/cu.usbmodem1421'
162174 } ;
163175
164- var c = new ConnectionTest ( options ) ;
165- c . _pollForPort ( function ( error ) {
166- t . error ( error , 'no error on polling result' ) ;
167- } ) ;
176+ // nodejs 0.10.x race condition needs this
177+ setTimeout ( function ( ) {
178+ var c = new ConnectionTest ( options ) ;
179+ c . _pollForPort ( function ( error ) {
180+ t . error ( error , 'no error on polling result' ) ;
181+ } ) ;
182+ } , 200 ) ;
183+
168184} ) ;
0 commit comments