buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boisv...@apache.org
Subject svn commit: r1039804 - in /buildr/trunk: lib/buildr/java/bdd.rb lib/buildr/java/jtestr_runner.rb.erb lib/buildr/java/test_result.rb spec/java/bdd_spec.rb
Date Sun, 28 Nov 2010 00:16:24 GMT
Author: boisvert
Date: Sun Nov 28 00:16:24 2010
New Revision: 1039804

URL: http://svn.apache.org/viewvc?rev=1039804&view=rev
Log:
JtestR specs now passing

Modified:
    buildr/trunk/lib/buildr/java/bdd.rb
    buildr/trunk/lib/buildr/java/jtestr_runner.rb.erb
    buildr/trunk/lib/buildr/java/test_result.rb
    buildr/trunk/spec/java/bdd_spec.rb

Modified: buildr/trunk/lib/buildr/java/bdd.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/bdd.rb?rev=1039804&r1=1039803&r2=1039804&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/bdd.rb (original)
+++ buildr/trunk/lib/buildr/java/bdd.rb Sun Nov 28 00:16:24 2010
@@ -17,7 +17,6 @@
 require 'buildr/java/tests'
 require 'buildr/java/test_result'
 
-
 module Buildr
 
   # Mixin for test frameworks using src/spec/{lang}
@@ -373,7 +372,11 @@ module Buildr
       # so the rspec version used depends on the jtestr jar.
       runner.requires.unshift 'jtestr'
       runner.gems.update 'rspec' => '=1.3.0'
-      runner.requires.unshift 'rspec'
+      runner.requires.unshift 'spec'
+      runner.requires.unshift File.join(File.dirname(__FILE__), 'jtestr_result')
+      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::JtestR::YamlFormatter:#{runner.result}"
       runner
     end
 
@@ -381,10 +384,8 @@ module Buildr
       runner_erb = File.join(File.dirname(__FILE__), 'jtestr_runner.rb.erb')
       Filter::Mapper.new(:erb, binding).transform(File.read(runner_erb), runner_erb)
     end
-
   end
 
-
   # JBehave is a Java BDD framework. To use in your project:
   #   test.using :jbehave
   #
@@ -456,3 +457,4 @@ end
 Buildr::TestFramework << Buildr::RSpec
 Buildr::TestFramework << Buildr::JtestR
 Buildr::TestFramework << Buildr::JBehave
+

Modified: buildr/trunk/lib/buildr/java/jtestr_runner.rb.erb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/jtestr_runner.rb.erb?rev=1039804&r1=1039803&r2=1039804&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/jtestr_runner.rb.erb (original)
+++ buildr/trunk/lib/buildr/java/jtestr_runner.rb.erb Sun Nov 28 00:16:24 2010
@@ -26,7 +26,6 @@
 # <%= user_config %>
 
 begin
-
   <%= jruby_gem %>
   <%= dependencies.map(&:to_s).inspect %>.each { |dep| $CLASSPATH << dep
}
   <%= runner.gems.inspect %>.each { |ary| JRuby.gem(*ary.flatten) }
@@ -87,21 +86,20 @@ begin
      output = STDOUT
   <% end %>
 
-
   args = [ '<%= spec_dir %>', # the directory to search for jtestr files
            JtestR::SimpleLogger::ERR, # log level (DEBUG/WARN/ERR)
            JtestR::GenericResultHandler::QUIET, #output level (QUIET/VERBOSE)
            fake_out, # output STDOUT
            [], # groups to run
            # Use JtestR::GenericResultHandler for debugging
-           Buildr::TestFramework::TestResult::RSpecResultHandler, # result handler
+           Buildr::JtestR::ResultHandler, # result handler
            []  # classpath
          ]
 
   argv = <%= runner.rspec.inspect %> || []
   argv.push *<%= tests.inspect %>
-  Buildr::TestFramework::TestResult::RSpecResultHandler.init(argv, output, output)
-  Buildr::TestFramework::TestResult::RSpecResultHandler.test_files = <%= tests.inspect
%>
+  Buildr::JtestR::ResultHandler.init(argv, output, output)
+  Buildr::JtestR::ResultHandler.test_files = <%= tests.inspect %>
 
   jtestr.run *args
 
@@ -110,7 +108,7 @@ rescue => e
   puts "-[--- ERROR ---]-", e.class, e.message, *e.backtrace
 end
 
-exit 0 # let buildr find the erros from the result yaml
+exit 0 # let buildr find the errors from the result yaml
 
 # Local Variables:
 # mode: ruby

Modified: buildr/trunk/lib/buildr/java/test_result.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/test_result.rb?rev=1039804&r1=1039803&r2=1039804&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/test_result.rb (original)
+++ buildr/trunk/lib/buildr/java/test_result.rb Sun Nov 28 00:16:24 2010
@@ -96,224 +96,6 @@ module Buildr #:nodoc:
         end
       end # YamlFormatter
 
-      # A JtestR ResultHandler
-      # Using this handler we can use RSpec formatters, like html/ci_reporter with JtestR
-      # Created for YamlFormatter
-      class RSpecResultHandler
-
-        # Workaround for http://jira.codehaus.org/browse/JTESTR-68
-        module TestNGResultHandlerMixin
-          def onTestSuccess(test_result)
-            @result_handler.succeed_single(test_result.name)
-          end
-        end
-
-        class BacktraceTweaker
-          attr_reader :ignore_patterns
-          def initialize
-            @ignore_patterns = ::Spec::Runner::QuietBacktraceTweaker::IGNORE_PATTERNS.dup
-            # ignore jruby/jtestr backtrace
-            ignore_patterns << /org\.jruby\.javasupport\.JavaMethod\./
-            ignore_patterns << /jtestr.*\.jar!/i << /runner\.rb/
-          end
-
-          def clean_up_double_slashes(line)
-            line.gsub!('//','/')
-          end
-
-          def tweak_backtrace(error)
-            return if error.backtrace.nil?
-            error.backtrace.collect! do |line|
-              clean_up_double_slashes(line)
-              ignore_patterns.each do |ignore|
-                if line =~ ignore
-                  line = nil
-                  break
-                end
-              end
-              line
-            end
-            error.backtrace.compact!
-          end
-        end
-
-        class << self
-          # an rspec reporter used to proxy events to rspec formatters
-          attr_reader :reporter
-          attr_accessor :test_files
-
-          def init(argv = [], out = STDOUT, err = STDERR)
-            ::JtestR::TestNGResultHandler.module_eval { include TestNGResultHandlerMixin
}
-            rspec_parser = ::Spec::Runner::OptionParser.new(err, out)
-            rspec_parser.order!(argv)
-            rspec_parser.options.backtrace_tweaker = BacktraceTweaker.new
-            @reporter = Spec::Runner::Reporter.new(rspec_parser.options)
-          end
-
-          def before
-            reporter.start(reporter.options.files.size)
-          end
-
-          def after
-            reporter.end
-            reporter.dump
-          end
-
-        end
-
-        module ExampleMethods
-          attr_accessor :name, :description, :__full_description, :location
-        end
-
-        def reporter
-          self.class.reporter
-        end
-
-        attr_accessor :example_group, :current_example, :current_failure
-
-        def initialize(name, desc, *args)
-          self.example_group = ::Spec::Example::ExampleGroup.new(desc)
-          example_group.extend ExampleMethods
-          example_group.name = name.to_s
-          if example_group.name[/Spec/]
-            example_group.description = desc.to_s
-          else
-            example_group.description = name.to_s
-          end
-          reporter.example_group_started(example_group)
-        end
-
-
-        def starting
-        end
-
-        def ending
-        end
-
-        def add_fault(fault)
-          self.current_failure = fault
-        end
-
-        def add_pending(pending)
-        end
-
-        def starting_single(name = nil)
-          self.current_failure = nil
-          self.current_example = Object.new
-          current_example.extend ::Spec::Example::ExampleMethods
-          current_example.extend ExampleMethods
-          name = name.to_s
-          current_example.location = name.to_s
-          current_example.name = name.gsub(/(.*)\((.+)\)/, '\2')
-          current_example.description = name
-          if example_group.name[/Spec/]
-            current_example.__full_description = "#{example_group.description} #{name}"
-          else
-            current_example.__full_description = "#{example_group.name}: #{name}"
-          end
-          reporter.example_started(current_example)
-        end
-
-        def succeed_single(name = nil)
-          reporter.example_finished(current_example, nil)
-        end
-
-        def fail_single(name = nil)
-          current_example.name = current_name
-          reporter.example_finished(current_example, current_error)
-        end
-
-        def error_single(name = nil)
-          current_example.name = current_name
-          reporter.example_finished(current_example, current_error)
-        end
-
-        def pending_single(name = nil)
-          error = ::Spec::Example::ExamplePendingError.new(name)
-          reporter.example_finished(current_example, error)
-        end
-
-      private
-        def detect_file(trace)
-          # find first matching test file in stacktrace
-          file = nil
-          first_pos = nil
-          RSpecResultHandler.test_files.each do |f|
-            pos = trace.index(f)
-            if pos && (first_pos.nil? || pos < first_pos)
-              file = f
-              first_pos = pos
-            end
-          end
-          file || fail("RSpecResultHandler.detect_file failed: #{trace}")
-        end
-
-        def current_name(example = current_example, fault = current_failure)
-          return example.name unless fault
-          case fault
-          when Test::Unit::Error
-            detect_file(fault.long_display)
-          when Test::Unit::Failure
-            detect_file(fault.location.to_s)
-          when Spec::Runner::Reporter::Failure
-            detect_file(fault.exception.backtrace.to_s)
-          else
-            example.name
-          end
-        end
-
-        def current_error(fault = current_failure)
-          case fault
-          when nil
-            nil
-          when Test::Unit::Failure
-            Error.new(fault.message, fault.location)
-          when Test::Unit::Error
-            if fault.exception.is_a?(NativeException)
-              exception = fault.exception.cause
-              bt = exception.stack_trace.to_a
-            else
-              exception = fault.exception
-              bt = exception.backtrace
-            end
-            Error.new(exception.message, bt)
-          when Expectations::Results::Error
-            fault.exception
-          when Spec::Runner::Reporter::Failure
-            ex = fault.exception
-            Error.new(ex.message, ex.backtrace)
-          when Expectations::Results
-            file = fault.file
-            line = fault.line
-            Error.new(fault.message, ["#{fault.file}:#{fault.line}"])
-          else
-            if fault.respond_to?(:test_header)
-              fault.test_header[/\((.+)\)/]
-              test_cls, test_meth = $1.to_s, $`.to_s
-              exception = fault.exception
-              (class << exception; self; end).module_eval do
-                define_method(:backtrace) do
-                  (["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
-                end
-              end
-              exception
-            elsif fault.respond_to?(:method)
-              test_cls, test_meth = fault.method.test_class.name, fault.method.method_name
-              exception = fault.throwable
-              (class << exception; self; end).module_eval do
-                define_method(:backtrace) do
-                  (["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
-                end
-              end
-              exception
-            else
-              raise "Cannot handle fault #{fault.class}: #{fault.inspect}"
-            end
-          end
-        end
-
-      end # RSpecResultHandler
-
     end # TestResult
   end
 end

Modified: buildr/trunk/spec/java/bdd_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/java/bdd_spec.rb?rev=1039804&r1=1039803&r2=1039804&view=diff
==============================================================================
--- buildr/trunk/spec/java/bdd_spec.rb (original)
+++ buildr/trunk/spec/java/bdd_spec.rb Sun Nov 28 00:16:24 2010
@@ -29,7 +29,7 @@ describe Buildr::RSpec do
 
   it 'should read passed specs from result yaml' do
     write('src/spec/ruby/success_spec.rb', 'describe("success") { it("is true") { nil.should
be_nil } }')
-    
+
     project('foo').test.invoke
     project('foo').test.passed_tests.should eql([File.expand_path('src/spec/ruby/success_spec.rb')])
   end
@@ -41,7 +41,7 @@ describe Buildr::RSpec do
     write(failure, 'describe("failure") { it("is false") { true.should == false } }')
     error = File.expand_path('src/spec/ruby/error_spec.rb')
     write(error, 'describe("error") { it("raises") { lambda; } }')
-    
+
     lambda { project('foo').test.invoke }.should raise_error(/Tests failed/)
     project('foo').test.tests.should include(success, failure, error)
     project('foo').test.failed_tests.sort.should eql([failure, error].sort)
@@ -234,7 +234,7 @@ describe Buildr::JtestR do
     failure = File.expand_path('src/spec/ruby/failure_expect.rb')
     write(failure, 'Expectations { expect(true) { false } }')
     error = File.expand_path('src/spec/ruby/error_expect.rb')
-    write(error, 'Expectations { expect(nil) { lambda; } }')
+    write(error, 'Expectations { expect(nil) { lambda {}; } }')
     foo do
       lambda { test.invoke }.should raise_error(/Tests failed/)
       test.tests.should include(success, failure, error)



Mime
View raw message