Commit b2dd7214 authored by Aneta Steimarova's avatar Aneta Steimarova

#691 Made tests run parallel on multiple connected devices

parent c9573a40
......@@ -364,27 +364,28 @@ task runAndroidITestBundle (dependsOn:'assembleITest'){
}
def connectedDevices = 0
def exceptions = ""
def threads = []
adbOut.toString().eachLine { line ->
if (!line.contains("List") && line.contains("device")) {
connectedDevices++;
int i;
for (i=0; i<20; i++) {
if(line.charAt(i)=='\t') break
}
def device = line.substring(0, i)
println "Connected device: " + device
def adbLsOut = new ByteArrayOutputStream()
exec {
commandLine "$adb", '-s', device, 'shell', 'ls'
standardOutput = adbLsOut
}
if(adbLsOut.toString().contains("error")){
exceptions += "[iTest-" + device + "] Device does not meet requirements for running tests. Try to check out if device has SD card and SD card is accessible from computer."
println "[iTest-" + device + "] THIS DEVICE DOES NOT MEET REQUIREMENTS FOR RUNNING TESTS."
def th = new Thread({ //run devices parallel
if (!line.contains("List") && line.contains("device")) {
connectedDevices++
def device = line.split('\t')[0]
println "Connected device: " + device
def adbLsOut = new ByteArrayOutputStream()
exec {
commandLine "$adb", '-s', device, 'shell', 'ls'
standardOutput = adbLsOut
}
if (adbLsOut.toString().contains("error")) {
exceptions += "[iTest-" + device + "] Device does not meet requirements for running tests. Try to check out if device has SD card and SD card is accessible from computer."
println "[iTest-" + device + "] THIS DEVICE DOES NOT MEET REQUIREMENTS FOR RUNNING TESTS."
} else exceptions += androidITestBundle(device)
}
else exceptions += androidITestBundle(device)
}
})
threads << th
}
threads.each { it.start() }
threads.each { it.join() }
if(connectedDevices<1) throw new GradleException("NO CONNECTED DEVICE WAS FOUND!")
if(exceptions!="") throw new GradleException(exceptions)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment