30
30
public final class SpoonRunner {
31
31
private static final String DEFAULT_TITLE = "Spoon Execution" ;
32
32
public static final String DEFAULT_OUTPUT_DIRECTORY = "spoon-output" ;
33
+ private static final int DEFAULT_ADB_TIMEOUT = 10 * 60 ; //10 minutes
33
34
34
35
private final String title ;
35
36
private final File androidSdk ;
@@ -38,14 +39,15 @@ public final class SpoonRunner {
38
39
private final File output ;
39
40
private final boolean debug ;
40
41
private final boolean noAnimations ;
42
+ private final int adbTimeout ;
41
43
private final String className ;
42
44
private final String methodName ;
43
45
private final Set <String > serials ;
44
46
private final String classpath ;
45
47
private final IRemoteAndroidTestRunner .TestSize testSize ;
46
48
47
49
private SpoonRunner (String title , File androidSdk , File applicationApk , File instrumentationApk ,
48
- File output , boolean debug , boolean noAnimations , Set <String > serials , String classpath ,
50
+ File output , boolean debug , boolean noAnimations , int adbTimeout , Set <String > serials , String classpath ,
49
51
String className , String methodName , IRemoteAndroidTestRunner .TestSize testSize ) {
50
52
this .title = title ;
51
53
this .androidSdk = androidSdk ;
@@ -54,6 +56,7 @@ private SpoonRunner(String title, File androidSdk, File applicationApk, File ins
54
56
this .output = output ;
55
57
this .debug = debug ;
56
58
this .noAnimations = noAnimations ;
59
+ this .adbTimeout = adbTimeout ;
57
60
this .className = className ;
58
61
this .methodName = methodName ;
59
62
this .classpath = classpath ;
@@ -191,7 +194,7 @@ static boolean parseOverallSuccess(SpoonSummary summary) {
191
194
192
195
private SpoonDeviceRunner getTestRunner (String serial , SpoonInstrumentationInfo testInfo ) {
193
196
return new SpoonDeviceRunner (androidSdk , applicationApk , instrumentationApk , output , serial ,
194
- debug , noAnimations , classpath , testInfo , className , methodName , testSize );
197
+ debug , noAnimations , adbTimeout , classpath , testInfo , className , methodName , testSize );
195
198
}
196
199
197
200
/** Build a test suite for the specified devices and configuration. */
@@ -208,6 +211,7 @@ public static class Builder {
208
211
private String methodName ;
209
212
private boolean noAnimations ;
210
213
private IRemoteAndroidTestRunner .TestSize testSize ;
214
+ private int adbTimeout ;
211
215
212
216
/** Identifying title for this execution. */
213
217
public Builder setTitle (String title ) {
@@ -259,6 +263,12 @@ public Builder setNoAnimations(boolean noAnimations) {
259
263
return this ;
260
264
}
261
265
266
+ /** Set ADB timeout. */
267
+ public Builder setAdbTimeout (int value ) {
268
+ this .adbTimeout = value ;
269
+ return this ;
270
+ }
271
+
262
272
/** Add a device serial for test execution. */
263
273
public Builder addDevice (String serial ) {
264
274
checkNotNull (serial , "Serial cannot be null." );
@@ -317,7 +327,7 @@ public SpoonRunner build() {
317
327
}
318
328
319
329
return new SpoonRunner (title , androidSdk , applicationApk , instrumentationApk , output , debug ,
320
- noAnimations , serials , classpath , className , methodName , testSize );
330
+ noAnimations , adbTimeout , serials , classpath , className , methodName , testSize );
321
331
}
322
332
}
323
333
@@ -357,6 +367,9 @@ static class CommandLineArgs {
357
367
@ Parameter (names = { "--no-animations" }, description = "Disable animated gif generation" )
358
368
public boolean noAnimations ;
359
369
370
+ @ Parameter (names = { "--adb-timeout" }, description = "Set maximum execution time per test in seconds (10min default)" )
371
+ public int adbTimeoutSeconds = DEFAULT_ADB_TIMEOUT ;
372
+
360
373
@ Parameter (names = { "--debug" }, hidden = true )
361
374
public boolean debug ;
362
375
@@ -416,6 +429,7 @@ public static void main(String... args) {
416
429
.setAndroidSdk (parsedArgs .sdk )
417
430
.setNoAnimations (parsedArgs .noAnimations )
418
431
.setTestSize (parsedArgs .size )
432
+ .setAdbTimeout (parsedArgs .adbTimeoutSeconds * 1000 )
419
433
.setClassName (parsedArgs .className )
420
434
.setMethodName (parsedArgs .methodName )
421
435
.useAllAttachedDevices ()
0 commit comments