appium-xcuitest-driver 7.21.0 → 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.
Files changed (54) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/lib/commands/context.d.ts.map +1 -1
  3. package/build/lib/commands/context.js +4 -1
  4. package/build/lib/commands/context.js.map +1 -1
  5. package/build/lib/commands/log.d.ts +0 -8
  6. package/build/lib/commands/log.d.ts.map +1 -1
  7. package/build/lib/commands/log.js +7 -15
  8. package/build/lib/commands/log.js.map +1 -1
  9. package/build/lib/commands/types.d.ts +5 -0
  10. package/build/lib/commands/types.d.ts.map +1 -1
  11. package/build/lib/device-log/helpers.d.ts +3 -0
  12. package/build/lib/device-log/helpers.d.ts.map +1 -0
  13. package/build/lib/device-log/helpers.js +11 -0
  14. package/build/lib/device-log/helpers.js.map +1 -0
  15. package/build/lib/device-log/ios-crash-log.d.ts +6 -17
  16. package/build/lib/device-log/ios-crash-log.d.ts.map +1 -1
  17. package/build/lib/device-log/ios-crash-log.js +4 -10
  18. package/build/lib/device-log/ios-crash-log.js.map +1 -1
  19. package/build/lib/device-log/ios-device-log.d.ts +17 -8
  20. package/build/lib/device-log/ios-device-log.d.ts.map +1 -1
  21. package/build/lib/device-log/ios-device-log.js +9 -21
  22. package/build/lib/device-log/ios-device-log.js.map +1 -1
  23. package/build/lib/device-log/ios-log.d.ts +24 -16
  24. package/build/lib/device-log/ios-log.d.ts.map +1 -1
  25. package/build/lib/device-log/ios-log.js +40 -38
  26. package/build/lib/device-log/ios-log.js.map +1 -1
  27. package/build/lib/device-log/ios-performance-log.d.ts +19 -10
  28. package/build/lib/device-log/ios-performance-log.d.ts.map +1 -1
  29. package/build/lib/device-log/ios-performance-log.js +28 -30
  30. package/build/lib/device-log/ios-performance-log.js.map +1 -1
  31. package/build/lib/device-log/ios-simulator-log.d.ts +22 -18
  32. package/build/lib/device-log/ios-simulator-log.d.ts.map +1 -1
  33. package/build/lib/device-log/ios-simulator-log.js +39 -61
  34. package/build/lib/device-log/ios-simulator-log.js.map +1 -1
  35. package/build/lib/device-log/line-consuming-log.d.ts +9 -0
  36. package/build/lib/device-log/line-consuming-log.d.ts.map +1 -0
  37. package/build/lib/device-log/line-consuming-log.js +16 -0
  38. package/build/lib/device-log/line-consuming-log.js.map +1 -0
  39. package/lib/commands/context.js +4 -1
  40. package/lib/commands/log.js +9 -16
  41. package/lib/commands/types.ts +6 -0
  42. package/lib/device-log/helpers.ts +9 -0
  43. package/lib/device-log/ios-crash-log.js +4 -11
  44. package/lib/device-log/ios-device-log.ts +52 -0
  45. package/lib/device-log/ios-log.ts +87 -0
  46. package/lib/device-log/ios-performance-log.ts +61 -0
  47. package/lib/device-log/ios-simulator-log.ts +119 -0
  48. package/lib/device-log/line-consuming-log.ts +16 -0
  49. package/npm-shrinkwrap.json +52 -27
  50. package/package.json +2 -2
  51. package/lib/device-log/ios-device-log.js +0 -54
  52. package/lib/device-log/ios-log.js +0 -65
  53. package/lib/device-log/ios-performance-log.js +0 -57
  54. package/lib/device-log/ios-simulator-log.js +0 -124
@@ -1,57 +0,0 @@
1
- import {logger} from 'appium/support';
2
- import _ from 'lodash';
3
-
4
- const log = logger.getLogger('IOSPerformanceLog');
5
- const MAX_EVENTS = 5000;
6
-
7
- class IOSPerformanceLog {
8
- constructor(remoteDebugger, maxEvents = MAX_EVENTS) {
9
- this.remoteDebugger = remoteDebugger;
10
- this.maxEvents = parseInt(String(maxEvents), 10);
11
-
12
- this.timelineEvents = [];
13
- }
14
-
15
- async startCapture() {
16
- log.debug('Starting performance (Timeline) log capture');
17
- this.timelineEvents = [];
18
- return await this.remoteDebugger.startTimeline(this.onTimelineEvent.bind(this));
19
- }
20
-
21
- async stopCapture() {
22
- log.debug('Stopping performance (Timeline) log capture');
23
- return await this.remoteDebugger.stopTimeline();
24
- }
25
-
26
- onTimelineEvent(event) {
27
- log.debug(`Received Timeline event: ${_.truncate(JSON.stringify(event))}`);
28
- this.timelineEvents.push(event);
29
-
30
- // if we have too many, get rid of the oldest log line
31
- if (this.timelineEvents.length > this.maxEvents) {
32
- let removedEvent = this.timelineEvents.shift();
33
- log.warn(
34
- `Too many Timeline events, removing earliest: ${_.truncate(JSON.stringify(removedEvent))}`,
35
- );
36
- }
37
- }
38
-
39
- // eslint-disable-next-line require-await
40
- async getLogs() {
41
- let events = this.timelineEvents;
42
-
43
- // flush events
44
- log.debug('Flushing Timeline events');
45
- this.timelineEvents = [];
46
-
47
- return events;
48
- }
49
-
50
- // eslint-disable-next-line require-await
51
- async getAllLogs() {
52
- return this.getLogs();
53
- }
54
- }
55
-
56
- export {IOSPerformanceLog};
57
- export default IOSPerformanceLog;
@@ -1,124 +0,0 @@
1
- import _ from 'lodash';
2
- import {IOSLog} from './ios-log';
3
- import {logger} from 'appium/support';
4
- import {exec} from 'teen_process';
5
-
6
- const log = logger.getLogger('IOSSimulatorLog');
7
-
8
- const START_TIMEOUT = 10000;
9
-
10
- class IOSSimulatorLog extends IOSLog {
11
- constructor({sim, showLogs, xcodeVersion, iosSimulatorLogsPredicate}) {
12
- super();
13
- this.sim = sim;
14
- this.showLogs = !!showLogs;
15
- this.xcodeVersion = xcodeVersion;
16
- this.predicate = iosSimulatorLogsPredicate;
17
- this.proc = null;
18
- }
19
-
20
- async startCapture() {
21
- if (_.isUndefined(this.sim.udid)) {
22
- throw new Error(`Log capture requires a sim udid`);
23
- }
24
-
25
- if (!(await this.sim.isRunning())) {
26
- throw new Error(`iOS Simulator with udid '${this.sim.udid}' is not running`);
27
- }
28
- const spawnArgs = ['log', 'stream', '--style', 'compact'];
29
- if (this.predicate) {
30
- spawnArgs.push('--predicate', this.predicate);
31
- }
32
- log.debug(
33
- `Starting log capture for iOS Simulator with udid '${this.sim.udid}' ` + `using simctl`,
34
- );
35
- try {
36
- // cleanup existing listeners if the previous session has not been terminated properly
37
- await exec('pkill', ['-f', [this.sim.udid, ...spawnArgs].join(' ')]);
38
- } catch (ign) {}
39
- try {
40
- this.proc = await this.sim.simctl.spawnSubProcess(spawnArgs);
41
- await this.finishStartingLogCapture();
42
- } catch (e) {
43
- throw new Error(`Simulator log capture failed. Original error: ${e.message}`);
44
- }
45
- }
46
-
47
- async finishStartingLogCapture() {
48
- if (!this.proc) {
49
- log.errorAndThrow('Could not capture simulator log');
50
- }
51
- let firstLine = true;
52
- let logRow = '';
53
- this.proc.on('output', (stdout, stderr) => {
54
- if (stdout) {
55
- if (firstLine) {
56
- if (stdout.endsWith('\n')) {
57
- // don't store the first line of the log because it came before the sim was launched
58
- firstLine = false;
59
- }
60
- } else {
61
- logRow += stdout;
62
- if (stdout.endsWith('\n')) {
63
- this.onOutput(logRow);
64
- logRow = '';
65
- }
66
- }
67
- }
68
- if (stderr) {
69
- this.onOutput(logRow, 'STDERR');
70
- }
71
- });
72
-
73
- let sd = (stdout, stderr) => {
74
- if (/execvp\(\)/.test(stderr)) {
75
- throw new Error('iOS log capture process failed to start');
76
- }
77
- return stdout || stderr;
78
- };
79
- await this.proc.start(sd, START_TIMEOUT);
80
- }
81
-
82
- async stopCapture() {
83
- if (!this.proc) {
84
- return;
85
- }
86
- await this.killLogSubProcess();
87
- this.proc = null;
88
- }
89
-
90
- async killLogSubProcess() {
91
- if (!this.proc.isRunning) {
92
- return;
93
- }
94
- log.debug('Stopping iOS log capture');
95
- try {
96
- await this.proc.stop('SIGTERM', 1000);
97
- } catch (e) {
98
- if (!this.proc.isRunning) {
99
- return;
100
- }
101
- log.warn('Cannot stop log capture process. Sending SIGKILL');
102
- await this.proc.stop('SIGKILL');
103
- }
104
- }
105
-
106
- get isCapturing() {
107
- return this.proc && this.proc.isRunning;
108
- }
109
-
110
- onOutput(logRow, prefix = '') {
111
- const logs = _.cloneDeep(logRow.split('\n'));
112
- for (const logLine of logs) {
113
- if (!logLine) continue; // eslint-disable-line curly
114
- this.broadcast(logLine);
115
- if (this.showLogs) {
116
- const space = prefix.length > 0 ? ' ' : '';
117
- log.info(`[IOS_SYSLOG_ROW${space}${prefix}] ${logLine}`);
118
- }
119
- }
120
- }
121
- }
122
-
123
- export {IOSSimulatorLog};
124
- export default IOSSimulatorLog;