mirror of
https://github.com/openstf/stf
synced 2025-10-04 18:29:17 +02:00
Move more work to devutil.
This commit is contained in:
parent
3c55f91ee9
commit
6c350d0068
2 changed files with 31 additions and 27 deletions
|
@ -90,14 +90,8 @@ module.exports = function(options) {
|
|||
])
|
||||
})
|
||||
.then(function() {
|
||||
var port = 2870
|
||||
return adb.openTcpAsync(options.serial, port)
|
||||
.then(function(conn) {
|
||||
conn.end()
|
||||
throw new Error(util.format('Old connection still lives on port %d', port))
|
||||
})
|
||||
.catch(function(err) {
|
||||
if (err.message === 'closed') {
|
||||
return devutil.ensureUnusedPort(adb, options.serial, 2870)
|
||||
.then(function(port) {
|
||||
return adb.shellAsync(options.serial, [
|
||||
vendor.bin.dest
|
||||
, '--lib', vendor.lib.dest
|
||||
|
@ -113,10 +107,6 @@ module.exports = function(options) {
|
|||
selfDestruct()
|
||||
})
|
||||
})
|
||||
}
|
||||
else {
|
||||
throw err
|
||||
}
|
||||
})
|
||||
})
|
||||
.done(function() {
|
||||
|
|
|
@ -26,6 +26,20 @@ devutil.vendorFiles = function(identity) {
|
|||
}
|
||||
}
|
||||
|
||||
devutil.ensureUnusedPort = function(adb, serial, port) {
|
||||
function closedError(err) {
|
||||
return err.message === 'closed'
|
||||
}
|
||||
return adb.openTcpAsync(serial, port)
|
||||
.then(function(conn) {
|
||||
conn.end()
|
||||
throw new Error(util.format('Port "%d" should be unused', port))
|
||||
})
|
||||
.catch(closedError, function(err) {
|
||||
return Promise.resolve(port)
|
||||
})
|
||||
}
|
||||
|
||||
devutil.killProcsByComm = function(adb, serial, comm, bin) {
|
||||
return adb.shellAsync(serial, ['ps', comm])
|
||||
.then(function(out) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue