Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > require problem with syntax errors

Reply
Thread Tools

require problem with syntax errors

 
 
David Corbin
Guest
Posts: n/a
 
      07-01-2005
I have written a little "test suite" for my use in developing a rails
application (I know about "rake test_units", but that won't work in my IDE of
choice). So, if I run unitTest.rb, all my tests run.

The problem I'm having, is if I have syntax errors, I still get a green bar
(fewer tests are shown), and there is NO indication of syntax errors, if one
of the required test files has syntax errors.

Help me understand why the there's no trace of syntax error when the required
file has one.

Thanks
David

-- begin unitTestSuite.rb--
require "test_helper"
require "test_builder"

requireAllTests("test/unit/**/*.rb")

--end--
--begin test_builder.rb--
def requireAllTests(pattern)
Dir.glob(pattern).each do |file|
require file
end
end

----





 
Reply With Quote
 
 
 
 
Pit Capitain
Guest
Posts: n/a
 
      07-02-2005
David Corbin schrieb:
> The problem I'm having, is if I have syntax errors, I still get a green bar
> (fewer tests are shown), and there is NO indication of syntax errors, if one
> of the required test files has syntax errors.
>
> Help me understand why the there's no trace of syntax error when the required
> file has one.
>
> def requireAllTests(pattern)
> Dir.glob(pattern).each do |file|
> require file
> end
> end


Hi David,

I haven't looked where this happens, but it seems that test/unit
discards those errors. When this happened to me, I simply catched the
load errors myself and reported them with puts.

You write that you get a green bar, so I assume you're running a
graphical frontend. In this case, I guess a simple puts wouldn't be
enough. You could try the following code, which creates a new TestCase
class for each load error in order to present them as a failing test:

def requireAllTests(pattern)
Dir.glob(pattern).each do |file|
begin
require file
rescue Exception => e
Class.new(Test::Unit::TestCase) do
define_method(:test_load) do ||
flunk("#{file}: #{e}")
end
public :test_load
end
end
end
end

Regards,
Pit


 
Reply With Quote
 
 
 
 
David Corbin
Guest
Posts: n/a
 
      07-02-2005
On Saturday 02 July 2005 01:54 am, Pit Capitain wrote:
> David Corbin schrieb:
> > The problem I'm having, is if I have syntax errors, I still get a green
> > bar (fewer tests are shown), and there is NO indication of syntax errors,
> > if one of the required test files has syntax errors.
> >
> > Help me understand why the there's no trace of syntax error when the
> > required file has one.
> >
> > def requireAllTests(pattern)
> > Dir.glob(pattern).each do |file|
> > require file
> > end
> > end

>
> Hi David,
>
> I haven't looked where this happens, but it seems that test/unit
> discards those errors. When this happened to me, I simply catched the
> load errors myself and reported them with puts.


There don't seem to be any errors raised. I tried the puts, and I do have a
console window, but nothing shows up.

I tried your example too, and get nothing.

David


 
Reply With Quote
 
Pit Capitain
Guest
Posts: n/a
 
      07-03-2005
David Corbin schrieb:
> There don't seem to be any errors raised. I tried the puts, and I do have a
> console window, but nothing shows up.
>
> I tried your example too, and get nothing.


Weird. If you want, you can send your files to my mail address and I'll
have a short look.

Regards,
Pit


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why does catching errors that aren't thrown give syntax errors? yawnmoth Java 97 02-27-2009 12:07 AM
IRB, Mac OS X, command-line require via "-r" and Bus Errors James Adam Ruby 15 05-18-2005 03:10 PM
Require errors for rubygems David Naseby Ruby 1 11-16-2004 11:13 PM
What is PRISM.exe and these application require runtime to terminate in unusual ways errors I just started receiving? Rod Flash Computer Support 0 08-17-2004 04:20 AM
Errors, errors, errors Mark Goldin ASP .Net 2 01-17-2004 08:05 PM



Advertisments