No, I didn’t have that one, but had one similar problem where one of
my specs edited one non-Ruby file, which caused autotest to reload. I
solved that problem by explicitly ignoring it in autotest. I was
surprised that autotest cares about non-mapped files
But now I have another problem - it seems that autotest doesn’t
understand always when something really failed and it seems to be due
to the fact that autotest.rb has this line:
self.failed_results_re = /^\s+\d+) (?:Failure|Error):\n(.?)((.?)
)/
It doesn’t match correctly with most of the failing specs so Snarl
(like Growl for Windows) shows that tests are passing when they’re
actually not. So, I digged around a little more to see if RSpec
modifies this regular expression somewhere and I found it at lib/
autotest/rspec.rb and there is this class Autotest::Rspec < Autotest,
which overwrites failed_results_re as: self.failed_results_re = /^\d+)
\n(?:\e[\dm)?(?:.?in )?’([^\n])’(?: FAILED)?(?:\e[\dm)?\n(.*?)\n
\n/m
This autotest thing seems to be quite strange, because if I added some
puts statements into discover.rb and rspec.rb then they didn’t seem to
get executed, BUT if I putsed this failed_results_re in autotest.rb
itself, then it was set correctly as written above.
My .autotest file is as following:
require ‘autotest/menu’
require ‘autotest/snarl’
Autotest.add_hook :initialize do |at|
at.add_exception(/.sqlite/)
at.add_exception(/^.git/)
end
And spec.opts is like this:
-r spec/env.rb
-c
And I’m running autospec and seeing this output:
1)
‘correct year’ FAILED
expected “2008”
got “2009”
(compared using eql?)
./spec/year_spec.rb:38:
Finished in 5.918 seconds
11 examples, 1 failure
And when I added to autotest.rb line 410 this: p self.files_to_test
Then the resulted hash was empty, e.g. this line sets result to
“green”: color = completed &&
self.files_to_test.empty? ? :green : :red
When I break some other test with different error message like this,
then Snarl shows me failing tests:
1)
NoMethodError in ‘DatabaseOperations adds options’
undefined method `[]’ for nil:NilClass
./spec/database_operations_spec.rb:50:
The difference is that failing reason is shown on one line, instead of
two lines. Also, p elf.files_to_test results in “normal” result:
{“spec/database_operations_spec.rb”=>[“DatabaseOperations adds
options”, “DatabaseOperations adds new default_options if some are
missing”]}
- Is it possible that this regular expression is little outdated and
can’t handle the situation where failing reason is shown on 2 lines?
- Why won’t anything puts’ed from autotest/discover.rb or autotest/
rspec.rb like they aren’t loaded?
- Any other reasons why autotest behaviour might be broken?
Jarmo