Skip to content
This repository

Rake::TestTask pattern is not being expanded in 1.9.3 #51

Closed
spastorino opened this Issue June 07, 2011 · 23 comments
Santiago Pastorino
Rake::TestTask.new(:test) do |t|
  t.pattern = "test/**/*_test.rb"
  t.verbose = true
  t.warning = true
end

Here https://github.com/ruby/ruby/blob/trunk/lib/test/unit.rb#L144 files is ['test/**/*_test.rb'] which is wrong.
I need to change the pattern line to

Rake::TestTask.new(:test) do |t|
  t.test_files = Dir.glob("test/**/*_test.rb")
  t.verbose = true
  t.warning = true
end

in order to run rake test.

This is the commit that seems to broke it 0712aed

Eric Hodel
Collaborator

It looks like this commit was supposed to have rake_test_loader pick up the slack, but that is not happening.

Santiago Pastorino
➜  string_reverse  rake -t test
** Invoke test (first_time)
** Invoke compile (first_time)
** Invoke compile:x86_64-darwin10.7.4 (first_time)
** Invoke compile:string_reverse:x86_64-darwin10.7.4 (first_time)
** Invoke copy:string_reverse:x86_64-darwin10.7.4:1.9.3 (first_time)
** Invoke lib (first_time, not_needed)
** Invoke tmp/x86_64-darwin10.7.4/string_reverse/1.9.3/string_reverse.bundle (first_time, not_needed)
** Invoke tmp/x86_64-darwin10.7.4/string_reverse/1.9.3/Makefile (first_time, not_needed)
** Invoke tmp/x86_64-darwin10.7.4/string_reverse/1.9.3 (first_time, not_needed)
** Invoke ext/string_reverse/extconf.rb (first_time, not_needed)
** Invoke ext/string_reverse/string_reverse.c (first_time, not_needed)
** Execute copy:string_reverse:x86_64-darwin10.7.4:1.9.3
install -c tmp/x86_64-darwin10.7.4/string_reverse/1.9.3/string_reverse.bundle lib/string_reverse.bundle
** Execute compile:string_reverse:x86_64-darwin10.7.4
** Execute compile:x86_64-darwin10.7.4
** Execute compile
** Execute test
/Users/santiago/.rvm/rubies/ruby-head/bin/ruby -w -I"lib" -I"/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib" "/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/rake_test_loader.rb" "test/**/*_test.rb" 
/Users/santiago/string_reverse/lib/string_reverse.bundle: warning: method redefined; discarding old reverse
test/**/*_test.rb
["test/**/*_test.rb"]
/Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/test/unit.rb:168:in `block in non_options': file not found: test/**/*_test.rb (ArgumentError)
    from /Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/test/unit.rb:147:in `map!'
    from /Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/test/unit.rb:147:in `non_options'
    from /Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/test/unit.rb:208:in `non_options'
    from /Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/test/unit.rb:53:in `process_args'
    from /Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
    from /Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
    from /Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/test/unit.rb:21:in `run'
    from /Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/test/unit.rb:333:in `block (2 levels) in autorun'
    from /Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
    from /Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/test/unit.rb:332:in `block in autorun'
rake aborted!
Command failed with status (1): [/Users/santiago/.rvm/rubies/ruby-head/bin/...]
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/file_utils.rb:45:in `call'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/file_utils.rb:45:in `sh'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/file_utils_ext.rb:36:in `sh'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/file_utils.rb:80:in `ruby'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/file_utils_ext.rb:36:in `ruby'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/testtask.rb:99:in `block (2 levels) in define'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/file_utils_ext.rb:57:in `verbose'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/testtask.rb:98:in `block in define'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/santiago/.rvm/rubies/ruby-head/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/santiago/.rvm/gems/ruby-head/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/santiago/.rvm/gems/ruby-head/bin/rake:19:in `load'
/Users/santiago/.rvm/gems/ruby-head/bin/rake:19:in `<main>'
Tasks: TOP => test
Eric Hodel drbrain closed this June 23, 2011
Christoph Olszowka

Since the fix is not released in an official gem version of rake yet, running rake test to try out 1.9.3-preview1 might fail because of this issue.

I was able to work around the issue on simplecov by replacing test.pattern (...) with test.test_files = FileList['test/test*.rb'] inside of the Rakefile Rake::TestTask definition (found this suggestion in the Rake rdoc actually, see http://rake.rubyforge.org/classes/Rake/TestTask.html). The corresponding commit can be found here

Hope this helps people trying to get their stuff ready for 1.9.3!

Santiago Pastorino

@colszowka anyways this should be fixed for 1.9.3 and rake should be released again since it's a regression. /cc @drbrain @jimweirich

Robert Pankowecki

I would like to see new rake release with this issue fixed too.

Eric Hodel
Collaborator

If you would like to see this bug fix released please send Jim a postcard care of Edgecase in Cincinnati:

Jim Weirich
℅ EdgeCase
1130 Congress Avenue
Suite C
Cincinnati, Ohio 45246

Please stop asking for a release via this issue as it is a waste of your time. I am no longer paying attention to this issue and I cannot release rake.

Christoph Olszowka

Sorry Eric, I was thinking it might be of interest to the maintainers of Rake that this actually causes trouble on the latest version of Ruby. I will write the postcard as soon as I have scraped together the money for the stamps (it's a long way from here).

Joshua Siler

Why do we have to send a postcard asking for a rake release?

Huy Nguyen

Hi guys I'm still seeing this issue and non of the workarounds are working for me.

I've tried using rake 0.9.3.beta.1 and overriding Rakefile with the below. What am I doing wrong? :(

Rake::TestTask.new(:test) do |t|
  t.test_files = Dir.glob("test/**/*_test.rb")
  t.verbose = true
  t.warning = true
end
Santiago Pastorino

are you sure you're using 0.9.3.beta.1? it is a Rails application? have you tried bundle exec rake ...
It works fine for me, also works fine using Ruby 1.9.3 and Rake 0.9.2.2.

Huy Nguyen

rake 0.9.2.2:

hnguyen@taengoo:~/work/fundly ಠ_ಠ >> ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
hnguyen@taengoo:~/work/fundly ಠ_ಠ >> rails --version
Rails 3.1.3
hnguyen@taengoo:~/work/fundly ಠ_ಠ >> rake -V
rake, version 0.9.2.2
hnguyen@taengoo:~/work/fundly ಠ_ಠ >> bundle exec rake -V
rake, version 0.9.2.2
hnguyen@taengoo:~/work/fundly ಠ_ಠ >> bundle exec rake db:migrate
/Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:167:in `block in non_options': file not found: db:migrate (ArgumentError)
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `map!'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `non_options'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:207:in `non_options'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:52:in `process_args'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:21:in `run'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'

rake 0.9.3.beta.1

hnguyen@taengoo:~/work/fundly ಠ_ಠ >> ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]
hnguyen@taengoo:~/work/fundly ಠ_ಠ >> rails --version
Rails 3.1.3
hnguyen@taengoo:~/work/fundly ಠ_ಠ >> rake -V
rake, version 0.9.3.beta.1
hnguyen@taengoo:~/work/fundly ಠ_ಠ >> bundle exec rake -V
rake, version 0.9.3.beta.1
hnguyen@taengoo:~/work/fundly ಠ_ಠ >> bundle exec rake db:migrate
/Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:167:in `block in non_options': file not found: db:migrate (ArgumentError)
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `map!'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `non_options'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:207:in `non_options'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:52:in `process_args'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:21:in `run'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
    from /Users/hnguyen/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'
hnguyen@taengoo:~/work/fundly ಠ_ಠ >> 
Santiago Pastorino

Try the same thing in a fresh app and without changing the Rakefile. Seems like you're not hitting this same issue.

Huy Nguyen

A fresh app worked, after hours tracked it down to a gem. Sorry :X

Santiago Pastorino

No worries ;)

Benjamin Fritsch

just fyi: shoulda (>= 3.0.0.beta) causes the same error, remove it from your Gemfile and it works (at least for me)

Huy Nguyen

The shoulda was also the gem I tracked it down to in my project as well. I was using rspec and NOT test-unit. The correct thing to do was to use shoulda-matcher gem instead.

Gourav Tiwari

I see this issue with shoulda 3.0.1 as well

I had this same issue and fixed it by using shoulda-matchers in Gemfile instead of shoulda.

Jonathan Hyman

@RKushnir, same here. Removing shoulda fixed it for me.

Philip Hale
hale commented April 25, 2012

Instead of removing it entirely, you can change your Gemfile to gem 'shoulda', :require => false and then put in your spec_helper.rb file require 'shoulda'

Daniel Harrington
rubiii commented May 29, 2012

one year later this is still a problem for us and neither removing shoulda nor using rake master fixes the problem.
using the test/unit gem works, but it unfortunately causes new problems. so i guess i'll keep investigating ...

Bruno Coelho

It is also a problem to me. I think the easiest way is to do what @hale said.

Jarl Friis

@hale, thank you very much for your workaround (gem 'shoulda', :require => false), that solved it for me... Has anyone reported this to the shoulda guys?

Nathan Lee X0nic referenced this issue from a commit in nerab/dropcaster January 05, 2014
Nathan Lee upgrade rake.
Previous issue with 0.9 has been resolved.
jimweirich/rake#51
3b92af1
Gregory Becker igreg referenced this issue from a commit January 24, 2014
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.