mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Port to new adbkit.
This commit is contained in:
parent
ca401d7b9c
commit
d90d450400
4 changed files with 38 additions and 32 deletions
|
@ -10,6 +10,10 @@ var pathutil = require('./pathutil')
|
|||
|
||||
var devutil = module.exports = Object.create(null)
|
||||
|
||||
function closedError(err) {
|
||||
return err.message.indexOf('closed') !== -1
|
||||
}
|
||||
|
||||
devutil.matchesRequirements = function(capabilities, requirements) {
|
||||
return requirements.every(function(req) {
|
||||
var capability = capabilities[req.name]
|
||||
|
@ -61,10 +65,7 @@ devutil.vendorFiles = function(identity) {
|
|||
}
|
||||
|
||||
devutil.ensureUnusedPort = function(adb, serial, port) {
|
||||
function closedError(err) {
|
||||
return err.message === 'closed'
|
||||
}
|
||||
return adb.openTcpAsync(serial, port)
|
||||
return adb.openTcp(serial, port)
|
||||
.then(function(conn) {
|
||||
conn.end()
|
||||
throw new Error(util.format('Port "%d" should be unused', port))
|
||||
|
@ -75,10 +76,7 @@ devutil.ensureUnusedPort = function(adb, serial, port) {
|
|||
}
|
||||
|
||||
devutil.waitForPort = function(adb, serial, port) {
|
||||
function closedError(err) {
|
||||
return err.message === 'closed'
|
||||
}
|
||||
return adb.openTcpAsync(serial, port)
|
||||
return adb.openTcp(serial, port)
|
||||
.then(function(conn) {
|
||||
conn.port = port
|
||||
return conn
|
||||
|
@ -92,10 +90,7 @@ devutil.waitForPort = function(adb, serial, port) {
|
|||
}
|
||||
|
||||
devutil.waitForPortToFree = function(adb, serial, port) {
|
||||
function closedError(err) {
|
||||
return err.message === 'closed'
|
||||
}
|
||||
return adb.openTcpAsync(serial, port)
|
||||
return adb.openTcp(serial, port)
|
||||
.then(function(conn) {
|
||||
var resolver = Promise.defer()
|
||||
|
||||
|
@ -126,7 +121,7 @@ devutil.listPidsByComm = function(adb, serial, comm, bin) {
|
|||
shell: true
|
||||
}
|
||||
|
||||
return adb.shellAsync(serial, ['ps', comm])
|
||||
return adb.shell(serial, ['ps', comm])
|
||||
.then(function(out) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var header = false
|
||||
|
@ -168,7 +163,7 @@ devutil.killProcsByComm = function(adb, serial, comm, bin, mode) {
|
|||
if (!pids.length) {
|
||||
return Promise.resolve()
|
||||
}
|
||||
return adb.shellAsync(serial, ['kill', mode || -15].concat(pids))
|
||||
return adb.shell(serial, ['kill', mode || -15].concat(pids))
|
||||
.then(function(out) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
out.on('end', resolve)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue