mirror of
https://github.com/appium/appium.git
synced 2026-04-30 15:30:20 -05:00
allow setting of tmp dir appium uses via --tmp flag
This commit is contained in:
@@ -49,8 +49,8 @@ All flags are optional, but some are required in conjunction with certain others
|
||||
|`--default-device`, `-dd`|false|(IOS-Simulator-only) use the default simulator that instruments launches on its own||
|
||||
|`--force-iphone`|false|(IOS-only) Use the iPhone Simulator no matter what the app wants||
|
||||
|`--force-ipad`|false|(IOS-only) Use the iPad Simulator no matter what the app wants||
|
||||
|`--language`|null|language for the iOS simulator or Android Device|`--language en`|
|
||||
|`--locale`|null|locale for the iOS simulator or Android Device|`--locale en_US`|
|
||||
|`--language`|null|(IOS-only) language for the iOS simulator|`--language en`|
|
||||
|`--locale`|null|(IOS-only) locale for the iOS simulator|`--locale en_US`|
|
||||
|`--calendar-format`|null|(IOS-only) calendar format for the iOS simulator|`--calendar-format gregorian`|
|
||||
|`--orientation`|null|(IOS-only) use LANDSCAPE or PORTRAIT to initialize all requests to this orientation|`--orientation LANDSCAPE`|
|
||||
|`--tracetemplate`|null|(IOS-only) .tracetemplate file to use with Instruments|`--tracetemplate /Users/me/Automation.tracetemplate`|
|
||||
@@ -68,3 +68,4 @@ All flags are optional, but some are required in conjunction with certain others
|
||||
|`--show-config`|false|Show info about the appium server configuration and exit||
|
||||
|`--command-timeout`|60|The default command timeout for the server to use for all sessions. Will still be overridden by newCommandTimeout cap||
|
||||
|`--keep-keychains`|false|(iOS) Whether to keep keychains (Library/Keychains) when reset app between sessions||
|
||||
|`--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||
|
||||
|
||||
@@ -14,7 +14,6 @@ var spawn = require('win-spawn')
|
||||
, unzipFile = helpers.unzipFile
|
||||
, testZipArchive = helpers.testZipArchive
|
||||
, AdmZip = require('adm-zip')
|
||||
, getTempPath = helpers.getTempPath
|
||||
, rimraf = require('rimraf')
|
||||
, Logcat = require('./logcat.js')
|
||||
, isWindows = helpers.isWindows()
|
||||
@@ -39,6 +38,7 @@ var ADB = function (opts) {
|
||||
this.keyAlias = opts.keyAlias;
|
||||
this.keyPassword = opts.keyPassword;
|
||||
this.adb = "adb";
|
||||
this.tmpDir = opts.tmpDir;
|
||||
this.adbCmd = this.adb;
|
||||
this.curDeviceId = null;
|
||||
this.emulatorPort = null;
|
||||
@@ -573,7 +573,7 @@ ADB.prototype.checkApkKeystoreMatch = function (keytool, md5re, keystoreHash,
|
||||
continue;
|
||||
}
|
||||
logger.debug("Entry: " + entry);
|
||||
var entryPath = path.join(getTempPath(), pkg, 'cert');
|
||||
var entryPath = path.join(this.tmpDir, pkg, 'cert');
|
||||
logger.debug("entryPath: " + entryPath);
|
||||
var entryFile = path.join(entryPath, entry);
|
||||
logger.debug("entryFile: " + entryFile);
|
||||
|
||||
@@ -6,8 +6,6 @@ var logger = require('../../server/logger.js').get('appium')
|
||||
, fs = require('fs')
|
||||
, path = require('path')
|
||||
, exec = require('child_process').exec
|
||||
, helpers = require('../../helpers.js')
|
||||
, getTempPath = helpers.getTempPath
|
||||
, helperJarPath = path.resolve(__dirname, 'helpers')
|
||||
, md5 = require('md5calculator')
|
||||
, async = require('async')
|
||||
@@ -717,7 +715,7 @@ androidCommon.extractStringsFromApk = function (makeStrings, language, cb) {
|
||||
};
|
||||
|
||||
androidCommon.extractStrings = function (cb, language) {
|
||||
var outputPath = path.resolve(getTempPath(), this.args.appPackage);
|
||||
var outputPath = path.resolve(this.args.tmpDir, this.args.appPackage);
|
||||
var stringsJson = 'strings.json';
|
||||
if (!fs.existsSync(this.args.app)) {
|
||||
logger.debug("Apk doesn't exist locally");
|
||||
|
||||
@@ -5,8 +5,6 @@ var errors = require('../../server/errors.js')
|
||||
, fs = require('fs')
|
||||
, ADB = require('./adb.js')
|
||||
, Device = require('../device.js')
|
||||
, helpers = require('../../helpers.js')
|
||||
, getTempPath = helpers.getTempPath
|
||||
, _ = require('underscore')
|
||||
, logger = require('../../server/logger.js').get('appium')
|
||||
, deviceCommon = require('../common.js')
|
||||
@@ -284,7 +282,7 @@ Android.prototype.processFromManifest = function (cb) {
|
||||
};
|
||||
|
||||
Android.prototype.pushStrings = function (cb, language) {
|
||||
var outputPath = path.resolve(getTempPath(), this.args.appPackage);
|
||||
var outputPath = path.resolve(this.args.tmpDir, this.args.appPackage);
|
||||
var remotePath = '/data/local/tmp';
|
||||
var stringsJson = 'strings.json';
|
||||
this.extractStrings(function (err) {
|
||||
|
||||
@@ -11,8 +11,6 @@ var ADB = require('./adb.js')
|
||||
, status = require("../../server/status.js")
|
||||
, fs = require('fs')
|
||||
, async = require('async')
|
||||
, helpers = require('../../helpers.js')
|
||||
, getTempPath = helpers.getTempPath
|
||||
, androidCommon = require('./android-common.js')
|
||||
, path = require('path');
|
||||
|
||||
@@ -78,7 +76,7 @@ Selendroid.prototype.start = function (cb) {
|
||||
, modAppPkg = null;
|
||||
|
||||
var checkModServerExists = function (cb) {
|
||||
this.selendroidServerPath = path.resolve(getTempPath(),
|
||||
this.selendroidServerPath = path.resolve(this.args.tmpDir,
|
||||
'selendroid.' + this.args.appPackage + '.apk');
|
||||
modAppPkg = this.args.appPackage + '.selendroid';
|
||||
fs.stat(this.selendroidServerPath, function (err) {
|
||||
@@ -332,7 +330,7 @@ Selendroid.prototype.insertSelendroidManifest = function (serverPath, cb) {
|
||||
, newPackage = this.args.appPackage + '.selendroid'
|
||||
, srcManifest = path.resolve(__dirname, '..', '..', '..', 'build',
|
||||
'selendroid', 'AndroidManifest.xml')
|
||||
, dstDir = path.resolve(getTempPath(), this.args.appPackage)
|
||||
, dstDir = path.resolve(this.args.tmpDir, this.args.appPackage)
|
||||
, dstManifest = path.resolve(dstDir, 'AndroidManifest.xml');
|
||||
|
||||
try {
|
||||
|
||||
@@ -28,6 +28,9 @@ Device.prototype.configure = function (args, caps) {
|
||||
_.each(caps, function (val, cap) {
|
||||
this.setArgFromCap(cap, cap);
|
||||
}.bind(this));
|
||||
if (this.args.tmpDir === null) {
|
||||
this.args.tmpDir = helpers.isWindows() ? "C:\\Windows\\Temp" : "/tmp";
|
||||
}
|
||||
};
|
||||
|
||||
Device.prototype.setArgFromCap = function (arg, cap) {
|
||||
|
||||
@@ -171,7 +171,7 @@ IOS.prototype.configurePreferences = function (cb) {
|
||||
|
||||
var sdkNext = function (prefsVer) {
|
||||
logger.info("Trying to use settings app, version " + prefsVer);
|
||||
checkPreferencesApp(prefsVer, function (err, attemptedApp, origApp) {
|
||||
checkPreferencesApp(prefsVer, this.args.tmpDir, function (err, attemptedApp, origApp) {
|
||||
if (err) {
|
||||
logger.error("Could not prepare settings app with version '" +
|
||||
prefsVer + "': " + err);
|
||||
|
||||
@@ -54,7 +54,7 @@ Safari.prototype.configureSafari = function (cb) {
|
||||
}.bind(this));
|
||||
}.bind(this);
|
||||
var sdkNext = function (safariVer) {
|
||||
checkSafari(safariVer, function (err, attemptedApp, origApp) {
|
||||
checkSafari(safariVer, this.args.tmpDir, function (err, attemptedApp, origApp) {
|
||||
if (err) {
|
||||
logger.error("Could not prepare mobile safari with version '" +
|
||||
safariVer + "': " + err);
|
||||
@@ -62,7 +62,7 @@ Safari.prototype.configureSafari = function (cb) {
|
||||
}
|
||||
checkNext(attemptedApp, origApp, safariVer);
|
||||
});
|
||||
};
|
||||
}.bind(this);
|
||||
|
||||
if (safariVer === null) {
|
||||
getiOSSDKVersion(function (err, safariVer) {
|
||||
|
||||
+6
-16
@@ -141,10 +141,9 @@ exports.unzipApp = function (zipPath, appExt, cb) {
|
||||
});
|
||||
};
|
||||
|
||||
exports.checkBuiltInApp = function (appName, version, cb) {
|
||||
exports.checkBuiltInApp = function (appName, version, tmpDir, cb) {
|
||||
logger.info("Looking for built in app " + appName);
|
||||
var newAppDir = path.resolve(exports.getAppsBackupPath(),
|
||||
'Appium-' + appName + '.app');
|
||||
var newAppDir = path.resolve(tmpDir, 'Appium-' + appName + '.app');
|
||||
var checkApp = function (s, appPath, cb) {
|
||||
if (!s.isDirectory()) {
|
||||
cb(new Error("App package was not a directory"), appPath);
|
||||
@@ -191,12 +190,12 @@ exports.checkBuiltInApp = function (appName, version, cb) {
|
||||
});
|
||||
};
|
||||
|
||||
exports.checkSafari = function (version, cb) {
|
||||
exports.checkBuiltInApp("MobileSafari", version, cb);
|
||||
exports.checkSafari = function (version, tmpDir, cb) {
|
||||
exports.checkBuiltInApp("MobileSafari", version, tmpDir, cb);
|
||||
};
|
||||
|
||||
exports.checkPreferencesApp = function (version, cb) {
|
||||
exports.checkBuiltInApp("Preferences", version, cb);
|
||||
exports.checkPreferencesApp = function (version, tmpDir, cb) {
|
||||
exports.checkBuiltInApp("Preferences", version, tmpDir, cb);
|
||||
};
|
||||
|
||||
exports.getBuiltInAppDir = function (version, cb) {
|
||||
@@ -469,15 +468,6 @@ exports.macVersionArray = function (cb) {
|
||||
}
|
||||
};
|
||||
|
||||
exports.getTempPath = function () {
|
||||
return exports.isWindows() ? "C:\\Windows\\Temp" : "/tmp";
|
||||
};
|
||||
|
||||
exports.getAppsBackupPath = function () {
|
||||
if (process.env.APPIUM_APP_BACKUP_DIR) return process.env.APPIUM_APP_BACKUP_DIR;
|
||||
return exports.getTempPath();
|
||||
};
|
||||
|
||||
exports.getGitRev = function (cb) {
|
||||
var cwd = path.resolve(__dirname, "..");
|
||||
exec("git rev-parse HEAD", {cwd: cwd, maxBuffer: 524288}, function (err, stdout) {
|
||||
|
||||
@@ -16,6 +16,7 @@ var helpers = require('../helpers.js')
|
||||
, async = require('async')
|
||||
, through = require('through')
|
||||
, io = require('socket.io')
|
||||
, mkdirp = require('mkdirp')
|
||||
, bytes = require('bytes');
|
||||
|
||||
var watchForUnresponsiveInstruments = function (cb) {
|
||||
@@ -171,6 +172,17 @@ module.exports.conditionallyPreLaunch = function (args, appiumServer, cb) {
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.prepareTmpDir = function (args, cb) {
|
||||
if (args.tmpDir === null) return cb();
|
||||
mkdirp(args.tmpDir, function (err) {
|
||||
if (err) {
|
||||
logger.error("Could not ensure tmp dir '" + args.tmpDir + "' exists");
|
||||
logger.error(err);
|
||||
}
|
||||
cb(err);
|
||||
});
|
||||
};
|
||||
|
||||
var startAlertSocket = function (restServer, appiumServer) {
|
||||
var alerts = io.listen(restServer, {
|
||||
'flash policy port': -1,
|
||||
|
||||
@@ -57,6 +57,7 @@ var http = require('http')
|
||||
, configureServer = helpers.configureServer
|
||||
, startListening = helpers.startListening
|
||||
, conditionallyPreLaunch = helpers.conditionallyPreLaunch
|
||||
, prepareTmpDir = helpers.prepareTmpDir
|
||||
, noColorLogger = helpers.noColorLogger;
|
||||
|
||||
var main = function (args, readyCb, doneCb) {
|
||||
@@ -115,6 +116,9 @@ var main = function (args, readyCb, doneCb) {
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function (cb) {
|
||||
prepareTmpDir(args, cb);
|
||||
},
|
||||
function (cb) {
|
||||
conditionallyPreLaunch(args, appiumServer, cb);
|
||||
},
|
||||
|
||||
@@ -478,7 +478,17 @@ var args = [
|
||||
, required: false
|
||||
, help: "(iOS) Whether to keep keychains (Library/Keychains) when reset app between sessions"
|
||||
, nargs: 0
|
||||
}],
|
||||
|
||||
[['--tmp'], {
|
||||
defaultValue: null
|
||||
, dest: 'tmpDir'
|
||||
, required: false
|
||||
, help: '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'
|
||||
}]
|
||||
|
||||
];
|
||||
|
||||
// Setup all the command line argument parsing
|
||||
|
||||
Reference in New Issue
Block a user