mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:03:30 +02:00
Keep better track of vital streams. Add monkey.
This commit is contained in:
@@ -40,6 +40,23 @@ devutil.ensureUnusedPort = function(adb, serial, port) {
|
||||
})
|
||||
}
|
||||
|
||||
devutil.waitForPort = function(adb, serial, port) {
|
||||
function closedError(err) {
|
||||
return err.message === 'closed'
|
||||
}
|
||||
return adb.openTcpAsync(serial, port)
|
||||
.then(function(conn) {
|
||||
conn.end()
|
||||
return port
|
||||
})
|
||||
.catch(closedError, function(err) {
|
||||
return Promise.delay(100)
|
||||
.then(function() {
|
||||
return devutil.waitForPort(adb, serial, port)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
devutil.killProcsByComm = function(adb, serial, comm, bin) {
|
||||
return adb.shellAsync(serial, ['ps', comm])
|
||||
.then(function(out) {
|
||||
|
||||
24
lib/util/vitals.js
Normal file
24
lib/util/vitals.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var events = require('events')
|
||||
var util = require('util')
|
||||
|
||||
function Vitals() {
|
||||
events.EventEmitter.call(this)
|
||||
}
|
||||
|
||||
util.inherits(Vitals, events.EventEmitter)
|
||||
|
||||
Vitals.prototype.register = function(name, stream) {
|
||||
var that = this
|
||||
|
||||
stream.on('end', function() {
|
||||
that.emit('end', name)
|
||||
})
|
||||
|
||||
stream.on('error', function(err) {
|
||||
that.emit('error', name, err)
|
||||
})
|
||||
|
||||
return stream
|
||||
}
|
||||
|
||||
module.exports = Vitals
|
||||
Reference in New Issue
Block a user