diff --git a/docs/en/writing-running-appium/server-args.md b/docs/en/writing-running-appium/server-args.md index 2340c09fc..468cc6697 100644 --- a/docs/en/writing-running-appium/server-args.md +++ b/docs/en/writing-running-appium/server-args.md @@ -20,7 +20,6 @@ All flags are optional, but some are required in conjunction with certain others |`-a`, `--address`|0.0.0.0|IP Address to listen on|`--address 0.0.0.0`| |`-p`, `--port`|4723|port to listen on|`--port 4723`| |`-bp`, `--bootstrap-port`|4724|(Android-only) port to use on device to talk to Appium|`--bootstrap-port 4724`| -|`-k`, `--keep-artifacts`|false|(IOS-only) Keep Instruments trace directories|| |`-r`, `--backend-retries`|3|(iOS-only) How many times to retry launching Instruments before saying it crashed or timed out|`--backend-retries 3`| |`--session-override`|false|Enables session override (clobbering)|| |`--full-reset`|false|(iOS) Delete the entire simulator folder. (Android) Reset app state by uninstalling app instead of clearing app data. On Android, this will also remove the app after the session is complete.|| @@ -77,3 +76,5 @@ All flags are optional, but some are required in conjunction with certain others |`--keep-keychains`|false|(iOS) Whether to keep keychains (Library/Keychains) when reset app between sessions|| |`--strict-caps`|false|Cause sessions to fail if desired caps are sent in that Appium does not recognize as valid for the selected device|| |`--tmp`|null|Absolute path to directory Appium can use to manage temporary files, like built-in iOS apps it needs to move around. On *nix/Mac defaults to /tmp, on Windows defaults to C:\Windows\Temp|| +|`--trace-dir`|null|Absolute path to directory Appium uses to stor trace, defaults +to `/appium-instruments`|| diff --git a/lib/devices/device.js b/lib/devices/device.js index a79bc706d..d3d60d087 100644 --- a/lib/devices/device.js +++ b/lib/devices/device.js @@ -31,6 +31,9 @@ Device.prototype.configure = function (args, caps) { if (this.args.tmpDir === null) { this.args.tmpDir = helpers.isWindows() ? "C:\\Windows\\Temp" : "/tmp"; } + if (this.args.traceDir === null) { + this.args.traceDir = path.resolve(this.args.tmpDir , 'appium-instruments'); + } }; Device.prototype.setArgFromCap = function (arg, cap) { diff --git a/lib/devices/ios/ios.js b/lib/devices/ios/ios.js index c65ad4d42..eb972f2f9 100644 --- a/lib/devices/ios/ios.js +++ b/lib/devices/ios/ios.js @@ -5,7 +5,6 @@ var path = require('path') , fs = require('fs') , _ = require('underscore') , logger = require('../../server/logger.js').get('appium') - , glob = require('glob') , exec = require('child_process').exec , spawn = require('child_process').spawn , bplistCreate = require('bplist-creator') @@ -120,7 +119,6 @@ IOS.prototype.configure = function (args, caps, cb) { IOS.prototype.setIOSArgs = function () { this.args.withoutDelay = !this.args.nativeInstrumentsLib; this.args.reset = !this.args.noReset; - this.args.removeTraceDir = !this.args.keepArtifacts; this.args.deviceName = this.args.deviceName || this.args.platformName; this.args.initialOrientation = this.capabilities.deviceOrientation || this.args.orientation || @@ -197,44 +195,6 @@ IOS.prototype.configurePreferences = function (cb) { }; IOS.prototype.preCleanup = function (cb) { - var removeTracedirs = function (innerCb) { - if (this.args.removeTraceDir) { - logger.debug("Cleaning up any tracedirs"); - glob("*.trace", {}, function (err, files) { - if (err) { - logger.error("Could not glob for tracedirs: " + err.message); - innerCb(err); - } else { - if (files.length > 0) { - var filesDone = 0; - var onDelete = function () { - filesDone++; - if (filesDone === files.length) { - innerCb(); - } - }; - _.each(files, function (file) { - file = path.resolve(process.cwd(), file); - rimraf(file, function (err) { - if (err) { - logger.warn("Problem cleaning up file: " + err.message); - } else { - logger.debug("Cleaned up " + file); - } - onDelete(); - }); - }); - } else { - logger.debug("No tracedirs to clean up"); - innerCb(); - } - } - }); - } else { - innerCb(); - } - }.bind(this); - var removeSocket = function (innerCb) { logger.debug("Removing any remaining instruments sockets"); rimraf(this.sock, function (err) { @@ -243,8 +203,7 @@ IOS.prototype.preCleanup = function (cb) { innerCb(); }.bind(this)); }.bind(this); - - async.series([removeSocket, removeTracedirs], cb); + removeSocket(cb); }; IOS.prototype.getNumericVersion = function () { @@ -327,8 +286,8 @@ IOS.prototype.startInstruments = function (cb) { if (err) return treatError(err, cb); // we don't call cb here, waiting for first connection or error }.bind(this) - , function (code, tracedir) { - this.onUnexpectedInstrumentsExit(code, tracedir); + , function (code) { + this.onUnexpectedInstrumentsExit(code); }.bind(this) ); }.bind(this) @@ -354,6 +313,7 @@ IOS.prototype.makeInstruments = function (cb) { , flakeyRetries: this.args.backendRetries , simulatorSdkAndDevice: this.iOSSDKVersion >= 7.1 ? this.getDeviceString() : null , tmpDir: path.resolve(this.args.tmpDir , 'appium-instruments') + , traceDir: this.args.traceDir }); cb(null, instruments); }.bind(this), function (err) { cb(err); } @@ -425,7 +385,7 @@ IOS.prototype.configureBootstrap = function (cb) { }); }; -IOS.prototype.onUnexpectedInstrumentsExit = function (code, traceDir) { +IOS.prototype.onUnexpectedInstrumentsExit = function (code) { logger.debug("Instruments exited unexpectedly"); if (typeof this.cbForCurrentCmd === "function") { // we were in the middle of waiting for a command when it died @@ -438,7 +398,7 @@ IOS.prototype.onUnexpectedInstrumentsExit = function (code, traceDir) { } } if (this.commandProxy) this.commandProxy.safeShutdown(); - this.shutdown(code, traceDir, this.onInstrumentsDie); + this.shutdown(code, this.onInstrumentsDie); }; IOS.prototype.setXcodeFolder = function (cb) { @@ -881,9 +841,10 @@ IOS.prototype.getDeviceString = function () { 'iPad - Simulator - iOS 7.1': 'iPad Retina (64-bit) - Simulator - iOS 7.1' }; if (CONFIG_FIX[iosDeviceString]) { + var oldDeviceString = iosDeviceString; iosDeviceString = CONFIG_FIX[iosDeviceString]; - logger.debug("Fixing device was changed from:\"", iosDeviceString, "\" to:\"", - CONFIG_FIX[iosDeviceString] + "\""); + logger.debug("Fixing device was changed from:\"", oldDeviceString, + "\" to:\"" + iosDeviceString + "\""); } } return iosDeviceString; @@ -1249,37 +1210,18 @@ IOS.prototype.stop = function (cb) { } else { this.commandProxy.shutdown(function (err) { if (err) logger.warn("Got warning when trying to close command proxy:", err); - this.instruments.shutdown(function (code, traceDir) { - this.shutdown(code, traceDir, cb); + this.instruments.shutdown(function (code) { + this.shutdown(code, cb); }.bind(this)); }.bind(this)); } }; -IOS.prototype.shutdown = function (code, traceDir, cb) { +IOS.prototype.shutdown = function (code, cb) { this.commandProxy = null; this.instruments = null; this.commandProxy = null; - var removeTraceDir = function (cb) { - if (this.args.removeTraceDir && traceDir) { - rimraf(traceDir, function (err) { - if (err) return cb(err); - logger.debug("Deleted tracedir we heard about from instruments (" + - traceDir + ")"); - cb(); - }); - } else { - cb(); - } - }.bind(this); - - async.series([ - removeTraceDir, - this.postCleanup.bind(this) - ], function () { - cb(); - }); - + this.postCleanup(cb); }; IOS.prototype.resetTimeout = deviceCommon.resetTimeout; diff --git a/lib/server/parser.js b/lib/server/parser.js index bef294b4c..e911de562 100644 --- a/lib/server/parser.js +++ b/lib/server/parser.js @@ -78,7 +78,8 @@ var args = [ , dest: 'keepArtifacts' , action: 'storeTrue' , required: false - , help: '(IOS-only) Keep Instruments trace directories' + , help: 'deprecated, no effect, trace is now in tmp dir by default and is ' + + ' cleared before each run. Please also refer to the --trace-dir flag.' , nargs: 0 }], @@ -522,6 +523,14 @@ var args = [ 'defaults to /tmp, on Windows defaults to C:\\Windows\\Temp' }], + [['--trace-dir'], { + defaultValue: null + , dest: 'traceDir' + , required: false + , help: 'Absolute path to directory Appium use to save ios instruments ' + + 'traces, defaults to /appium-instruments' + }], + [['--intent-action'], { dest: 'intentAction' , defaultValue: "android.intent.action.MAIN" diff --git a/submodules/appium-instruments b/submodules/appium-instruments index dc09fa44b..42b34d006 160000 --- a/submodules/appium-instruments +++ b/submodules/appium-instruments @@ -1 +1 @@ -Subproject commit dc09fa44bca22ec02ec0534f5eabe208884a51b6 +Subproject commit 42b34d0062d879308a3ce599306e1b2a97bd1841