Skip to content

Commit 8130d8f

Browse files
add option for derivedDataPath
1 parent b5626dd commit 8130d8f

File tree

8 files changed

+27
-9
lines changed

8 files changed

+27
-9
lines changed

lib/appium-driver.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ import {
3030
encodeImageToBase64,
3131
ensureReportsDirExists,
3232
checkImageLogType,
33-
adbShellCommand
33+
adbShellCommand,
34+
logWarn
3435
} from "./utils";
3536

3637
import { INsCapabilities } from "./interfaces/ns-capabilities";
@@ -280,6 +281,8 @@ export class AppiumDriver {
280281
}
281282
} catch (error) {
282283
args.verbose = true;
284+
console.log("===============================");
285+
console.log("", error)
283286
if (!args.ignoreDeviceController && error && error.message && error.message.includes("Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]")) {
284287
await DeviceManager.kill(args.device);
285288
await DeviceController.startDevice(args.device);
@@ -303,11 +306,11 @@ export class AppiumDriver {
303306
console.log("Retry launching appium driver!");
304307
hasStarted = false;
305308

306-
if (error && error.message && error.message.includes("WebDriverAgent")) {
307-
const freePort = await findFreePort(100, args.wdaLocalPort);
308-
console.log("args.appiumCaps['wdaLocalPort']", freePort);
309-
args.appiumCaps["wdaLocalPort"] = freePort;
310-
}
309+
// if (error && error.message && error.message.includes("WebDriverAgent")) {
310+
// const freePort = await findFreePort(100, args.wdaLocalPort);
311+
// console.log("args.appiumCaps['wdaLocalPort']", freePort);
312+
// args.appiumCaps["wdaLocalPort"] = freePort;
313+
// }
311314
}
312315

313316
if (hasStarted) {
@@ -883,7 +886,7 @@ export class AppiumDriver {
883886
}
884887
}
885888

886-
private static async applyAdditionalSettings(args) {
889+
private static async applyAdditionalSettings(args: INsCapabilities) {
887890
if (args.isSauceLab) return;
888891

889892
args.appiumCaps['udid'] = args.appiumCaps['udid'] || args.device.token;
@@ -900,6 +903,11 @@ export class AppiumDriver {
900903
args.appiumCaps["wdaStartupRetries"] = 5;
901904
args.appiumCaps["shouldUseSingletonTestManager"] = args.appiumCaps.shouldUseSingletonTestManager;
902905

906+
if (args.derivedDataPath) {
907+
args.appiumCaps["derivedDataPath"] = `${args.derivedDataPath}/${args.device.token}`;
908+
logWarn('Changed derivedDataPath to: ', args.appiumCaps["derivedDataPath"]);
909+
}
910+
903911
// It looks we need it for XCTest (iOS 10+ automation)
904912
if (args.appiumCaps.platformVersion >= 10 && args.wdaLocalPort) {
905913
console.log(`args.appiumCaps['wdaLocalPort']: ${args.wdaLocalPort}`);

lib/device-manager.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export declare class DeviceManager implements IDeviceManager {
1313
static getInstalledApps(device: IDevice): Promise<string[]>;
1414
static getDefaultDevice(args: INsCapabilities, deviceName?: string, token?: string, type?: DeviceType, platformVersion?: number): IDevice;
1515
private static convertViewportRectToIRectangle;
16-
static applyAppiumSessionInfoDetails(args: INsCapabilities, sessionInfoDetails: any): IDevice;
16+
static applyAppiumSessionInfoDetails(args: INsCapabilities, sessionInfoDetails: any): any;
1717
static setDontKeepActivities(args: INsCapabilities, driver: any, value: any): Promise<void>;
1818
static executeShellCommand(driver: any, commandArgs: {
1919
command: string;

lib/interfaces/ns-capabilities-args.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { AutomationName } from "../automation-name";
44
import { ITestReporter } from "./test-reporter";
55
import { LogImageType } from "../enums/log-image-type";
66
export interface INsCapabilitiesArgs {
7+
derivedDataPath?: string;
78
port?: number;
89
wdaLocalPort?: number;
910
projectDir?: string;

lib/interfaces/ns-capabilities-args.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ITestReporter } from "./test-reporter";
55
import { LogImageType } from "../enums/log-image-type";
66

77
export interface INsCapabilitiesArgs {
8+
derivedDataPath?: string;
89
port?: number;
910
wdaLocalPort?: number;
1011
projectDir?: string;

lib/ns-capabilities.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export declare class NsCapabilities implements INsCapabilities {
4747
deviceTypeOrPlatform: string;
4848
driverConfig: any;
4949
logImageTypes: Array<LogImageType>;
50+
derivedDataPath: string;
5051
constructor(_parser: INsCapabilitiesArgs);
5152
readonly isAndroid: any;
5253
readonly isIOS: boolean;

lib/ns-capabilities.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export class NsCapabilities implements INsCapabilities {
5353
public deviceTypeOrPlatform: string;
5454
public driverConfig: any;
5555
public logImageTypes: Array<LogImageType>;
56+
public derivedDataPath: string;
5657

5758
constructor(private _parser: INsCapabilitiesArgs) {
5859
this.projectDir = this._parser.projectDir;
@@ -76,6 +77,7 @@ export class NsCapabilities implements INsCapabilities {
7677
this.isSauceLab = this._parser.isSauceLab;
7778
this.ignoreDeviceController = this._parser.ignoreDeviceController;
7879
this.wdaLocalPort = this._parser.wdaLocalPort;
80+
this.derivedDataPath = this._parser.derivedDataPath;
7981
this.path = this._parser.path;
8082
this.capabilitiesName = this._parser.capabilitiesName;
8183
this.imagesPath = this._parser.imagesPath;

lib/parser.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import { LogImageType } from "./enums/log-image-type";
2-
export declare const projectDir: string, projectBinary: string, pluginRoot: string, pluginBinary: string, port: number, verbose: boolean, appiumCapsLocation: string, testFolder: string, runType: string, isSauceLab: boolean, appPath: string, storage: string, testReports: string, devMode: boolean, ignoreDeviceController: boolean, wdaLocalPort: number, path: string, relaxedSecurity: boolean, cleanApp: boolean, attachToDebug: boolean, sessionId: string, startSession: boolean, capabilitiesName: string, imagesPath: string, startDeviceOptions: string, deviceTypeOrPlatform: string, device: import("mobile-devices-controller/lib/device").IDevice, driverConfig: any, logImageTypes: LogImageType[], appiumCaps: any;
2+
export declare const projectDir: string, projectBinary: string, pluginRoot: string, pluginBinary: string, port: number, verbose: boolean, appiumCapsLocation: string, testFolder: string, runType: string, isSauceLab: boolean, appPath: string, storage: string, testReports: string, devMode: boolean, ignoreDeviceController: boolean, wdaLocalPort: number, derivedDataPath: string, path: string, relaxedSecurity: boolean, cleanApp: boolean, attachToDebug: boolean, sessionId: string, startSession: boolean, capabilitiesName: string, imagesPath: string, startDeviceOptions: string, deviceTypeOrPlatform: string, device: any, driverConfig: any, logImageTypes: LogImageType[], appiumCaps: any;

lib/parser.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ const config = (() => {
6464
type: "string"
6565
})
6666
.option("wdaLocalPort", { alias: "wda", describe: "WDA port", type: "number" })
67+
.options("derivedDataPath", {
68+
describe: "set the unique derived data path root for each driver instance. This will help to avoid possible conflicts and to speed up the parallel execution",
69+
type: "string" })
6770
.option("verbose", { alias: "v", describe: "Log actions", type: "boolean" })
6871
.option("path", { describe: "Execution path", default: process.cwd(), type: "string" })
6972
.option("relaxedSecurity", { describe: "appium relaxedSecurity", default: false, type: "boolean" })
@@ -160,6 +163,7 @@ const config = (() => {
160163
pluginRoot: pluginRoot,
161164
pluginBinary: pluginBinary,
162165
wdaLocalPort: options.wdaLocalPort || process.env.npm_config_wdaLocalPort || process.env["WDA_LOCAL_PORT"] || 8410,
166+
derivedDataPath: options.derivedDataPath || process.env.npm_config_derivedDataPath || process.env["DERIVED_DATA_PATH"],
163167
testFolder: options.testFolder || process.env.npm_config_testFolder || "e2e",
164168
runType: options.runType || process.env.npm_config_runType,
165169
appiumCapsLocation: options.appiumCapsLocation || process.env.npm_config_appiumCapsLocation || join(projectDir, options.testFolder, "config", options.capabilitiesName),
@@ -208,6 +212,7 @@ export const {
208212
devMode,
209213
ignoreDeviceController,
210214
wdaLocalPort,
215+
derivedDataPath,
211216
path,
212217
relaxedSecurity,
213218
cleanApp,

0 commit comments

Comments
 (0)