buildr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Assaf Arkin" <ar...@intalio.com>
Subject Re: svn commit: r702225 - in /incubator/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 Mon, 06 Oct 2008 19:01:47 GMT
On Mon, Oct 6, 2008 at 11:46 AM,  <vborja@apache.org> wrote:
> -      runner.gems.update 'rspec' => '>0'
> +      runner.gems.update 'rspec' => '>= 1.1.5'

This is guaranteed to fail when you get a new version of RSpec via gem
update, but it's broken/breaking, yet gets picked up for being newer
than 1.1.5.  For example, on my machine it picks RSpec 1.1.8.

If this is happening in the forked process, you can get all the right
dependencies set up at once by doing:

gem 'buildr', {Buildr::VERSION}

That would require some hack to support the test cases, though.

Assaf


>       runner.requires.unshift 'spec', 'jtestr'
>       runner
>     end
>
> Modified: incubator/buildr/trunk/lib/buildr/java/jtestr_runner.rb.erb
> URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/jtestr_runner.rb.erb?rev=702225&r1=702224&r2=702225&view=diff
> ==============================================================================
> --- incubator/buildr/trunk/lib/buildr/java/jtestr_runner.rb.erb (original)
> +++ incubator/buildr/trunk/lib/buildr/java/jtestr_runner.rb.erb Mon Oct  6 11:46:55 2008
> @@ -100,6 +100,16 @@
>   argv = <%= runner.rspec.inspect %> || []
>   argv.push *<%= tests.inspect %>
>   Buildr::TestFramework::TestResult::RSpecResultHandler.init(argv, output, output)
> +
> +  # JtestR uses this method, no longer on rspec
> +  module ::Spec; def self.run=(flag); end; end
> +  # JtestR uses a deprecated arity, so to complain with latest version we override it
> +  class ::JtestR::RSpecResultHandler
> +    alias_method :deprecated_example_pending, :example_pending
> +    def example_pending(example, message, pending_caller)
> +      deprecated_example_pendng(example, message)
> +    end
> +  end
>
>   jtestr.run *args
>
> @@ -107,6 +117,8 @@
>   Buildr::TestFramework::TestResult::Error.dump_yaml('<%= runner.result %>', e)
rescue \
>   puts "-[--- ERROR ---]-", e.class, e.message, *e.backtrace
>  end
> +
> +exit 0 # let buildr find the erros from the result yaml
>
>  # Local Variables:
>  # mode: ruby
>
> Modified: incubator/buildr/trunk/lib/buildr/java/test_result.rb
> URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/test_result.rb?rev=702225&r1=702224&r2=702225&view=diff
> ==============================================================================
> --- incubator/buildr/trunk/lib/buildr/java/test_result.rb (original)
> +++ incubator/buildr/trunk/lib/buildr/java/test_result.rb Mon Oct  6 11:46:55 2008
> @@ -27,6 +27,7 @@
>         def initialize(message, backtrace)
>           @message = message
>           @backtrace = backtrace
> +          set_backtrace backtrace
>         end
>
>         def self.dump_yaml(file, e)
> @@ -59,9 +60,12 @@
>         def initialize(options, where)
>           @options = options
>           @where = where
> +          @result = Hash.new
> +          @result[:succeeded] = []
> +          @result[:failed] = []
>         end
>
> -        %w[ example_started example_passed example_failed example_pending
> +        %w[ example_started
>             start_dump dump_failure dump_summary dump_pending ].each do |meth|
>           module_eval "def #{meth}(*args); end"
>         end
> @@ -70,24 +74,38 @@
>           @example_group = example_group
>         end
>
> +        def example_passed(example)
> +        end
> +
> +        def example_pending(example, counter, failure)
> +        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
> +        end
> +
>         def start(example_count)
>           @result = TestResult.new
>         end
>
> -        def close
> +        def path_from_bt(ary)
>           files = options.files
> -          failure_from_bt = lambda do |ary|
> -            test = nil
> -            ary.find do |bt|
> -              bt = bt.split(':').first.strip
> -              test = bt if files.include?(bt)
> -            end
> -            test
> -          end
> -          options.reporter.instance_variable_get(:@failures).each do |failure|
> -            result.failed << files.delete(failure_from_bt[failure.exception.backtrace])
> +          test = nil
> +          ary.find do |bt|
> +            bt = bt.split(':').first.strip
> +            test = bt if files.include?(bt)
>           end
> -          result.succeeded |= files
> +          test
> +        end
> +
> +        def close
> +          files = options.files
> +          result.succeeded = files - result.failed
>
>           FileUtils.mkdir_p(File.dirname(where))
>           File.open(where, 'w') { |f| f.puts YAML.dump(result) }
> @@ -238,8 +256,21 @@
>             nil
>           when Test::Unit::Failure
>             Error.new(fault.message, fault.location)
> -          when Test::Unit::Error, Expectations::Results::Error, Spec::Runner::Reporter::Failure
> +          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
> +            fault.example.instance_variable_get(:@_implementation).to_s =~ /@(.+:\d+)/
> +            Error.new(ex.message, [$1.to_s] + ex.backtrace)
>           when Expectations::Results
>             file = fault.file
>             line = fault.line
>
> Modified: incubator/buildr/trunk/spec/java/bdd_spec.rb
> URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/java/bdd_spec.rb?rev=702225&r1=702224&r2=702225&view=diff
> ==============================================================================
> --- incubator/buildr/trunk/spec/java/bdd_spec.rb (original)
> +++ incubator/buildr/trunk/spec/java/bdd_spec.rb Mon Oct  6 11:46:55 2008
> @@ -38,7 +38,7 @@
>     failure = File.expand_path('src/spec/ruby/failure_spec.rb')
>     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") { eval("lambda") } }')
> +    write(error, 'describe("error") { it("raises") { lambda; } }')
>     foo do
>       lambda { test.invoke }.should raise_error(/Tests failed/)
>       test.tests.should include(success, failure, error)
> @@ -208,7 +208,7 @@
>       require 'test/unit'
>       class TC_Error < Test::Unit::TestCase
>         def test_error
> -          eval('lambda')
> +          lambda;
>         end
>       end
>     TESTUNIT
> @@ -226,7 +226,7 @@
>     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) { eval("lambda") } }')
> +    write(error, 'Expectations { expect(nil) { lambda; } }')
>     foo do
>       lambda { test.invoke }.should raise_error(/Tests failed/)
>       test.tests.should include(success, failure, error)
> @@ -241,7 +241,7 @@
>     failure = File.expand_path('src/spec/ruby/failure_spec.rb')
>     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") { eval("lambda") } }')
> +    write(error, 'describe("error") { it("raises") { lambda; } }')
>     pending =  File.expand_path('src/spec/ruby/pending_spec.rb')
>     write(pending, 'describe("peding") { it "is not implemented" }')
>     foo do
>
>
>

Mime
View raw message