thoughtbot / appraisal

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

Appraisal as default rake task doesn't run additional tasks #144

Open jeremywadsack opened 6 years ago

jeremywadsack commented 6 years ago

When I use the following in my Rakefile it runs all the tasks listed:

if !ENV["APPRAISAL_INITIALIZED"]
  task default: %i[rubocop bundle:audit appraisal]
else
  task default: %i[spec]
end

When I change the order of default dependencies to run appraisal first it runs the suites through Appraisal (successfully) and then exits without running bundle:audit or rubocop tasks.

if !ENV["APPRAISAL_INITIALIZED"]
  task default: %i[appraisal rubocop bundle:audit]
else
  task default: %i[spec]
end

I presume this has something to do with an exit code for the appraisal task but the actual value of $? in the shell in both cases is 0, so I'm not sure where to look.

inkstak commented 1 year ago

Got the same problem. Fixed it by calling rake tasks in a spawn process :

task :default do
  if ENV["APPRAISAL_INITIALIZED"]
    Rake::Task["spec"].invoke
  else
    # Standard & appraisal requires each a spawn process.

    # Additional tasks won't run after appraisal because of
    # something to do with the exit code.
    # https://github.com/thoughtbot/appraisal/issues/144

    # Standard may be tainted by the rubocop task and
    # report offenses from other plugins putted in .rubocop_todo.yml
    # https://github.com/testdouble/standard/issues/480

    fail unless system "bundle exec appraisal rspec"
    fail unless system "bundle exec rubocop"
    fail unless system "bundle exec rake standard"
  end
end