Hi Mat,
It seems some callbacks have changed in rspec 1.2.8 (or recent version)
which broke our custom report handler. I have something working with rspec
now but JtestR fails... I'm attaching my current patch in case that's
helpful to you.
alex
On Wed, Sep 30, 2009 at 8:17 AM, Mat Schaffer <[email protected]> wrote:
> So yet more questions. I'm still working on getting buildr working for the
> java-mateview component of redcar. I separated it out into an "api" project
> which contains just the java and junit tests and a "specs" project which
> contains the rspecs used to test ruby integration. The problem now is that
> although everything appears to load correctly, the rspec portion just shows:
> "0 examples, 0 failures" and I get an error that seems to be triggered by an
> empty result.yaml.
>
> I get the same behavior when running the full java command (from running
> with --trace) or jruby target/spec/runner.rb from the specs folder. I also
> tried putting a raise in one of the ..._spec.rb file and that worked, so it
> seems like the specs are getting loaded just not executed.
>
> This is jruby 1.4.0dev (same behavior on 1.3.1), buildr-1.3.4-java,
> rspec-1.2.8. I'm going to try a simple jruby+rspec test to see if maybe
> there's a problem there, but I suspect it has something to do with how
> runner.rb is getting constructed.
>
> Source is up at http://github.com/matschaffer/java-mateview. Thanks in
> advance for any assistance or ideas.
> -Mat
Index: lib/buildr/java/test_result.rb
===================================================================
--- lib/buildr/java/test_result.rb (revision 820094)
+++ lib/buildr/java/test_result.rb (working copy)
@@ -68,43 +68,28 @@
module_eval "def #{meth}(*args); end"
end
- def add_example_group(example_group)
+ def example_group_started(example_group)
@example_group = example_group
end
def example_passed(example)
+ result.succeeded << example_group.location.gsub(/:\d+$/, '')
end
def example_pending(example, counter, failure)
+ result.succeeded << example_group.location.gsub(/:\d+$/, '')
end
def example_failed(example, counter, failure)
- if example_group.respond_to?(:spec_path)
- result.failed << example_group.spec_path.gsub(/:\d+$/, '')
- else
- path = path_from_bt(failure.exception.backtrace)
- result.failed << path if path
- end
+ result.failed << example_group.location.gsub(/:\d+$/, '')
end
def start(example_count)
@result = TestResult.new
end
- def path_from_bt(ary)
- files = options.files
- test = nil
- ary.find do |bt|
- bt = bt.split(':').first.strip
- test = bt if files.include?(bt)
- end
- test
- end
-
def close
- files = options.files
- result.succeeded = files - result.failed
-
+ result.succeeded = result.succeeded - result.failed
FileUtils.mkdir_p File.dirname(where)
File.open(where, 'w') { |f| f.puts YAML.dump(result) }
end
@@ -192,7 +177,7 @@
else
example_group.description = name.to_s
end
- reporter.add_example_group(example_group)
+ reporter.example_group_started(example_group)
end
def starting
@@ -228,23 +213,26 @@
def succeed_single(name = nil)
#puts "SUCC SINGLE #{name}"
- reporter.example_finished(current_example, nil)
+ reporter.example_passed(current_example, nil)
end
def fail_single(name = nil)
#puts "FAIL SINGLE #{name}"
- reporter.example_finished(current_example, current_error)
+ reporter.example_failed(current_example, current_error)
end
def error_single(name = nil)
#puts "ERR SINGLE #{name}"
- reporter.example_finished(current_example, current_error)
+ reporter.example_failed(current_example, current_error)
end
def pending_single(name = nil)
#puts "PEND SINGLE #{name}"
error = ::Spec::Example::ExamplePendingError.new(name)
- reporter.example_finished(current_example, error)
+ reporter.example_passed(current_example, error)
+ end
+
+ def example_started(example)
end
private
Index: lib/buildr/java/bdd.rb
===================================================================
--- lib/buildr/java/bdd.rb (revision 820094)
+++ lib/buildr/java/bdd.rb (working copy)
@@ -48,7 +48,7 @@
module TestFramework::JRubyBased
extend self
- VERSION = '1.1.6'
+ VERSION = '1.3.1'
class << self
def version
@@ -267,7 +267,8 @@
argv.push *<%= tests.inspect %>
parser.order!(argv)
$rspec_options = parser.options
- Buildr::TestFramework::TestResult::Error.guard('<%= runner.file %>') do
+
+ Buildr::TestFramework::TestResult::Error.guard('<%= runner.result %>')
do
::Spec::Runner::CommandLine.run($rspec_options)
end
exit 0 # let buildr figure the result from the yaml file
@@ -299,7 +300,7 @@
include TestFramework::JRubyBased
- VERSION = '0.3.1'
+ VERSION = '0.4.0'
# pattern for rspec stories
STORY_PATTERN = /_(steps|story)\.rb$/