Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Better test specific file searching #7166

Merged
1 commit merged into from May 16, 2019
Merged

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented May 7, 2019

What was the end-user problem that led to this PR?

The problem was that in #7138 I removed some test specific code from lib, but it's not quite working.

What was your diagnosis of the problem?

My diagnosis was that the mocking I used to fix the issue of bundler looking for files outside of bundler's clone doesn't work inside subprocesses, which many of our specs use. That means some specs were currently failing if you have Gemfile's on .bundle folders up in the directory hierarchy ascending from your bundler's clone

What is your fix for the problem, implemented in this PR?

My fix is revert to the previous approach of using a test specific environment variable to prevent search up higher than the test directory when running our specs.

Why did you choose this fix out of the possible options?

I initially tried to monkeypatch the gemfile finding helpers only inside specs, but that caused load order issues (I monkeypatched the helpers insde support/hax.rb, that caused the monkeypatched lib code to be loaded before the rest of bundler, which caused issues in some specs).

Overall, the old approach is the only one that works without issues, so I'm reverting to it, at least for now.

@deivid-rodriguez deivid-rodriguez force-pushed the better_test_specific_file_searching branch 3 times, most recently from b2aa543 to 2bb86b5 Compare May 12, 2019 16:24
@deivid-rodriguez
Copy link
Member Author

This is now passing but I was getting a spec failure and 1f1162d fixed and I have no idea why. So I'd like to investigate that before asking for reviews.

@deivid-rodriguez deivid-rodriguez force-pushed the better_test_specific_file_searching branch 2 times, most recently from 6f299ca to 040186d Compare May 16, 2019 15:52
@deivid-rodriguez
Copy link
Member Author

I investigated the issues and finally decided to revert #7138, because I couldn't find a good solution that does not cause issues.

@deivid-rodriguez
Copy link
Member Author

Oh, this might fix #7169, by the way.

I tried monkeypatching the gemfile finder methods in hax.rb, but that
resulted in loading parts of bundler too early, and getting redefinition
warnings when loading them again from exe/bundle, resulting in actual
errors in some cases. The fix for that required eagerly loading the
monkeypatched parts of bundler, but that involves changing lib just for
the sake of making existing tests pass, and that's what the original
changes intend to avoid.

So, I'm just reverting to the previous approach of setting an
environment variable just for testing and check that.

Reverts 11597fe.
@deivid-rodriguez deivid-rodriguez force-pushed the better_test_specific_file_searching branch from 040186d to d5729d2 Compare May 16, 2019 19:45
@deivid-rodriguez
Copy link
Member Author

This fixes several failures when testing locally on systems with a per-user bundler configuration, so I'm merging it. We can revisit if we find a solution that does not run into those issues.

@bundlerbot r+

ghost pushed a commit that referenced this pull request May 16, 2019
7166: Better test specific file searching r=deivid-rodriguez a=deivid-rodriguez

### What was the end-user problem that led to this PR?

The problem was that in #7138 I removed some test specific code from lib, but it's not quite working.

### What was your diagnosis of the problem?

My diagnosis was that the mocking I used to fix the issue of bundler looking for files outside of bundler's clone doesn't work inside subprocesses, which many of our specs use. That means some specs were currently failing if you have Gemfile's on `.bundle` folders up in the directory hierarchy ascending from your bundler's clone

### What is your fix for the problem, implemented in this PR?

My fix is revert to the previous approach of using a test specific environment variable to prevent search up higher than the test directory when running our specs.

### Why did you choose this fix out of the possible options?

I initially tried to monkeypatch the gemfile finding helpers only inside specs, but that caused load order issues (I monkeypatched the helpers insde `support/hax.rb`, that caused the monkeypatched lib code to be loaded _before_ the rest of `bundler`, which caused issues in some specs).

Overall, the old approach is the only one that works without issues, so I'm reverting to it, at least for now.

Co-authored-by: David Rodríguez <deivid.rodriguez@riseup.net>
@ghost
Copy link

ghost commented May 16, 2019

Build succeeded

@ghost ghost merged commit d5729d2 into master May 16, 2019
@ghost ghost deleted the better_test_specific_file_searching branch May 16, 2019 21:24
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant