You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by bo...@apache.org on 2009/10/04 21:16:34 UTC
svn commit: r821583 - in /buildr/trunk: lib/buildr/java/bdd.rb
lib/buildr/java/test_result.rb spec/java/bdd_spec.rb spec/sandbox.rb
Author: boisvert
Date: Sun Oct 4 19:16:34 2009
New Revision: 821583
URL: http://svn.apache.org/viewvc?rev=821583&view=rev
Log:
Update YamlReporter for rspec 1.2.8 and fork JtestRYamlReport to maintain compatibility with JtestR 0.3.1
Modified:
buildr/trunk/lib/buildr/java/bdd.rb
buildr/trunk/lib/buildr/java/test_result.rb
buildr/trunk/spec/java/bdd_spec.rb
buildr/trunk/spec/sandbox.rb
Modified: buildr/trunk/lib/buildr/java/bdd.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/bdd.rb?rev=821583&r1=821582&r2=821583&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/bdd.rb (original)
+++ buildr/trunk/lib/buildr/java/bdd.rb Sun Oct 4 19:16:34 2009
@@ -109,7 +109,7 @@
if Exception === result
raise [result.message, result.backtrace].flatten.join("\n")
end
- result.succeeded
+ tests - result.failed
end
def jruby_home
@@ -201,9 +201,13 @@
runner.gems ||= {}
runner.rspec ||= ['--format', 'progress', '--format', "html:#{runner.html_report}"]
runner.format.each { |format| runner.rspec << '--format' << format } if runner.format
- runner.rspec.push '--format', "Buildr::TestFramework::TestResult::YamlFormatter:#{runner.result}"
+ runner.rspec.push '--format', "#{runner_formatter}:#{runner.result}"
runner
- end
+ end
+
+ def runner_formatter
+ "Buildr::TestFramework::TestResult::YamlFormatter"
+ end
end
@@ -379,6 +383,10 @@
Filter::Mapper.new(:erb, binding).transform(File.read(runner_erb), runner_erb)
end
+ def runner_formatter
+ 'Buildr::TestFramework::TestResult::JtestRYamlFormatter'
+ end
+
end
Modified: buildr/trunk/lib/buildr/java/test_result.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/test_result.rb?rev=821583&r1=821582&r2=821583&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/test_result.rb (original)
+++ buildr/trunk/lib/buildr/java/test_result.rb Sun Oct 4 19:16:34 2009
@@ -68,6 +68,53 @@
module_eval "def #{meth}(*args); end"
end
+ 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)
+ result.failed << example_group.location.gsub(/:\d+$/, '')
+ end
+
+ def start(example_count)
+ @result = TestResult.new
+ end
+
+ def close
+ result.succeeded = result.succeeded - result.failed
+ FileUtils.mkdir_p File.dirname(where)
+ File.open(where, 'w') { |f| f.puts YAML.dump(result) }
+ end
+ end # YamlFormatter
+
+ # Rspec formatter used for JtestR
+ # (JtestR provides its own version of rspec)
+ class JtestRYamlFormatter
+ attr_reader :result
+
+ attr_accessor :example_group, :options, :where
+
+ def initialize(options, where)
+ @options = options
+ @where = where
+ @result = Hash.new
+ @result[:succeeded] = []
+ @result[:failed] = []
+ end
+
+ %w[ example_started
+ start_dump dump_failure dump_summary dump_pending ].each do |meth|
+ module_eval "def #{meth}(*args); end"
+ end
+
def add_example_group(example_group)
@example_group = example_group
end
@@ -108,7 +155,7 @@
FileUtils.mkdir_p File.dirname(where)
File.open(where, 'w') { |f| f.puts YAML.dump(result) }
end
- end # YamlFormatter
+ end # JtestRYamlFormatter
# A JtestR ResultHandler
# Using this handler we can use RSpec formatters, like html/ci_reporter with JtestR
Modified: buildr/trunk/spec/java/bdd_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/java/bdd_spec.rb?rev=821583&r1=821582&r2=821583&view=diff
==============================================================================
--- buildr/trunk/spec/java/bdd_spec.rb (original)
+++ buildr/trunk/spec/java/bdd_spec.rb Sun Oct 4 19:16:34 2009
@@ -60,6 +60,15 @@
describe Buildr::JtestR do
+ before do
+ # JtestR currently requires JUnit 4.4
+ Buildr.settings.build['junit'] = '4.4'
+
+ # clear cached dependencies
+ Buildr::JUnit.instance_eval { @dependencies = nil }
+ Buildr::JtestR.instance_eval { @dependencies = nil }
+ end
+
def foo(*args, &prc)
define('foo', *args) do
test.using :jtestr, :output => false
@@ -261,6 +270,12 @@
end
end
+ after do
+ # reset to default
+ Buildr.settings.build['junit'] = nil
+ Buildr::JUnit.instance_eval { @dependencies = nil }
+ Buildr::JtestR.instance_eval { @dependencies = nil }
+ end
end if RUBY_PLATFORM =~ /java/ || ENV['JRUBY_HOME'] # JtestR
Modified: buildr/trunk/spec/sandbox.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/sandbox.rb?rev=821583&r1=821582&r2=821583&view=diff
==============================================================================
--- buildr/trunk/spec/sandbox.rb (original)
+++ buildr/trunk/spec/sandbox.rb Sun Oct 4 19:16:34 2009
@@ -29,6 +29,8 @@
artifacts(TestFramework.frameworks.map(&:dependencies).flatten, JUnit.ant_taskdef).each do |path|
file(path).invoke
end
+# JtestR currently requires JUnit 4.4
+file(artifact("junit:junit:jar:4.4")).invoke
ENV['HOME'] = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'home'))