thoughtbot / appraisal

A Ruby library for testing your library against different versions of dependencies.
https://thoughtbot.com
MIT License
1.26k stars 107 forks source link

Use Bundler.with_original_env instead of custom clean environment logic #202

Closed kyrofa closed 1 year ago

kyrofa commented 1 year ago

This is simply a version of #174 that:

  1. Is rebased on the most recent main
  2. Has tests that actually pass

(2) is done by way of introducing a new 'APPRAISAL_UNDER_TEST' environment variable that Command uses to determine if Appraisal itself is under test, and if so, tweaks the environment in the way the tests require.

nickcharlton commented 1 year ago

Thanks for doing this, and sorry for taking so long to get around to looking at it. My plan is to merge this in the next few days (unfortunately, I've run out of time today).

One question, I'm getting this locally:

Failures:

  1) Appraisals file Bundler DSL compatibility supports all Bundler DSL in Appraisals file
     Failure/Error:
       raise RuntimeError, <<-error_message.strip_heredoc
         Command #{command.inspect} exited with status #{exitstatus}. Output:
         #{output.gsub(/^/, '  ')}
       error_message

     RuntimeError:
                 Command "bundle install --local" exited with status 17. Output:
                   Fetching ../gems/croissant
       Fetching ../gems/egg
       Fetching ../gems/omelette
     # ./spec/support/acceptance_test_helpers.rb:162:in `block (2 levels) in run'
     # <internal:kernel>:90:in `tap'
     # ./spec/support/acceptance_test_helpers.rb:154:in `block in run'
     # ./spec/support/acceptance_test_helpers.rb:149:in `chdir'
     # ./spec/support/acceptance_test_helpers.rb:149:in `in_test_directory'
     # ./spec/support/acceptance_test_helpers.rb:153:in `run'
     # ./spec/acceptance/appraisals_file_bundler_dsl_compatibility_spec.rb:92:in `block (2 levels) in <top (required)>'

Have you been seeing the same?

nickcharlton commented 1 year ago

Oh! It's fixed with Bundler v2.3.7. That's acceptable, I think.

kyrofa commented 1 year ago

I don't see it locally, using bundler v2.2.33 (which is what is stated in the lockfile). Note that bundler v2.3 and later, if combined with RubyGems v3.3 or later, automatically re-execs into the BUNDLED_WITH version from the lockfile, so that latest test run you just did probably used v2.2.33 as well.

We will need to deal with those deprecations, they will eventually bite us. That'll be another PR, though.

nickcharlton commented 1 year ago

Yeah — should be much easier now this problem is solved. It's been a real headache here, elsewhere just for me, let alone everyone else!

Thanks for opening this new PR with the working tests and getting in touch the other week. Thanks also to everyone else who helped with this issue over the last while!

kyrofa commented 1 year ago

My pleasure. As I mentioned in my email, I'm happy to help maintain this if you'd like more hands.