-
-
Notifications
You must be signed in to change notification settings - Fork 0
Sauce: Implement CopyDeviceItem, log file parameter for RunApplication & fix issues #32
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
base: main
Are you sure you want to change the base?
Conversation
- Add optional LogFilePath parameter to Invoke-DeviceApp and RunApplication - Implement log file retrieval with fallback to system logs in SauceLabsProvider - Add method overloads to AdbProvider and XboxProvider for compatibility - Reduce code footprint by consolidating log retrieval logic - Maintain backward compatibility with existing provider implementations Co-authored-by: Claude Sonnet <claude@anthropic.com>
- Replace method overloads with single method using optional LogFilePath parameter - Update base DeviceProvider class to include optional parameter - Simplify all provider implementations (SauceLabs, Adb, Xbox) - Remove conditional logic from Invoke-DeviceApp - single method call - Clean up code by eliminating method overload complexity Co-authored-by: Claude Sonnet <claude@anthropic.com>
- Add optional LogFilePath parameter to match other providers - Ensures consistent method signature across all provider implementations - Completes the refactoring to use optional parameters instead of overloads Co-authored-by: Claude Sonnet <claude@anthropic.com>
|
|
On it! We are reviewing the PR and will provide feedback shortly. |
|
|
||
| # Split the arguments string by spaces, but handle quoted strings (both single and double quotes) | ||
| $argTokens = [regex]::Matches($Arguments, '(\"[^\"]*\"|''[^'']*''|\S+)') | ForEach-Object { $_.Value.Trim('"', "'") } | ||
|
|
||
| foreach ($token in $argTokens) { | ||
| $argumentsArray += $token | ||
| } | ||
|
|
||
| $launchBody['arguments'] = $argumentsArray |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better, how about we change $arguments param to [object] and let users pass string or array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, [string[]] actually accepts both a string and an array of strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have multiple places where we represent arguments as a single string. I suppose I can refactor all of that in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you shouldn't really need to change that. a single string works the same as an array of a a single string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, we'd want to use arrays to eliminate the guesswork. But it clashes with command format string substitutions in device providers. I've converted most of our pathways to use an array of arguments, but I'm still a bit conflicted about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you're only changing this for the invoke-app flow - I'd just join the string by a space by default, no escaping, quoting, etc.
If someone needs custom escaping or quoting, they can always pass a single string.
let's keep it simple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this to work:
Invoke-App -Exe "Game.exe" -Arguments @("start-level", "Big Mountain")But I get your point, and we can remove the safety. If we don't want to add such guarantees, we should clearly communicate such expectations. I'll add it to the docs then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean if you want, you can do some simple quoting but I probably wouldn't bother. It's not all that usual to have spaces in args for what we do here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can leave it as is. Is there anything else we should address before it can be merged?
vaind
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found a couple of bugs and a few improvement ideas
Updated device provider APIs to consistently accept arguments as string arrays rather than pre-formatted strings, improving type safety and eliminating argument parsing ambiguities. Added ConvertArgumentsToString method to DeviceProvider base class for consistent string conversion when needed by underlying tools. Co-authored-by: Claude <claude@anthropic.com>
Also relax Intent extras validation to only validate known patterns
providers that don't support the LogFilePath parameter, and clarify in documentation that it's currently only supported on SauceLabs platforms.
7988845 to
ad71c2a
Compare
|
|
vaind
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late re-review. This looks pretty good to me but needs some tests for the new code (ideally against real SauceLabs, but unit tests would do too)
| [hashtable] RunApplication([string]$AppPath, [string[]]$Arguments, [string]$LogFilePath = $null) { | ||
| if (-not ([string]::IsNullOrEmpty($LogFilePath))) { | ||
| Write-Warning "LogFilePath parameter is not supported on this platform." | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this codeblock mixes tab & space separators, breaking the indent (2 vs 4) for some. Please use spaces instead to keep the indentation consistent across the repo.
|
|
||
| # Skip the key and value we just validated | ||
| $i += 2 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider warning or a debug log in the "else" branch. Although, I guess since this is just a nice-to-nave anyway, maybe it's ok as is.
| Array of arguments to pass to the executable when starting it. | ||
| The caller is responsible for quoting/escaping the arguments. | ||
| For example, if the executable requires arguments with spaces, they should be quoted: | ||
| Invoke-DeviceApp -ExecutablePath "Game.exe" -Arguments @('"/path/to/some file.txt"', '--debug') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfectly explained, thanks! 👍
| # Check iOS Fixture (not supported yet) | ||
| # $iosFixture = Join-Path $PSScriptRoot 'Fixtures' 'iOS' 'TestApp.ipa' | ||
| # if (Test-Path $iosFixture) { | ||
| # $TestTargets += Get-TestTarget ` | ||
| # -Platform 'iOSSauceLabs' ` | ||
| # -Target 'iPhone 13 Pro' ` | ||
| # -FixturePath $iosFixture ` | ||
| # -ExePath 'com.saucelabs.mydemoapp.ios' ` | ||
| # -Arguments '--test-arg value' | ||
| # -Arguments @('--test-arg', 'value') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU this PR enables iOS support. Are you going to enable iOS tests in a followup PR? As currently the new code paths don't seem to be tested (CopyDeviceItems, LogFilePath and CheckAppFileSharingCapability)
I tested it on iOS in Sauce Labs, and it should work on Android too. This PR also fixes some issues specific to iOS in Sauce Labs runner: splitting CLI arguments correctly and using correct Appium parameter for iOS.
These changes are sufficient to get E2E tests green on iOS in the Godot SDK.