Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: include devicectl in IOSDeploy object #2352

Merged
merged 9 commits into from
Mar 25, 2024
Merged

Conversation

KazuCocoa
Copy link
Member

@KazuCocoa KazuCocoa commented Mar 24, 2024

the command itself failed but below example was this pr's test. The lib/commands/memory.js's instance called the devicectl command properly

[HTTP] --> POST /session/882dfb56-d64d-4124-a74e-f1056e9c7200/execute/sync
[HTTP] {"script":"mobile: sendMemoryWarning","args":[{"bundleId":"com.apple.Maps"}]}
[XCUITestDriver@36d5 (882dfb56)] Calling AppiumDriver.execute() with args: ["mobile: sendMemoryWarning",[{"bundleId":"com.apple.Maps"}],"882dfb56-d64d-4124-a74e-f1056e9c7200"]
[XCUITestDriver@36d5 (882dfb56)] Executing command 'execute'
[XCUITest] Executing xcrun devicectl device info apps --device 00008020-000E5CDA0A23002E --include-all-apps --bundle-id com.apple.Maps --quiet --json-output -
[XCUITest] Executing xcrun devicectl device info processes --device 00008020-000E5CDA0A23002E --quiet --json-output -
[XCUITestDriver@36d5 (882dfb56)] Emulating Low Memory warning for the process id 3745, bundle id com.apple.Maps
[XCUITest] Executing xcrun devicectl device process sendMemoryWarning --device 00008020-000E5CDA0A23002E --pid 3745 --quiet --json-output -
[XCUITestDriver@36d5 (882dfb56)] Encountered internal error running command: Error: 'xcrun devicectl device process sendMemoryWarning --device 00008020-000E5CDA0A23002E --pid 3745 --quiet --json-output -' failed. Original error: ERROR: The operation couldn’t be completed. No such file or directory (NSPOSIXErrorDomain error 2.)
[XCUITestDriver@36d5 (882dfb56)]
[XCUITestDriver@36d5 (882dfb56)]     at Devicectl.execute (/Users/kazu/GitHub/appium-xcuitest-driver/lib/devicectl.js:138:13)
[XCUITestDriver@36d5 (882dfb56)]     at Devicectl.sendMemoryWarning (/Users/kazu/GitHub/appium-xcuitest-driver/lib/devicectl.js:149:5)
[XCUITestDriver@36d5 (882dfb56)]     at XCUITestDriver.mobileSendMemoryWarning (/Users/kazu/GitHub/appium-xcuitest-driver/lib/commands/memory.js:49:5)
[XCUITestDriver@36d5 (882dfb56)]     at XCUITestDriver.executeMethod (/Users/kazu/GitHub/appium-xcuitest-driver/node_modules/@appium/base-driver/lib/basedriver/commands/execute.ts:36:12)
[XCUITestDriver@36d5 (882dfb56)]     at XCUITestDriver.execute (/Users/kazu/GitHub/appium-xcuitest-driver/lib/commands/execute.js:118:14)
[HTTP] <-- POST /session/882dfb56-d64d-4124-a74e-f1056e9c7200/execute/sync 500 4357 ms - 1054

@KazuCocoa KazuCocoa marked this pull request as draft March 24, 2024 01:58
@KazuCocoa KazuCocoa marked this pull request as ready for review March 24, 2024 02:11
const devicectl = new Devicectl(this.opts.udid, this.log);
const fileNames = await devicectl.listFiles(DOMAIN_TYPE, DOMAIN_IDENTIFIER, {
// @ts-expect-error - do not assign arbitrary properties to `this.opts`
const device = this.opts.device;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it makes sense to explicitly provide the type of device, so typescript could verify further typechecks. Same note for other calls

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, i wondered if it could. I need to learn more to add them as another pr. Initially I thought something like the below in driver.js, but maybe it was wrong.

/**
 * @typedef {import('@appium/types').DriverOpts<XCUITestDriverConstraints>} XCUITestDriverOpts
 * @property {import('./devicectl')Devicectl} device
 */

Copy link
Contributor

@mykola-mokhnach mykola-mokhnach Mar 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about having device property attached directly to the driver, like

get device () {
  return this.opts.device;
}

With proper typehints this should work nicely. Maybe I will take care about it later myself after your changes are done

lib/ios-deploy.js Outdated Show resolved Hide resolved
lib/ios-deploy.js Outdated Show resolved Hide resolved
@mykola-mokhnach
Copy link
Contributor

It would probably make sense to bump the major WDA version when we are going to use devicectl attached to the device instance there. The reason is that older xcuitest drivers have "^x.x.x" dependency, which means there is a possibility they could fetch newer WDA and render unexpected errors.

@KazuCocoa KazuCocoa merged commit 6c5abd1 into master Mar 25, 2024
18 checks passed
@KazuCocoa KazuCocoa deleted the include-devicectl branch March 25, 2024 00:07
@KazuCocoa
Copy link
Member Author

hm https://github.com/appium/appium-xcuitest-driver/actions/runs/8413083261/job/23034781606

Error: lib/simulator-management.js(41,10): error TS2339: Property 'map' does not exist on type 'Promise<any>'.
Error: lib/simulator-management.js(50,63): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.
npm ERR! code 1
npm ERR! path /home/runner/work/appium-xcuitest-driver/appium-xcuitest-driver
npm ERR! command failed
npm ERR! command sh -c npm run rebuild

npm ERR! A complete log of this run can be found in: /home/runner/.npm/_logs/2024-03-25T00_07_44_898Z-debug-0.log
Error: Process completed with exit code 1.

KazuCocoa added a commit that referenced this pull request Mar 25, 2024
* chore: include devicectl in IOSDeploy object

* add ignore

* define once to reduce ignore

* define once to reduce ignore

* mofidy log
github-actions bot pushed a commit that referenced this pull request Mar 25, 2024
## [7.5.3](v7.5.2...v7.5.3) (2024-03-25)

### Bug Fixes

* build error ([#2356](#2356)) ([5c5ebc3](5c5ebc3))
* typo by [#2351](#2351) ([63589a1](63589a1))

### Miscellaneous Chores

* include devicectl in IOSDeploy object ([#2352](#2352)) ([6c5abd1](6c5abd1))
Copy link
Contributor

🎉 This PR is included in version 7.5.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants