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

test: don't try to use Xcode SDK for build requirement #10048

Merged
merged 1 commit into from
Dec 21, 2020
Merged

test: don't try to use Xcode SDK for build requirement #10048

merged 1 commit into from
Dec 21, 2020

Conversation

Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Dec 18, 2020

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?
  • Have you successfully run brew man locally and committed any changes?

Previously, running brew test failed if the formula had an Xcode build requirement but the user did not have Xcode installed. brew would see the Xcode requirement and default to the Xcode SDK. However, for formula that only need Xcode to build, this check is unnecessary when simply testing the formula. I ran into this in Homebrew/homebrew-core#67043 with deno:

$ brew test deno
==> Testing deno
Error: deno: failed
An exception occurred within a child process:
  NoMethodError: undefined method `path' for nil:NilClass
Did you mean?  paths
/usr/local/Homebrew/Library/Homebrew/extend/os/mac/extend/ENV/std.rb:88:in `macosxsdk'
/usr/local/Homebrew/Library/Homebrew/extend/os/mac/extend/ENV/std.rb:45:in `setup_build_environment'
/usr/local/Homebrew/Library/Homebrew/test.rb:39:in `<main>'

I don't have code installed, so Xcode.sdk.path failed (Xcode.sdk is nil).

My solution is to, when testing, pass a flag to the macosxsdk method to determine whether to check only runtime requirements. When this is false (the default), any Xcode requirement will require the use of the Xcode SDK. When set to true (only in brew test), build-only Xcode requirements will not necessarily require the Xcode SDK.

I'm marking this PR as critical because I believe it fixes a bug. However, I'm not familiar at all with the files that I'm changing so it's entirely possible that this change will have unintended consequences. I will not merge until I have approvals from other maintainers who are more familiar with this code.

@Rylan12 Rylan12 added the critical Critical change which should be shipped as soon as possible. label Dec 18, 2020
@BrewTestBot
Copy link
Member

BrewTestBot commented Dec 18, 2020

Review period ended.

@carlocab
Copy link
Member

Tested this locally with the existing deno bottle:

❯ brew test deno
==> Testing deno
==> /usr/local/Cellar/deno/1.6.0/bin/deno run hello.ts
Check file:///private/tmp/deno-test-20201218-47524-x10fau/hello.ts
==> /usr/local/Cellar/deno/1.6.0/bin/deno run --allow-read=/private/tmp/deno-test-20201218-47524-x10fau https://deno.land/[email protected].
Download https://deno.land/[email protected]/examples/cat.ts
Check https://deno.land/[email protected]/examples/cat.ts

Works perfectly fine.

Library/Homebrew/os/mac.rb Outdated Show resolved Hide resolved
Library/Homebrew/extend/os/mac/extend/ENV/std.rb Outdated Show resolved Hide resolved
@Rylan12
Copy link
Member Author

Rylan12 commented Dec 18, 2020

Updated to simplify/clarify the logic and switch to using keyword arguments instead of **options

@MikeMcQuaid
Copy link
Member

Thanks @Rylan12!

@Rylan12 Rylan12 enabled auto-merge December 21, 2020 14:25
@Rylan12 Rylan12 merged commit 6994633 into Homebrew:master Dec 21, 2020
@Rylan12 Rylan12 deleted the fix-test-sdk-detection branch December 21, 2020 15:17
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Feb 1, 2021
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Feb 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants