-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[screengrab] Fix screenshots on Android Q and above #18434
[screengrab] Fix screenshots on Android Q and above #18434
Conversation
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 is a good fix! Thanks for catching this 😊 Just one small suggestion!
@@ -377,6 +377,8 @@ def self.executable?(cmd_path) | |||
|
|||
# returns the path of the executable with the correct extension on Windows | |||
def self.get_executable_path(cmd_path) | |||
cmd_path = localize_file_path(cmd_path) |
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.
Thoughts on removing this new method and just doing this 👇 😇 I tested this on macOS and Windows and it worked 🤷♂️ FILE::ALT_SEPARATOR
is nil
on Windows
cmd_path = localize_file_path(cmd_path) | |
cmd_path = cmd_path.gsub(File::SEPARATOR,File::ALT_SEPARATOR || File::SEPARATOR) |
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.
The localize_file_path
function is used multiple times, so I think you mean something like this?
diff --git a/fastlane_core/lib/fastlane_core/helper.rb b/fastlane_core/lib/fastlane_core/helper.rb
index 72ab5f36a..20f66d759 100644
--- a/fastlane_core/lib/fastlane_core/helper.rb
+++ b/fastlane_core/lib/fastlane_core/helper.rb
@@ -398,7 +398,7 @@ module FastlaneCore
# returns the path with the platform-specific path separator (`/` on UNIX, `\` on Windows)
def self.localize_file_path(path)
# change `/` to `\` on Windows
- return self.windows? ? path.gsub('/', '\\') : path
+ return path.gsub(File::SEPARATOR, File::ALT_SEPARATOR || File::SEPARATOR)
end
# checks if given file is a valid json file
But that would mean duplicating the setup for all the tests:
diff --git a/fastlane/spec/actions_specs/adb_spec.rb b/fastlane/spec/actions_specs/adb_spec.rb
index c148b8cae..b2dfdb7a8 100644
--- a/fastlane/spec/actions_specs/adb_spec.rb
+++ b/fastlane/spec/actions_specs/adb_spec.rb
@@ -3,6 +3,7 @@ describe Fastlane do
describe "adb" do
before(:each) do
allow(FastlaneCore::Helper).to receive(:windows?).and_return(false)
+ allow(File).to receive(:ALT_SEPARATOR).and_return(nil)
end
it "generates a valid command" do
@@ -78,6 +79,7 @@ describe Fastlane do
describe "adb on Windows" do
before(:each) do
allow(FastlaneCore::Helper).to receive(:windows?).and_return(true)
+ allow(File).to receive(:ALT_SEPARATOR).and_return('\\')
end
it "generates a valid command" do
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.
@KartikSoneji Oh shoot, it is used multiple times! 😱 I thought I only saw it used once which is why I suggested what I did. My bad 🤦♂️
Hmmmm... I don’t like those changes to the tests 😔
I think what you had originally is okay 😊 We’ll go with that! Thanks for looking into!
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.
Turns out this is good and I was crazy during my first review 😛 Really appreciate the contribution! Thank you ❤️
Hey @KartikSoneji 👋 Thank you for your contribution to fastlane and congrats on getting this pull request merged 🎉 Please let us know if this change requires an immediate release by adding a comment here 👍 |
Congratulations! 🎉 This was released as part of fastlane 2.179.0 🚀 |
Many devices don't have tar installed. There are also large issues with the current Android-side helper implementation across various android versions. Please see #18003 where I fixed (some of?) these. It looks like my PR fell through some cracks and just didn't get reviewed. :( |
Checklist
bundle exec rspec
from the root directory to see all new and existing tests passbundle exec rubocop -a
to ensure the code style is validMotivation and Context
Trying to capture screenshots with
screengrab
on Android versions >= Android Q (v10, API version 29) fails on Windows.Resolves #18335
Description
FastlaneCore::Helper.which
uses the platform-specific path separator (/
on UNIX,\
on Windows).Adds a new method,
FastlaneCore::Helper.localize_file_path(path)
that fixes the path separator.Fixes the command used to extract the screenshots as described in the issue
Testing Steps
On a Windows PC:
fastlane screengrab
for the project