configurable traceDir + got rid of keepArtefacts/removeTraceDir arg

This commit is contained in:
sebv
2014-07-08 19:57:12 +08:00
parent a51d268576
commit ea942455e9
5 changed files with 29 additions and 74 deletions

View File

@@ -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 `<tmpDir>/appium-instruments`||

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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 <tmp dir>/appium-instruments'
}],
[['--intent-action'], {
dest: 'intentAction'
, defaultValue: "android.intent.action.MAIN"