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

bottle: add tests for writing part #9490

Merged
merged 1 commit into from Dec 22, 2020

Conversation

iMichka
Copy link
Member

@iMichka iMichka commented Dec 9, 2020

In preparation for #9315

  • 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?
  • Have you successfully run brew man locally and committed any changes?

@BrewTestBot
Copy link
Member

Review period will end on 2020-12-10 at 22:06:30 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Dec 9, 2020
@iMichka
Copy link
Member Author

iMichka commented Dec 9, 2020

@SeekingMeaning this will conflict with your changes in #9095. I would like to get my changes in first, so I can proceed on working on the next steps for #9315. The pattern refactoring can then come as a second step.

@iMichka
Copy link
Member Author

iMichka commented Dec 9, 2020

Just if someone wonders: I struggled with the flush/closes of the files. The current code was the only way I found to make it work.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

This refactoring is now very hard to review.

I'm afraid I just don't have confidence that this isn't going to break code that's very important and widely used to "improve readability" in a way that I don't think actually does improve readability. I worry that it's only more readable to you @iMichka now because you're the one who has refactored it.

For changes like this what I'd propose is:

  1. open a PR that adds tests to cover 100% of the existing code you wish to refactor and makes no modifications to the existing code. This will demonstrate the tests exercise (at least some) of the existing functionality.
  2. open a PR that refactors the existing code and makes no modifications to the tests. This will demonstrate that the refactor does not change (at least some) of the existing functionality.
  3. additional, small PRs can be made that add more tests and refactor without needing to alter existing tests.

Sorry to do this, I've just seen these refactorings usually break things (sometimes in ways that aren't apparent until months down the line).

@MikeMcQuaid
Copy link
Member

@SeekingMeaning this will conflict with your changes in #9095. I would like to get my changes in first, so I can proceed on working on the next steps for #9315. The pattern refactoring can then come as a second step.

I would like #9095 to land before this as it's fixing a problem that keeps reoccurring whereas this PR does not in itself do anything beyond refactoring code.

@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Dec 11, 2020
@BrewTestBot
Copy link
Member

Review period ended.

@iMichka iMichka force-pushed the bottle-write-test branch 2 times, most recently from 0d5a0dc to 2896b29 Compare December 11, 2020 22:36
Library/Homebrew/dev-cmd/bottle.rb Outdated Show resolved Hide resolved
@iMichka
Copy link
Member Author

iMichka commented Dec 15, 2020

@MikeMcQuaid I tried a different strategy. Can you have a quick look to validated the approach before I add more tests?

  • I know that brew style is failing, but I do not know how to fix all of the errors. I might need help here.
  • I have no clue what is going on with the indentation in the EOS blocks ... the output needs to look that weird to make the test pass ...

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looking great, thanks for the changes @iMichka! This will definitely provide more confidence while refactoring here 👏🏻

Library/Homebrew/test/dev-cmd/bottle_spec.rb Outdated Show resolved Hide resolved
Library/Homebrew/test/dev-cmd/bottle_spec.rb Outdated Show resolved Hide resolved
Library/Homebrew/test/dev-cmd/bottle_spec.rb Outdated Show resolved Hide resolved
Library/Homebrew/test/dev-cmd/bottle_spec.rb Show resolved Hide resolved
Library/Homebrew/test/dev-cmd/bottle_spec.rb Outdated Show resolved Hide resolved
Library/Homebrew/test/dev-cmd/bottle_spec.rb Outdated Show resolved Hide resolved
Library/Homebrew/test/dev-cmd/bottle_spec.rb Outdated Show resolved Hide resolved
@iMichka iMichka force-pushed the bottle-write-test branch 2 times, most recently from a60abdb to 459015e Compare December 18, 2020 14:14
@iMichka
Copy link
Member Author

iMichka commented Dec 21, 2020

The test is passing now, but I can't make brew style pass. Either brew style, either the test is fine. I can't make both work together ...

@SeekingMeaning SeekingMeaning force-pushed the bottle-write-test branch 5 times, most recently from ef66296 to 8411c2a Compare December 21, 2020 23:53
@iMichka
Copy link
Member Author

iMichka commented Dec 22, 2020

This should work now. Thanks @SeekingMeaning for the test fix!

Library/Homebrew/test/dev-cmd/bottle_spec.rb Outdated Show resolved Hide resolved
Library/Homebrew/test/dev-cmd/bottle_spec.rb Outdated Show resolved Hide resolved
Library/Homebrew/test/dev-cmd/bottle_spec.rb Outdated Show resolved Hide resolved
@iMichka iMichka merged commit fc305cc into Homebrew:master Dec 22, 2020
@iMichka
Copy link
Member Author

iMichka commented Dec 22, 2020

Merged, CI is green. I have one or two more tests to test other branches of that part of the code, this should be straightforward now and I will open a new PR for that.

@iMichka iMichka deleted the bottle-write-test branch December 22, 2020 13:20
@MikeMcQuaid
Copy link
Member

Thanks for persevering @iMichka!

@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Jan 22, 2021
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Jan 22, 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

4 participants