@@ -7,13 +7,19 @@ import java.io.{InputStream, OutputStream, PipedInputStream, PipedOutputStream,
7
7
ByteArrayOutputStream , IOException , Closeable }
8
8
import java .lang .reflect .InvocationTargetException
9
9
import scala .concurrent .{Await , Future }
10
- import scala .concurrent .duration .{Duration , SECONDS }
11
10
import scala .concurrent .ExecutionContext .Implicits .global
12
11
import scala .util .control .Exception .ignoring
13
12
14
- // Each test normally ends in a moment, but for failure cases, waits until one second .
13
+ // Each test normally ends in a moment, but for failure cases, waits two seconds .
15
14
// SI-7350, SI-8768
16
15
16
+ // one second wasn't always enough --
17
+ // https://github.com/scala/scala-dev/issues/313
18
+ object TestDuration {
19
+ import scala .concurrent .duration .{Duration , SECONDS }
20
+ val Standard = Duration (2 , SECONDS )
21
+ }
22
+
17
23
@ RunWith (classOf [JUnit4 ])
18
24
class PipedProcessTest {
19
25
class ProcessMock (error : Boolean ) extends Process {
@@ -81,7 +87,7 @@ class PipedProcessTest {
81
87
val f = Future {
82
88
p.callRunAndExitValue(source, sink)
83
89
}
84
- Await .result(f, Duration ( 1 , SECONDS ) )
90
+ Await .result(f, TestDuration . Standard )
85
91
assert(source.releaseCount == 0 )
86
92
assert(sink.releaseCount == 0 )
87
93
assert(a.destroyCount == 0 )
@@ -102,7 +108,7 @@ class PipedProcessTest {
102
108
p.callRunAndExitValue(source, sink)
103
109
}
104
110
}
105
- Await .result(f, Duration ( 1 , SECONDS ) )
111
+ Await .result(f, TestDuration . Standard )
106
112
assert(source.releaseCount == 1 )
107
113
assert(sink.releaseCount == 1 )
108
114
assert(a.destroyCount == 0 )
@@ -123,7 +129,7 @@ class PipedProcessTest {
123
129
p.callRunAndExitValue(source, sink)
124
130
}
125
131
}
126
- Await .result(f, Duration ( 1 , SECONDS ) )
132
+ Await .result(f, TestDuration . Standard )
127
133
assert(source.releaseCount == 1 )
128
134
assert(sink.releaseCount == 1 )
129
135
assert(a.destroyCount == 0 )
@@ -142,7 +148,7 @@ class PipedProcessTest {
142
148
val f = Future {
143
149
p.callRunAndExitValue(source, sink)
144
150
}
145
- Await .result(f, Duration ( 1 , SECONDS ) )
151
+ Await .result(f, TestDuration . Standard )
146
152
assert(source.releaseCount == 1 )
147
153
assert(sink.releaseCount == 1 )
148
154
assert(a.destroyCount == 1 )
@@ -161,7 +167,7 @@ class PipedProcessTest {
161
167
val f = Future {
162
168
p.callRunAndExitValue(source, sink)
163
169
}
164
- Await .result(f, Duration ( 1 , SECONDS ) )
170
+ Await .result(f, TestDuration . Standard )
165
171
assert(source.releaseCount == 1 )
166
172
assert(sink.releaseCount == 1 )
167
173
assert(a.destroyCount == 1 )
@@ -235,7 +241,7 @@ class PipeSourceSinkTest {
235
241
source.join()
236
242
sink.join()
237
243
}
238
- Await .result(f, Duration ( 1 , SECONDS ) )
244
+ Await .result(f, TestDuration . Standard )
239
245
assert(in.closed == true )
240
246
assert(out.closed == true )
241
247
assert(source.isReleased == true )
@@ -253,7 +259,7 @@ class PipeSourceSinkTest {
253
259
source.release()
254
260
sink.release()
255
261
}
256
- Await .result(f, Duration ( 1 , SECONDS ) )
262
+ Await .result(f, TestDuration . Standard )
257
263
assert(out.closed == true )
258
264
assert(source.isReleased == true )
259
265
assert(sink.isReleased == true )
@@ -270,13 +276,13 @@ class PipeSourceSinkTest {
270
276
source.release()
271
277
sink.release()
272
278
}
273
- Await .result(f, Duration ( 1 , SECONDS ) )
279
+ Await .result(f, TestDuration . Standard )
274
280
assert(in.closed == true )
275
281
assert(source.isReleased == true )
276
282
assert(sink.isReleased == true )
277
283
}
278
284
279
- // PipeSource and PipeSink must release resources when interrupted during copy streams"
285
+ // PipeSource and PipeSink must release resources when interrupted during copy streams
280
286
@ Test
281
287
def runloopInterrupted () {
282
288
val in = new DebugInfinityInputStream
@@ -290,7 +296,7 @@ class PipeSourceSinkTest {
290
296
source.release()
291
297
sink.release()
292
298
}
293
- Await .result(f, Duration ( 1 , SECONDS ) )
299
+ Await .result(f, TestDuration . Standard )
294
300
assert(in.closed == true )
295
301
assert(out.closed == true )
296
302
assert(source.isReleased == true )
0 commit comments