geekq / workflow

Ruby finite-state-machine-inspired API for modeling workflow
MIT License
1.75k stars 207 forks source link

Adds the What-Would-Travis-Do gem to run the full set of tests locally. #107

Closed damncabbage closed 10 years ago

damncabbage commented 10 years ago

wwtd uses the .travis.yml file to run the set of tests locally.

I haven't been able to run rake test without a bunch of MiniTest::Unit::TestCase is now Minitest::Test errors; this should be a convenient way to work around that problem without needing to run BUNDLE_GEMFILE=gemfiles/Gemfile.rails-edge bundle exec rake test or similar.

geekq commented 10 years ago

Representing a travis CI build locally is a nice idea. But why would you need any changes to the workflow library itself, like changing 7 files and adding the wwtd gem to every Gemfile? I can not see any note about the need for that in wwtd documentation https://github.com/grosser/wwtd/blob/master/Readme.md

I haven't been able to run rake test without a bunch of MiniTest::Unit::TestCase is now Minitest::Test errors

Was it probably at the moment, the workflow build was broken anyway? In travis too? I fixed it about one or two weeks ago.

BTW the before_install is debian/Ubuntu specific and would not help e.g. Mac users anyway.

damncabbage commented 10 years ago

Why WWTD at all?

I'm not sure what you mean by "Was it probably at the moment, the workflow build was broken anyway? In travis too?"; the build is currently green, and I only ran across this problem today.

I'll try to illustrate with examples from the console (as of master, not the changes in this PR):

$ bundle exec rake test
Warning: you should require 'minitest/autorun' instead.
Warning: or add 'gem "minitest"' before 'require "minitest/autorun"'
From:
  /.../.rbenv/versions/2.0.0-p451/lib/ruby/2.0.0/test/unit.rb:3:in `require'
  /.../.rbenv/versions/2.0.0-p451/lib/ruby/2.0.0/test/unit.rb:3:in `<top (required)>'
  /.../test/test_helper.rb:2:in `require'
  /.../test/test_helper.rb:2:in `<top (required)>'
...
  /.../vendor/bundler/gems/rake-10.3.2/lib/rake/rake_test_loader.rb:4:in `<main>'
MiniTest::Unit::TestCase is now Minitest::Test. From /.../.rbenv/versions/2.0.0-p451/lib/ruby/2.0.0/test/unit/testcase.rb:8:in `<module:Unit>'
/.../.rbenv/versions/2.0.0-p451/lib/ruby/2.0.0/test/unit.rb:670:in `<class:Runner>': undefined method `_run_suite' for class `Test::Unit::Runner' (NameError)
        from /.../.rbenv/versions/2.0.0-p451/lib/ruby/2.0.0/test/unit.rb:255:in `<module:Unit>'
        from /.../.rbenv/versions/2.0.0-p451/lib/ruby/2.0.0/test/unit.rb:9:in `<module:Test>'
        from /.../.rbenv/versions/2.0.0-p451/lib/ruby/2.0.0/test/unit.rb:8:in `<top (required)>'
        from /.../test/test_helper.rb:2:in `require'
...
        from /.../vendor/bundler/gems/rake-10.3.2/lib/rake/rake_test_loader.rb:4:in `<main>'
rake aborted!
...
$ env BUNDLE_GEMFILE=`pwd`/gemfiles/Gemfile.rails-edge bundle install
...

$ env BUNDLE_GEMFILE=`pwd`/gemfiles/Gemfile.rails-edge bundle exec rake test
...
Finished tests in 0.314007s, 175.1553 tests/s, 401.2649 assertions/s.
55 tests, 126 assertions, 0 failures, 0 errors, 0 skips
...

WWTD in every Gemfile

Having the wwtd stuck in every gemfile is not the greatest, I agree. Without it, the test run fails:

$ bundle exec rake
Ignoring: before_install, language, rvm
mv .bundle /var/folders/6t/8l1nhb_12jz2by1jths7bjp80000gn/T/d20140715-70030-1u58d1h
START gemfile: gemfiles/Gemfile.rails-edge
bundle install --quiet
bundle exec rake test
rake aborted!
LoadError: cannot load such file -- wwtd/tasks

I tried to avoid chucking a rescue LoadError in the Rakefile. Which would you prefer?

Linux dependencies

WWTD ignores the before_install line when running the tests.

(I'm not sure that this is a good thing, but it at least means that you can use the rake task in every environment, even if you have to brew install graphviz or apt-get install graphviz manually beforehand.)

geekq commented 10 years ago

I'm not sure what you mean by "Was it probably at the moment, the workflow build was broken anyway? In travis too?"; the build is currently green, and I only ran across this problem today.

If you ran into problem just today, than just ignore what I told. ;-) The workflow build for edge rails was broken for some weeks and fixed 10 days ago.

If this works

$ BUNDLE_GEMFILE=`pwd`/gemfiles/Gemfile.rails-edge bundle install
$ BUNDLE_GEMFILE=`pwd`/gemfiles/Gemfile.rails-edge bundle exec rake test

than it is perfect. This is how it supposed to work. ;-)

I like the idea behind wwtd, and I like it ignoring before_install and I'll likely try it out later. But I do not think, I'll change the workflow Gemfiles etc. just to run wwtd. wwtd is supposed to use Travis configuration files.

damncabbage commented 10 years ago

Okay, that's fine. :smiley: