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

Fix incompatible encoding regexp match for linting non-ascii pod name #9776

Merged
merged 8 commits into from May 9, 2020

Conversation

banjun
Copy link
Contributor

@banjun banjun commented May 8, 2020

Fixes #9765

Added a unit test for the issue and fix with minimal changes.

When the validator parses an xcodebuild output, String encoding is ASCII-8BIT on some environments (see the issue). As I can't tell how to fix the root cause in a safe way, I choose to apply a minimum fix in this PR.

The testcase potentially requires xcodebuild to be executed because the key is reading from its outputs from the system. I've done stub a part of xcodebuild output value for travis.

Gemfile.lock Outdated
@@ -134,8 +134,8 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.5.1)
Copy link
Contributor

Choose a reason for hiding this comment

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

why does this file need to change at all here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it has some strange points but bundle update webmock emit this error. updating webmock & danger I can install webmock 3.5.

Bundler could not find compatible versions for gem "addressable":
  In Gemfile:
    cocoapods-core was resolved to 1.9.1, which depends on
      addressable (~> 2.6)

    danger was resolved to 5.3.0, which depends on
      octokit (~> 4.2) was resolved to 4.7.0, which depends on
        sawyer (>= 0.5.3, ~> 0.8.0) was resolved to 0.8.1, which depends on
          addressable (>= 2.3.5, < 2.6)

    webmock was resolved to 3.8.3, which depends on
      addressable (>= 2.3.6)

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps bundle install instead of bundle update?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

possibly it's unnecessary change. Gemfile refs to cocoapods-core at master and core needs addressable (~> 2.6) on current master but core 1.9.1 does not require it. I think this may cause bundle update error.

https://github.com/CocoaPods/Core/blob/01e301e2a30a312247252f0c155ec6b244f35c51/cocoapods-core.gemspec#L29

bundle update for webmock is required to run the added test case on ruby 2.6. ruby 2.6 is system ruby on Catalina and used in the latest machines in github actions and bitrise. anyway, travis here uses ruby 2.0..? It might be better to remove the test case for ruby 2.6...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found disabling webmock in the testcase can avoid unknown keyword: write_timeout error without modifying Gemfile.lock. I have deleted the Gemfile.lock commit and force pushed. I think it should work.

How can this WebMock handling in the test case be better? How do you think of it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this resolved in #9776 (comment)

@dnkoutso
Copy link
Contributor

dnkoutso commented May 8, 2020

nice! Can you add a changelog entry and point to the GH issue in it?

@dnkoutso dnkoutso added this to the 1.10.0 milestone May 8, 2020
@@ -59,5 +60,14 @@ module Pod
UI.output.should.include 'could not be loaded'
end
end

it 'lints a spec with non-ascii pod name' do
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe dont add the test here but instead add it to the validator_spec.rb and just ensure there is no crash by asking to validate this spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dc14392
move the test into validator_spec.rb and that resolves WebMock and the Gemfile modification issues.

CHANGELOG.md Outdated
@@ -19,6 +19,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`

##### Bug Fixes

* Fix `incompatible encoding regexp match` for linting non-ascii pod name
Copy link
Contributor

Choose a reason for hiding this comment

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

last nit: please add two spaces at the end of this sentence for markdown formatting

@banjun
Copy link
Contributor Author

banjun commented May 9, 2020

@dnkoutso is xcodebuild unavailable on travis? if so, we have to stub _xcodebuild with some artificial value such like:

validator.stubs(:_xcodebuild).returns("note: Execution policy exception registration failed and was skipped: Error Domain=NSPOSIXErrorDomain Code=1 \"Operation not permitted\" (in target '※ikemen' from project 'Pods')".force_encoding('ASCII-8BIT'))

@banjun
Copy link
Contributor Author

banjun commented May 9, 2020

@dnkoutso thanks for approve! I've fixed the travis build. I'd like you to re-review with the latest commit.

@dnkoutso dnkoutso merged commit 7dccae0 into CocoaPods:master May 9, 2020
@banjun banjun deleted the fix-ascii-regex-match branch May 10, 2020 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pod lib lint cause incompatible encoding regexp match for non-ascii pod name
3 participants