appium-xcuitest-driver 7.21.1 → 7.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/build/lib/commands/context.d.ts.map +1 -1
- package/build/lib/commands/context.js +4 -1
- package/build/lib/commands/context.js.map +1 -1
- package/build/lib/commands/log.d.ts.map +1 -1
- package/build/lib/commands/log.js +3 -2
- package/build/lib/commands/log.js.map +1 -1
- package/build/lib/device-log/ios-device-log.d.ts +16 -10
- package/build/lib/device-log/ios-device-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-device-log.js +9 -24
- package/build/lib/device-log/ios-device-log.js.map +1 -1
- package/build/lib/device-log/ios-log.d.ts +23 -44
- package/build/lib/device-log/ios-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-log.js +6 -52
- package/build/lib/device-log/ios-log.js.map +1 -1
- package/build/lib/device-log/ios-performance-log.d.ts +18 -26
- package/build/lib/device-log/ios-performance-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-performance-log.js +9 -28
- package/build/lib/device-log/ios-performance-log.js.map +1 -1
- package/build/lib/device-log/ios-simulator-log.d.ts +21 -24
- package/build/lib/device-log/ios-simulator-log.d.ts.map +1 -1
- package/build/lib/device-log/ios-simulator-log.js +14 -30
- package/build/lib/device-log/ios-simulator-log.js.map +1 -1
- package/build/lib/device-log/line-consuming-log.d.ts +9 -0
- package/build/lib/device-log/line-consuming-log.d.ts.map +1 -0
- package/build/lib/device-log/line-consuming-log.js +16 -0
- package/build/lib/device-log/line-consuming-log.js.map +1 -0
- package/lib/commands/context.js +4 -1
- package/lib/commands/log.js +3 -2
- package/lib/device-log/ios-device-log.ts +52 -0
- package/lib/device-log/ios-log.ts +87 -0
- package/lib/device-log/ios-performance-log.ts +61 -0
- package/lib/device-log/{ios-simulator-log.js → ios-simulator-log.ts} +36 -37
- package/lib/device-log/line-consuming-log.ts +16 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/lib/device-log/ios-device-log.js +0 -56
- package/lib/device-log/ios-log.js +0 -116
- package/lib/device-log/ios-performance-log.js +0 -68
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
killLogSubProcess(): Promise<void>;
|
|
23
|
-
finishStartingLogCapture(): Promise<void>;
|
|
1
|
+
import { LineConsumingLog } from './line-consuming-log';
|
|
2
|
+
import type { Simulator } from 'appium-ios-simulator';
|
|
3
|
+
import type { AppiumLogger } from '@appium/types';
|
|
4
|
+
export interface IOSSimulatorLogOptions {
|
|
5
|
+
sim: Simulator;
|
|
6
|
+
showLogs?: boolean;
|
|
7
|
+
iosSimulatorLogsPredicate?: string;
|
|
8
|
+
log?: AppiumLogger;
|
|
9
|
+
}
|
|
10
|
+
export declare class IOSSimulatorLog extends LineConsumingLog {
|
|
11
|
+
private sim;
|
|
12
|
+
private showLogs;
|
|
13
|
+
private predicate?;
|
|
14
|
+
private proc;
|
|
15
|
+
constructor(opts: IOSSimulatorLogOptions);
|
|
16
|
+
startCapture(): Promise<void>;
|
|
17
|
+
stopCapture(): Promise<void>;
|
|
18
|
+
get isCapturing(): boolean;
|
|
19
|
+
private onOutput;
|
|
20
|
+
private killLogSubProcess;
|
|
21
|
+
private finishStartingLogCapture;
|
|
24
22
|
}
|
|
25
23
|
export default IOSSimulatorLog;
|
|
26
|
-
import { IOSLog } from './ios-log';
|
|
27
24
|
//# sourceMappingURL=ios-simulator-log.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios-simulator-log.d.ts","sourceRoot":"","sources":["../../../lib/device-log/ios-simulator-log.
|
|
1
|
+
{"version":3,"file":"ios-simulator-log.d.ts","sourceRoot":"","sources":["../../../lib/device-log/ios-simulator-log.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAMlD,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,SAAS,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAED,qBAAa,eAAgB,SAAQ,gBAAgB;IACnD,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,IAAI,CAAoB;gBAEpB,IAAI,EAAE,sBAAsB;IAQzB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IA2B7B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3C,IAAa,WAAW,IAAI,OAAO,CAElC;IAED,OAAO,CAAC,QAAQ;YAQF,iBAAiB;YAiBjB,wBAAwB;CAqBvC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -5,24 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.IOSSimulatorLog = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const ios_log_1 = require("./ios-log");
|
|
9
|
-
const support_1 = require("appium/support");
|
|
10
8
|
const teen_process_1 = require("teen_process");
|
|
11
|
-
const
|
|
9
|
+
const line_consuming_log_1 = require("./line-consuming-log");
|
|
12
10
|
const EXECVP_ERROR_PATTERN = /execvp\(\)/;
|
|
13
11
|
const START_TIMEOUT = 10000;
|
|
14
|
-
class IOSSimulatorLog extends
|
|
15
|
-
constructor(
|
|
16
|
-
super();
|
|
17
|
-
this.sim = sim;
|
|
18
|
-
this.showLogs = !!showLogs;
|
|
19
|
-
this.
|
|
20
|
-
this.predicate = iosSimulatorLogsPredicate;
|
|
12
|
+
class IOSSimulatorLog extends line_consuming_log_1.LineConsumingLog {
|
|
13
|
+
constructor(opts) {
|
|
14
|
+
super({ log: opts.log });
|
|
15
|
+
this.sim = opts.sim;
|
|
16
|
+
this.showLogs = !!opts.showLogs;
|
|
17
|
+
this.predicate = opts.iosSimulatorLogsPredicate;
|
|
21
18
|
this.proc = null;
|
|
22
19
|
}
|
|
23
|
-
/**
|
|
24
|
-
* @override
|
|
25
|
-
*/
|
|
26
20
|
async startCapture() {
|
|
27
21
|
if (lodash_1.default.isUndefined(this.sim.udid)) {
|
|
28
22
|
throw new Error(`Log capture requires a sim udid`);
|
|
@@ -34,7 +28,7 @@ class IOSSimulatorLog extends ios_log_1.IOSLog {
|
|
|
34
28
|
if (this.predicate) {
|
|
35
29
|
spawnArgs.push('--predicate', this.predicate);
|
|
36
30
|
}
|
|
37
|
-
log.debug(`Starting log capture for iOS Simulator with udid '${this.sim.udid}' ` + `using simctl`);
|
|
31
|
+
this.log.debug(`Starting log capture for iOS Simulator with udid '${this.sim.udid}' ` + `using simctl`);
|
|
38
32
|
try {
|
|
39
33
|
// cleanup existing listeners if the previous session has not been terminated properly
|
|
40
34
|
await (0, teen_process_1.exec)('pkill', ['-f', [this.sim.udid, ...spawnArgs].join(' ')]);
|
|
@@ -48,9 +42,6 @@ class IOSSimulatorLog extends ios_log_1.IOSLog {
|
|
|
48
42
|
throw new Error(`Simulator log capture failed. Original error: ${e.message}`);
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
|
-
/**
|
|
52
|
-
* @override
|
|
53
|
-
*/
|
|
54
45
|
async stopCapture() {
|
|
55
46
|
if (!this.proc) {
|
|
56
47
|
return;
|
|
@@ -58,28 +49,21 @@ class IOSSimulatorLog extends ios_log_1.IOSLog {
|
|
|
58
49
|
await this.killLogSubProcess();
|
|
59
50
|
this.proc = null;
|
|
60
51
|
}
|
|
61
|
-
/**
|
|
62
|
-
* @override
|
|
63
|
-
*/
|
|
64
52
|
get isCapturing() {
|
|
65
|
-
return this.proc && this.proc.isRunning;
|
|
53
|
+
return Boolean(this.proc && this.proc.isRunning);
|
|
66
54
|
}
|
|
67
|
-
/**
|
|
68
|
-
* @param {string} logRow
|
|
69
|
-
* @param {string} [prefix='']
|
|
70
|
-
*/
|
|
71
55
|
onOutput(logRow, prefix = '') {
|
|
72
56
|
this.broadcast(logRow);
|
|
73
57
|
if (this.showLogs) {
|
|
74
58
|
const space = prefix.length > 0 ? ' ' : '';
|
|
75
|
-
log.info(`[IOS_SYSLOG_ROW${space}${prefix}] ${logRow}`);
|
|
59
|
+
this.log.info(`[IOS_SYSLOG_ROW${space}${prefix}] ${logRow}`);
|
|
76
60
|
}
|
|
77
61
|
}
|
|
78
62
|
async killLogSubProcess() {
|
|
79
|
-
if (!this.proc
|
|
63
|
+
if (!this.proc?.isRunning) {
|
|
80
64
|
return;
|
|
81
65
|
}
|
|
82
|
-
log.debug('Stopping iOS log capture');
|
|
66
|
+
this.log.debug('Stopping iOS log capture');
|
|
83
67
|
try {
|
|
84
68
|
await this.proc.stop('SIGTERM', 1000);
|
|
85
69
|
}
|
|
@@ -87,13 +71,13 @@ class IOSSimulatorLog extends ios_log_1.IOSLog {
|
|
|
87
71
|
if (!this.proc.isRunning) {
|
|
88
72
|
return;
|
|
89
73
|
}
|
|
90
|
-
log.warn('Cannot stop log capture process. Sending SIGKILL');
|
|
74
|
+
this.log.warn('Cannot stop log capture process. Sending SIGKILL');
|
|
91
75
|
await this.proc.stop('SIGKILL');
|
|
92
76
|
}
|
|
93
77
|
}
|
|
94
78
|
async finishStartingLogCapture() {
|
|
95
79
|
if (!this.proc) {
|
|
96
|
-
log.
|
|
80
|
+
throw this.log.errorWithException('Could not capture simulator log');
|
|
97
81
|
}
|
|
98
82
|
for (const streamName of ['stdout', 'stderr']) {
|
|
99
83
|
this.proc.on(`lines-${streamName}`, (/** @type {string[]} */ lines) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ios-simulator-log.js","sourceRoot":"","sources":["../../../lib/device-log/ios-simulator-log.
|
|
1
|
+
{"version":3,"file":"ios-simulator-log.js","sourceRoot":"","sources":["../../../lib/device-log/ios-simulator-log.ts"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,+CAA8C;AAC9C,6DAAwD;AAIxD,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAE1C,MAAM,aAAa,GAAG,KAAK,CAAC;AAS5B,MAAa,eAAgB,SAAQ,qCAAgB;IAMnD,YAAY,IAA4B;QACtC,KAAK,CAAC,EAAC,GAAG,EAAE,IAAI,CAAC,GAAG,EAAC,CAAC,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,yBAAyB,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEQ,KAAK,CAAC,YAAY;QACzB,IAAI,gBAAC,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,GAAG,CAAC,IAAI,kBAAkB,CAAC,CAAC;QAC/E,CAAC;QACD,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,QAAQ,E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,CAAC,IAAI,EAAE,GAAG,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACtE,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,MAAM,aAAa,GAAG,CAAC,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,CAAC,MAAM,EAAE,EAAE;YACnF,IAAI,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBACtC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;YAC7D,CAAC;YACD,OAAO,MAAM,IAAI,MAAM,CAAC;QAC1B,CAAC,CAAC;QACF,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IACtD,CAAC;CACF;AAnGD,0CAmGC;AAED,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IOSLog } from './ios-log';
|
|
2
|
+
import type { LogEntry } from '../commands/types';
|
|
3
|
+
type TSerializedEntry = [string, number];
|
|
4
|
+
export declare abstract class LineConsumingLog extends IOSLog<string, TSerializedEntry> {
|
|
5
|
+
protected _serializeEntry(value: string): TSerializedEntry;
|
|
6
|
+
protected _deserializeEntry(value: TSerializedEntry): LogEntry;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=line-consuming-log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-consuming-log.d.ts","sourceRoot":"","sources":["../../../lib/device-log/line-consuming-log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAEjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,KAAK,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEzC,8BAAsB,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;cAC1D,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB;cAIhD,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,QAAQ;CAIxE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LineConsumingLog = void 0;
|
|
4
|
+
const ios_log_1 = require("./ios-log");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
class LineConsumingLog extends ios_log_1.IOSLog {
|
|
7
|
+
_serializeEntry(value) {
|
|
8
|
+
return [value, Date.now()];
|
|
9
|
+
}
|
|
10
|
+
_deserializeEntry(value) {
|
|
11
|
+
const [message, timestamp] = value;
|
|
12
|
+
return (0, helpers_1.toLogEntry)(message, timestamp);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.LineConsumingLog = LineConsumingLog;
|
|
16
|
+
//# sourceMappingURL=line-consuming-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-consuming-log.js","sourceRoot":"","sources":["../../../lib/device-log/line-consuming-log.ts"],"names":[],"mappings":";;;AAAA,uCAAiC;AACjC,uCAAuC;AAKvC,MAAsB,gBAAiB,SAAQ,gBAAgC;IAC1D,eAAe,CAAC,KAAa;QAC9C,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7B,CAAC;IAEkB,iBAAiB,CAAC,KAAuB;QAC1D,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;QACnC,OAAO,IAAA,oBAAU,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACxC,CAAC;CACF;AATD,4CASC"}
|
package/lib/commands/context.js
CHANGED
|
@@ -558,7 +558,10 @@ const commands = {
|
|
|
558
558
|
// attempt to start performance logging, if requested
|
|
559
559
|
if (this.opts.enablePerformanceLogging && this.remote) {
|
|
560
560
|
this.log.debug(`Starting performance log on '${this.curContext}'`);
|
|
561
|
-
this.logs.performance = new IOSPerformanceLog(
|
|
561
|
+
this.logs.performance = new IOSPerformanceLog({
|
|
562
|
+
remoteDebugger: this.remote,
|
|
563
|
+
log: this.log,
|
|
564
|
+
});
|
|
562
565
|
await this.logs.performance.startCapture();
|
|
563
566
|
}
|
|
564
567
|
|
package/lib/commands/log.js
CHANGED
|
@@ -103,13 +103,14 @@ export default {
|
|
|
103
103
|
this.logs.syslog = new IOSDeviceLog({
|
|
104
104
|
udid: this.opts.udid,
|
|
105
105
|
showLogs: this.opts.showIOSLog,
|
|
106
|
+
log: this.log,
|
|
106
107
|
});
|
|
107
108
|
} else {
|
|
108
109
|
this.logs.syslog = new IOSSimulatorLog({
|
|
109
|
-
sim: this.device,
|
|
110
|
+
sim: /** @type {import('appium-ios-simulator').Simulator} */ (this.device),
|
|
110
111
|
showLogs: this.opts.showIOSLog,
|
|
111
|
-
xcodeVersion: this.xcodeVersion,
|
|
112
112
|
iosSimulatorLogsPredicate: this.opts.iosSimulatorLogsPredicate,
|
|
113
|
+
log: this.log,
|
|
113
114
|
});
|
|
114
115
|
}
|
|
115
116
|
this.logs.safariConsole = new SafariConsoleLog(!!this.opts.showSafariConsoleLog);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {services} from 'appium-ios-device';
|
|
2
|
+
import { LineConsumingLog } from './line-consuming-log';
|
|
3
|
+
import type { AppiumLogger } from '@appium/types';
|
|
4
|
+
|
|
5
|
+
export interface IOSDeviceLogOpts {
|
|
6
|
+
udid: string;
|
|
7
|
+
showLogs?: boolean;
|
|
8
|
+
log?: AppiumLogger;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class IOSDeviceLog extends LineConsumingLog {
|
|
12
|
+
private udid: string;
|
|
13
|
+
private showLogs: boolean;
|
|
14
|
+
private service: any | null;
|
|
15
|
+
|
|
16
|
+
constructor(opts: IOSDeviceLogOpts) {
|
|
17
|
+
super({log: opts.log});
|
|
18
|
+
this.udid = opts.udid;
|
|
19
|
+
this.showLogs = !!opts.showLogs;
|
|
20
|
+
this.service = null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
override async startCapture(): Promise<void> {
|
|
24
|
+
if (this.service) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this.service = await services.startSyslogService(this.udid);
|
|
28
|
+
this.service.start(this.onLog.bind(this));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
override get isCapturing(): boolean {
|
|
32
|
+
return !!this.service;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line require-await
|
|
36
|
+
override async stopCapture(): Promise<void> {
|
|
37
|
+
if (!this.service) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.service.close();
|
|
41
|
+
this.service = null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private onLog(logLine: string): void {
|
|
45
|
+
this.broadcast(logLine);
|
|
46
|
+
if (this.showLogs) {
|
|
47
|
+
this.log.info(`[IOS_SYSLOG_ROW] ${logLine}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default IOSDeviceLog;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {EventEmitter} from 'events';
|
|
2
|
+
import { LRUCache } from 'lru-cache';
|
|
3
|
+
import type { LogEntry } from '../commands/types';
|
|
4
|
+
import type { AppiumLogger } from '@appium/types';
|
|
5
|
+
import {logger} from 'appium/support';
|
|
6
|
+
|
|
7
|
+
// We keep only the most recent log entries to avoid out of memory error
|
|
8
|
+
const MAX_LOG_ENTRIES_COUNT = 10000;
|
|
9
|
+
|
|
10
|
+
export interface IOSLogOptions {
|
|
11
|
+
maxBufferSize?: number;
|
|
12
|
+
log?: AppiumLogger;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export abstract class IOSLog<
|
|
16
|
+
TRawEntry,
|
|
17
|
+
TSerializedEntry extends object
|
|
18
|
+
> extends EventEmitter {
|
|
19
|
+
private maxBufferSize: number;
|
|
20
|
+
private logs: LRUCache<number, TSerializedEntry>;
|
|
21
|
+
private logIndexSinceLastRequest: number | null;
|
|
22
|
+
private _log: AppiumLogger;
|
|
23
|
+
|
|
24
|
+
constructor(opts: IOSLogOptions = {}) {
|
|
25
|
+
super();
|
|
26
|
+
this.maxBufferSize = opts.maxBufferSize ?? MAX_LOG_ENTRIES_COUNT;
|
|
27
|
+
this.logs = new LRUCache({
|
|
28
|
+
max: this.maxBufferSize,
|
|
29
|
+
});
|
|
30
|
+
this.logIndexSinceLastRequest = null;
|
|
31
|
+
this._log = opts.log ?? logger.getLogger(this.constructor.name);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
abstract startCapture(): Promise<void>;
|
|
35
|
+
abstract stopCapture(): Promise<void>;
|
|
36
|
+
abstract get isCapturing(): boolean;
|
|
37
|
+
|
|
38
|
+
get log(): AppiumLogger {
|
|
39
|
+
return this._log;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
broadcast(entry: TRawEntry): void {
|
|
43
|
+
let recentIndex = -1;
|
|
44
|
+
for (const key of this.logs.rkeys()) {
|
|
45
|
+
recentIndex = key;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
const serializedEntry = this._serializeEntry(entry);
|
|
49
|
+
this.logs.set(++recentIndex, serializedEntry);
|
|
50
|
+
if (this.listenerCount('output')) {
|
|
51
|
+
this.emit('output', this._deserializeEntry(serializedEntry));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getLogs(): LogEntry[] {
|
|
56
|
+
const result: LogEntry[] = [];
|
|
57
|
+
let recentLogIndex: number | null = null;
|
|
58
|
+
for (const [index, value] of this.logs.entries()) {
|
|
59
|
+
if (this.logIndexSinceLastRequest && index > this.logIndexSinceLastRequest
|
|
60
|
+
|| !this.logIndexSinceLastRequest) {
|
|
61
|
+
recentLogIndex = index;
|
|
62
|
+
result.push(this._deserializeEntry(value));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (recentLogIndex !== null) {
|
|
66
|
+
this.logIndexSinceLastRequest = recentLogIndex;
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
getAllLogs(): LogEntry[] {
|
|
72
|
+
const result: LogEntry[] = [];
|
|
73
|
+
for (const value of this.logs.values()) {
|
|
74
|
+
result.push(this._deserializeEntry(value));
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
protected abstract _serializeEntry(value: TRawEntry): TSerializedEntry;
|
|
80
|
+
protected abstract _deserializeEntry(value: TSerializedEntry): LogEntry;
|
|
81
|
+
|
|
82
|
+
protected _clearEntries() {
|
|
83
|
+
this.logs.clear();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default IOSLog;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { IOSLog } from './ios-log';
|
|
3
|
+
import type { LogEntry } from '../commands/types';
|
|
4
|
+
import type { AppiumLogger } from '@appium/types';
|
|
5
|
+
|
|
6
|
+
const MAX_EVENTS = 5000;
|
|
7
|
+
|
|
8
|
+
type PerformanceLogEntry = object;
|
|
9
|
+
export interface IOSPerformanceLogOptions {
|
|
10
|
+
remoteDebugger: any;
|
|
11
|
+
maxEvents?: number;
|
|
12
|
+
log?: AppiumLogger;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class IOSPerformanceLog extends IOSLog<PerformanceLogEntry, PerformanceLogEntry> {
|
|
16
|
+
private remoteDebugger: any;
|
|
17
|
+
private _started: boolean;
|
|
18
|
+
|
|
19
|
+
constructor(opts: IOSPerformanceLogOptions) {
|
|
20
|
+
super({
|
|
21
|
+
maxBufferSize: opts.maxEvents ?? MAX_EVENTS,
|
|
22
|
+
log: opts.log,
|
|
23
|
+
});
|
|
24
|
+
this.remoteDebugger = opts.remoteDebugger;
|
|
25
|
+
this._started = false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override async startCapture(): Promise<void> {
|
|
29
|
+
this.log.debug('Starting performance (Timeline) log capture');
|
|
30
|
+
this._clearEntries();
|
|
31
|
+
const result = await this.remoteDebugger.startTimeline(this.onTimelineEvent.bind(this));
|
|
32
|
+
this._started = true;
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override async stopCapture(): Promise<void> {
|
|
37
|
+
this.log.debug('Stopping performance (Timeline) log capture');
|
|
38
|
+
const result = await this.remoteDebugger.stopTimeline();
|
|
39
|
+
this._started = false;
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
override get isCapturing(): boolean {
|
|
44
|
+
return this._started;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected override _serializeEntry(value: PerformanceLogEntry): PerformanceLogEntry {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected override _deserializeEntry(value: PerformanceLogEntry): LogEntry {
|
|
52
|
+
return value as LogEntry;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private onTimelineEvent(event: PerformanceLogEntry): void {
|
|
56
|
+
this.log.debug(`Received Timeline event: ${_.truncate(JSON.stringify(event))}`);
|
|
57
|
+
this.broadcast(event);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default IOSPerformanceLog;
|
|
@@ -1,27 +1,35 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import {SubProcess, exec} from 'teen_process';
|
|
3
|
+
import { LineConsumingLog } from './line-consuming-log';
|
|
4
|
+
import type { Simulator } from 'appium-ios-simulator';
|
|
5
|
+
import type { AppiumLogger } from '@appium/types';
|
|
5
6
|
|
|
6
|
-
const log = logger.getLogger('IOSSimulatorLog');
|
|
7
7
|
const EXECVP_ERROR_PATTERN = /execvp\(\)/;
|
|
8
8
|
|
|
9
9
|
const START_TIMEOUT = 10000;
|
|
10
10
|
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export interface IOSSimulatorLogOptions {
|
|
12
|
+
sim: Simulator;
|
|
13
|
+
showLogs?: boolean;
|
|
14
|
+
iosSimulatorLogsPredicate?: string;
|
|
15
|
+
log?: AppiumLogger;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class IOSSimulatorLog extends LineConsumingLog {
|
|
19
|
+
private sim: Simulator;
|
|
20
|
+
private showLogs: boolean;
|
|
21
|
+
private predicate?: string;
|
|
22
|
+
private proc: SubProcess | null;
|
|
23
|
+
|
|
24
|
+
constructor(opts: IOSSimulatorLogOptions) {
|
|
25
|
+
super({log: opts.log});
|
|
26
|
+
this.sim = opts.sim;
|
|
27
|
+
this.showLogs = !!opts.showLogs;
|
|
28
|
+
this.predicate = opts.iosSimulatorLogsPredicate;
|
|
18
29
|
this.proc = null;
|
|
19
30
|
}
|
|
20
31
|
|
|
21
|
-
|
|
22
|
-
* @override
|
|
23
|
-
*/
|
|
24
|
-
async startCapture() {
|
|
32
|
+
override async startCapture(): Promise<void> {
|
|
25
33
|
if (_.isUndefined(this.sim.udid)) {
|
|
26
34
|
throw new Error(`Log capture requires a sim udid`);
|
|
27
35
|
}
|
|
@@ -33,7 +41,7 @@ export class IOSSimulatorLog extends IOSLog {
|
|
|
33
41
|
if (this.predicate) {
|
|
34
42
|
spawnArgs.push('--predicate', this.predicate);
|
|
35
43
|
}
|
|
36
|
-
log.debug(
|
|
44
|
+
this.log.debug(
|
|
37
45
|
`Starting log capture for iOS Simulator with udid '${this.sim.udid}' ` + `using simctl`,
|
|
38
46
|
);
|
|
39
47
|
try {
|
|
@@ -48,10 +56,7 @@ export class IOSSimulatorLog extends IOSLog {
|
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
|
|
51
|
-
|
|
52
|
-
* @override
|
|
53
|
-
*/
|
|
54
|
-
async stopCapture() {
|
|
59
|
+
override async stopCapture(): Promise<void> {
|
|
55
60
|
if (!this.proc) {
|
|
56
61
|
return;
|
|
57
62
|
}
|
|
@@ -59,44 +64,38 @@ export class IOSSimulatorLog extends IOSLog {
|
|
|
59
64
|
this.proc = null;
|
|
60
65
|
}
|
|
61
66
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*/
|
|
65
|
-
get isCapturing() {
|
|
66
|
-
return this.proc && this.proc.isRunning;
|
|
67
|
+
override get isCapturing(): boolean {
|
|
68
|
+
return Boolean(this.proc && this.proc.isRunning);
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
* @param {string} logRow
|
|
71
|
-
* @param {string} [prefix='']
|
|
72
|
-
*/
|
|
73
|
-
onOutput(logRow, prefix = '') {
|
|
71
|
+
private onOutput(logRow: string, prefix: string = ''): void {
|
|
74
72
|
this.broadcast(logRow);
|
|
75
73
|
if (this.showLogs) {
|
|
76
74
|
const space = prefix.length > 0 ? ' ' : '';
|
|
77
|
-
log.info(`[IOS_SYSLOG_ROW${space}${prefix}] ${logRow}`);
|
|
75
|
+
this.log.info(`[IOS_SYSLOG_ROW${space}${prefix}] ${logRow}`);
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
async killLogSubProcess() {
|
|
82
|
-
if (!this.proc
|
|
79
|
+
private async killLogSubProcess(): Promise<void> {
|
|
80
|
+
if (!this.proc?.isRunning) {
|
|
83
81
|
return;
|
|
84
82
|
}
|
|
85
|
-
|
|
83
|
+
|
|
84
|
+
this.log.debug('Stopping iOS log capture');
|
|
86
85
|
try {
|
|
87
86
|
await this.proc.stop('SIGTERM', 1000);
|
|
88
87
|
} catch (e) {
|
|
89
88
|
if (!this.proc.isRunning) {
|
|
90
89
|
return;
|
|
91
90
|
}
|
|
92
|
-
log.warn('Cannot stop log capture process. Sending SIGKILL');
|
|
91
|
+
this.log.warn('Cannot stop log capture process. Sending SIGKILL');
|
|
93
92
|
await this.proc.stop('SIGKILL');
|
|
94
93
|
}
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
async finishStartingLogCapture() {
|
|
96
|
+
private async finishStartingLogCapture() {
|
|
98
97
|
if (!this.proc) {
|
|
99
|
-
log.
|
|
98
|
+
throw this.log.errorWithException('Could not capture simulator log');
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
for (const streamName of ['stdout', 'stderr']) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {IOSLog} from './ios-log';
|
|
2
|
+
import { toLogEntry } from './helpers';
|
|
3
|
+
import type { LogEntry } from '../commands/types';
|
|
4
|
+
|
|
5
|
+
type TSerializedEntry = [string, number];
|
|
6
|
+
|
|
7
|
+
export abstract class LineConsumingLog extends IOSLog<string, TSerializedEntry> {
|
|
8
|
+
protected override _serializeEntry(value: string): TSerializedEntry {
|
|
9
|
+
return [value, Date.now()];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
protected override _deserializeEntry(value: TSerializedEntry): LogEntry {
|
|
13
|
+
const [message, timestamp] = value;
|
|
14
|
+
return toLogEntry(message, timestamp);
|
|
15
|
+
}
|
|
16
|
+
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium-xcuitest-driver",
|
|
3
|
-
"version": "7.21.
|
|
3
|
+
"version": "7.21.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "appium-xcuitest-driver",
|
|
9
|
-
"version": "7.21.
|
|
9
|
+
"version": "7.21.2",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@colors/colors": "^1.6.0",
|
package/package.json
CHANGED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {logger} from 'appium/support';
|
|
2
|
-
import {IOSLog} from './ios-log';
|
|
3
|
-
import {services} from 'appium-ios-device';
|
|
4
|
-
|
|
5
|
-
const log = logger.getLogger('IOSDeviceLog');
|
|
6
|
-
|
|
7
|
-
export class IOSDeviceLog extends IOSLog {
|
|
8
|
-
constructor(opts) {
|
|
9
|
-
super();
|
|
10
|
-
this.udid = opts.udid;
|
|
11
|
-
this.showLogs = !!opts.showLogs;
|
|
12
|
-
this.service = null;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* @override
|
|
16
|
-
*/
|
|
17
|
-
async startCapture() {
|
|
18
|
-
if (this.service) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
this.service = await services.startSyslogService(this.udid);
|
|
22
|
-
this.service.start(this.onLog.bind(this));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @param {string} logLine
|
|
27
|
-
*/
|
|
28
|
-
onLog(logLine) {
|
|
29
|
-
this.broadcast(logLine);
|
|
30
|
-
if (this.showLogs) {
|
|
31
|
-
log.info(logLine);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @override
|
|
37
|
-
*/
|
|
38
|
-
get isCapturing() {
|
|
39
|
-
return !!this.service;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @override
|
|
44
|
-
*/
|
|
45
|
-
// XXX: superclass is async, but this is not
|
|
46
|
-
// eslint-disable-next-line require-await
|
|
47
|
-
async stopCapture() {
|
|
48
|
-
if (!this.service) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
this.service.close();
|
|
52
|
-
this.service = null;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default IOSDeviceLog;
|