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

Cask loader: add missing canonicalisation #7451

Merged
merged 4 commits into from Apr 27, 2020
Merged

Cask loader: add missing canonicalisation #7451

merged 4 commits into from Apr 27, 2020

Conversation

claui
Copy link
Contributor

@claui claui commented Apr 27, 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 tests with your changes locally? A couple of tests fail on my local machine but all of them seem to be unrelated. See Fix cask loading after adding an artifact type #7417.

This PR fixes a bug I missed in PR #7417.
Also, a flaw in our test helper masked the bug so it went past the radar.

This PR has four steps:

  1. Change an interface for testability.

  2. Add a test for the PR Fix cask loading after adding an artifact type #7417 bug.
    That test is supposed to fail but actually passes due to a flaw in our test helper.
    In other words: this commit reveals a test helper bug.

  3. Fix the test helper bug. Now the test fails, exposing the PR Fix cask loading after adding an artifact type #7417 bug.

  4. Fix the PR Fix cask loading after adding an artifact type #7417 bug.

For details to one of the steps, see the detailed commit message of the individual step.

Previously, the JSON-based cask config loader was untested.
This commit changes the interface to accept a string, making the loader
easier to test. The commit also adds a test.
This commit adds a broken test, which is meant to expose a flaw in the
constructor of `Cask::Config`.

That (broken) test still passes because there’s also a flaw in our
test helper code.

The helper flaw happens to neutralize the `Cask::Config` flaw.
This commit fixes a flaw in the Cask test helper, causing the broken `Cask::Config` test to actually fail.

The flaw occurred while patching the `Cask::Config::DEFAULT_DIRS` hash.
While the original hash uses strings as values, the patched one used
`Pathname` values, masking a broken `Cask::Config::from_json` test.

Now the broken test fails like it should.
This commit fixes the PR #7417 bug.

The call to `canonicalize` needs to wrap `DEFAULT_DIRS`, not the
other way around. This was mixed up in PR #7417 due to an oversight.
@MikeMcQuaid MikeMcQuaid merged commit 223b66b into Homebrew:master Apr 27, 2020
@MikeMcQuaid
Copy link
Member

Thanks @claui!

@claui claui deleted the fix-cask-loading-this-time-for-real branch April 27, 2020 16:25
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Jan 2, 2021
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Jan 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants