Rake gives Command failed with status (1):

What happens if you run one of the tests explicitly, for example ruby -I test test/unit/comment_test.rb

That is a capital i in -I test, telling ruby to include the test folder.

Otherwise I am getting out of my depth I think. Can anyone else suggest what the problem may be?

Colin

From the stack trace, it does look like it's failing at story_test (unless that list of test files includes every single test in the directory...). As an extension of Colin's suggestion to run one test; what if you remove the story_test.rb file from the directory to test running everything *apart* from that.

If it works without the story_test, I'd guess there's something in there that's making it not parse...

Does any of this help?

Michael Pavling wrote in post #962835:

What happens if you run one of the tests explicitly, for example ruby -I test test/unit/comment_test.rb

neil@baby6:~/*****$ ruby -I test test/unit/comment_test.rb ruby index.rb <data dir> <index dir> neil@baby6:~/*****$

As an extension of Colin's suggestion to run one test; what if you remove the story_test.rb file from the directory to test running everything *apart* from that.

That gives

/usr/bin/ruby1.8 -I"lib:test" "/usr/lib/ruby/1.8/rake/rake_test_loader.rb" "test/unit/comment_test.rb" "test/unit/user_mailer_test.rb" "test/unit/friendship_test.rb" "test/unit/helpers/friendship_helper_test.rb" "test/unit/helpers/profile_helper_test.rb" "test/unit/helpers/community_helper_test.rb" "test/unit/user_test.rb" ruby index.rb <data dir> <index dir> rake aborted! Command failed with status (1): [/usr/bin/ruby1.8 -I"lib:test" "/usr/lib/ru...]

(See full trace by running task with --trace) neil@baby6:~/wagging_tales$

Is that all? What on earth is that about? What if you try one of the other tests?

Colin

Colin Law wrote in post #962842:

What happens if you put a trivial ruby program there and try and run it? Make a file test/unit/puts.rb and in it put just one line

puts "hello"

then run it

ruby test/unit/puts.rb

If that works (display hello obviously) then it is something about your test files. Empty one of the test files, and gradually build it back up until it starts to fail. That will hopefully give us a clue as to what is going on.

Colin

If that works (display hello obviously) then it is something about your test files. Empty one of the test files, and gradually build it back up until it starts to fail. That will hopefully give us a clue as to what is going on.

Colin

It did work. I've removed all the tests except story_test.rb which looks like

require 'test_helper'

class StoryTest < ActiveSupport::TestCase   def test_should_be_valid_with_author     s = Story.create(:author => 'neil', :title => 'Story', :body => 'test')     assert s.errors.on(:author)   end end

I get the same error as before until I remove the line

unit/story_test.rb

If I run

ruby test/unit/story_test.rb

I get

test/unit/story_test.rb:1:in `require': no such file to load -- test_helper (LoadError)   from test/unit/story_test.rb:1

Could this be the problem, why can't it find test_helper.rb

Gleble

If that works (display hello obviously) then it is something about your test files. Empty one of the test files, and gradually build it back up until it starts to fail. That will hopefully give us a clue as to what is going on.

Colin

It did work. I've removed all the tests except story_test.rb which looks like

require 'test_helper'

class StoryTest < ActiveSupport::TestCase def test_should_be_valid_with_author s = Story.create(:author => 'neil', :title => 'Story', :body => 'test') assert s.errors.on(:author) end end

I get the same error as before until I remove the line

unit/story_test.rb

What do you mean remove that line? I don't see that line in the file anywhere.

If I run

ruby test/unit/story_test.rb

I get

test/unit/story_test.rb:1:in `require': no such file to load -- test_helper (LoadError) from test/unit/story_test.rb:1

Could this be the problem, why can't it find test_helper.rb

You get that because with the require 'test_helper' line you need to tell ruby where to find it, as we did previously

ruby -I test test/unit/story_test.rb

The -I test tells it to include (-I) the folder test in it's search. When you do rake test it does the -I for you.

Can you post the contents of test/test_helper.rb

Also try removing everything from story_test.rb except the test_helper line and try to run that (with the -I test) in the ruby call.

Colin Law wrote in post #962924:

I get the same error as before until I remove the line

unit/story_test.rb

What do you mean remove that line? I don't see that line in the file anywhere.

Sorry, should read I get the same error as before until I remove the line

require 'test_helper'

If I edit story_test.rb so it only contains require 'test_helper' this happens

neil@baby6:~/*****$ ruby -I test test/unit/story_test.rb ruby index.rb <data dir> <index dir> neil@baby6:~/*****$

Attachments: http://www.ruby-forum.com/attachment/5431/test_helper.rb http://www.ruby-forum.com/attachment/5432/story_test.rb

Sorry wrong attachment

Attachments: http://www.ruby-forum.com/attachment/5433/story_test.rb

I see that requires test_help. Please post that also. Did you not think I might have wanted to see that also? Just post it inline unless it is large.

You have not mentioned it but I presume your app runs ok? If not then post environment.rb also.

Colin

Colin Law wrote in post #962955:

I've attached test_help.rb Had to go to /vendor/railties/lib to find it, is that right?

You have not mentioned it but I presume your app runs ok? If not then post environment.rb also.

Yes it works fine.

Gleble

Attachments: http://www.ruby-forum.com/attachment/5434/test_help.rb

Colin Law wrote in post #962955:

I've attached test_help.rb Had to go to /vendor/railties/lib to find it, is that right?

> You have not mentioned it but I presume your app runs ok? If not then > post environment.rb also.

Yes it works fine.

My guess is that somewhere in your app you have a ruby script (probably called index.rb) that expects to be invoked on the command line with some arguments.When rails loads up your tests it loads everything in app/models, app/controllers (and probably a few other places) and ends up loading your index.rb script, which blows up since it wasn't provided with the arguments it expects.

Fred

Just what I was about to suggest. Well that's my story anyway :slight_smile:

It is amazing how something that seems obvious once pointed out can be so elusive.

Colin

Frederick Cheung wrote in post #962968:

Yes it works fine.

My guess is that somewhere in your app you have a ruby script (probably called index.rb) that expects to be invoked on the command line with some arguments. Fred

I think you've got it, that gets rid of the line

ruby index.rb <data dir> <index dir>

which I think was the problem. Thanks everyone.

When I run rake test:units now I get

(See full trace by running task with --trace) neil@baby6:~/*****$ rake test:units (in /home/neil/******) /usr/bin/ruby1.8 -I"lib:test" "/usr/lib/ruby/1.8/rake/rake_test_loader.rb" "test/unit/story_test.rb" Loaded suite /usr/lib/ruby/1.8/rake/rake_test_loader Started E Finished in 0.411785 seconds.

  1) Error: test_should_be_valid_with_story(StoryTest): ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: avatars: DELETE FROM "avatars" WHERE 1=1

....

1 tests, 0 assertions, 0 failures, 1 errors rake aborted! Command failed with status (1): [/usr/bin/ruby1.8 -I"lib:test" "/usr/lib/ru...]

(See full trace by running task with --trace)

So I think I just have to sort my tests out now.

Gleble

For the record can you tell us where the offending file was? Was it called index.rb?

Colin

Colin Law wrote in post #963001:

ruby index.rb <data dir> <index dir>

which I think was the problem. Thanks everyone.

For the record can you tell us where the offending file was? Was it called index.rb?

Colin

It was called index.rb. There was one in app/controllers and one in app/models. I've attached the offending file. This morning they have both come back and cause the same problem. Removing them makes all OK.   Have you any idea what the file is? Have you any idea how to stop it coming back?

Gleble

Attachments: http://www.ruby-forum.com/attachment/5435/index.rb

I suggest watching to find what it is you do that makes them come back. Looking at the file, presumably it is something to do with Ferret.

Colin