Merge pull request #2731 from sebv/dynamic-bootstrap

Dynamic bootstrap + minor changes
This commit is contained in:
Jonathan Lipps
2014-06-03 17:06:29 -07:00
7 changed files with 51 additions and 30 deletions

View File

@@ -30,7 +30,7 @@ var path = require('path')
, mkdirp = require('mkdirp')
, getSimRoot = settings.getSimRoot
, fruitstrap = path.resolve(__dirname, '../../../build/fruitstrap/fruitstrap')
, uiauto = require('appium-uiauto')
, prepareBootstrap = require('./uiauto').prepareBootstrap
, UnknownError = errors.UnknownError;
// XML Plist library helper
@@ -286,8 +286,11 @@ IOS.prototype.start = function (cb, onDie) {
IOS.prototype.createInstruments = function (cb) {
logger.debug("Creating instruments");
this.instruments = this.makeInstruments();
cb();
this.makeInstruments(function (err, instruments) {
if (err) return cb(err);
this.instruments = instruments;
cb();
}.bind(this));
};
IOS.prototype.startInstruments = function (cb) {
@@ -309,22 +312,27 @@ IOS.prototype.startInstruments = function (cb) {
}.bind(this));
};
IOS.prototype.makeInstruments = function () {
return new Instruments({
app: this.args.app || this.args.bundleId
, udid: this.args.udid
, processArguments: this.args.processArguments
, ignoreStartupExit: this.shouldIgnoreInstrumentsExit()
, bootstrap: uiauto.bootstrap
, template: this.args.automationTraceTemplatePath
, sock: sock
, withoutDelay: this.args.withoutDelay
, xcodeVersion: this.xcodeVersion
, webSocket: this.args.webSocket
, launchTimeout: this.args.launchTimeout
, flakeyRetries: this.args.backendRetries
, simulatorSdkAndDevice: this.iOSSDKVersion >= 7.1 ? this.getDeviceString() : null
});
IOS.prototype.makeInstruments = function (cb) {
prepareBootstrap({ verboseInstruments: !this.args.quiet }).then(
function (bootstrapPath) {
var instruments = new Instruments({
app: this.args.app || this.args.bundleId
, udid: this.args.udid
, processArguments: this.args.processArguments
, ignoreStartupExit: this.shouldIgnoreInstrumentsExit()
, bootstrap: bootstrapPath
, template: this.args.automationTraceTemplatePath
, sock: sock
, withoutDelay: this.args.withoutDelay
, xcodeVersion: this.xcodeVersion
, webSocket: this.args.webSocket
, launchTimeout: this.args.launchTimeout
, flakeyRetries: this.args.backendRetries
, simulatorSdkAndDevice: this.iOSSDKVersion >= 7.1 ? this.getDeviceString() : null
});
cb(null, instruments);
}.bind(this), function (err) { cb(err); }
);
};
IOS.prototype.shouldIgnoreInstrumentsExit = function () {
@@ -578,10 +586,11 @@ IOS.prototype.instantLaunchAndQuit = function (cb) {
"to populate the applications and preference dirs");
this.setDeviceAndLaunchSimulator(function (err) {
if (err) return cb(err);
var instrumentsIsDeadLongLiveInstruments = this.makeInstruments();
instrumentsIsDeadLongLiveInstruments.launchAndKill(1000, function (err) {
if (err) return cb(err);
this.endSimulator(cb);
this.makeInstruments(function (err, instruments) {
instruments.launchAndKill(1000, function (err) {
if (err) return cb(err);
this.endSimulator(cb);
}.bind(this));
}.bind(this));
}.bind(this));
};

View File

@@ -0,0 +1,9 @@
// Gets instrument from npm package and setup logger
"use strict";
var uiauto = require('appium-uiauto'),
logger = uiauto.logger;
logger.init(require('../../server/logger.js').get('appium'));
module.exports = uiauto;

View File

@@ -226,17 +226,17 @@ module.exports.startListening = function (server, args, parser, appiumVer, appiu
if (appiumRev) {
welcome += " (REV " + appiumRev + ")";
}
logger.info(welcome);
logger.warn(welcome);
var logMessage = "Appium REST http interface listener started on " +
args.address + ":" + args.port;
logger.info(logMessage);
logger.warn(logMessage);
startAlertSocket(server, appiumServer);
if (args.nodeconfig !== null) {
gridRegister.registerNode(args.nodeconfig, args.address, args.port);
}
var showArgs = getNonDefaultArgs(parser, args);
if (_.size(showArgs)) {
logger.info("Non-default server args: " + JSON.stringify(showArgs));
logger.warn("Non-default server args: " + JSON.stringify(showArgs));
}
});
server.on('error', function (err) {

View File

@@ -44,6 +44,9 @@ module.exports.init = function (args) {
if (args.quiet) {
logger.transports.console.level = 'warn';
} else {
//TODO: pass loglevel in server args
logger.transports.console.level = process.env.APPIUM_LOGLEVEL || 'info';
}
if (args.log) {

View File

@@ -43,8 +43,8 @@
"adm-zip": "~0.4.4",
"appium-adb": "~1.0.1",
"appium-atoms": "~0.0.5",
"appium-instruments": "~0.1.21",
"appium-uiauto": "~0.0.20",
"appium-instruments": "1.0.0-beta1",
"appium-uiauto": "1.0.0-beta1",
"argparse": "~0.1.15",
"async": "~0.9.0",
"binary-cookies": "~0.1.1",