mirror of
https://github.com/openstf/stf
synced 2025-10-04 10:19:30 +02:00
Add a new command to generate fake devices for testing.
This commit is contained in:
parent
1c45b6eb70
commit
6acfa5b528
2 changed files with 86 additions and 0 deletions
33
lib/cli.js
33
lib/cli.js
|
@ -549,6 +549,39 @@ program
|
|||
})
|
||||
})
|
||||
|
||||
program
|
||||
.command('generate-fake-device')
|
||||
.description('generates a fake device for testing')
|
||||
.option('-n, --number <n>'
|
||||
, 'how many devices to create (defaults to 1)'
|
||||
, Number
|
||||
, 1)
|
||||
.action(function(options) {
|
||||
var log = logger.createLogger('cli:generate-fake-device')
|
||||
, fake = require('./util/fakedevice')
|
||||
, n = options.number
|
||||
|
||||
function next() {
|
||||
return fake.generate()
|
||||
.then(function(serial) {
|
||||
log.info('Created fake device "%s"', serial)
|
||||
|
||||
if (--n) {
|
||||
return next()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
next()
|
||||
.then(function() {
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(function(err) {
|
||||
log.fatal('Fake device creation had an error:', err.stack)
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
|
||||
program
|
||||
.command('local [serial..]')
|
||||
.description('start everything locally')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue