[DRE-commits] [ruby-test-unit-context] 03/04: Make tests run fine

Balasankar C balasankarc-guest at moszumanska.debian.org
Mon Feb 1 11:18:33 UTC 2016


This is an automated email from the git hooks/post-receive script.

balasankarc-guest pushed a commit to branch master
in repository ruby-test-unit-context.

commit 102aaebb6b1216ae24b3c6fe10a2d603a28050ad
Author: Balasankar C <balasankarc at autistici.org>
Date:   Mon Feb 1 15:32:16 2016 +0530

    Make tests run fine
---
 debian/patches/fix-tests.patch | 332 +++++++++++++++++++++++++++++++++++++++++
 debian/patches/series          |   1 +
 2 files changed, 333 insertions(+)

diff --git a/debian/patches/fix-tests.patch b/debian/patches/fix-tests.patch
new file mode 100644
index 0000000..e0e1d0a
--- /dev/null
+++ b/debian/patches/fix-tests.patch
@@ -0,0 +1,332 @@
+Description: Fix tests to run with test-unit ~3.0
+Author: Karol Bucek
+Applied-Upstream: https://github.com/kares/test-unit-context/commit/b75149715c9220fece680179b0d66ba93921ebb5
+Last-Update: 2016-02-01
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/test/test/unit/context/hooks_test.rb
++++ b/test/test/unit/context/hooks_test.rb
+@@ -2,14 +2,14 @@
+ 
+ module Test::Unit::Context
+   class TestHooks < Test::Unit::TestCase
+-    
++
+     class << self; alias_method :it, :test; end
+-    
++
+     setup do
+       @inherited_before_each_var ||= 0
+       @inherited_before_each_var  += 1
+     end
+-    
++
+     attr_reader :inherited_before_each_var
+ 
+     def setup
+@@ -20,29 +20,29 @@
+     end
+ 
+     attr_reader :inherited_before_each_var_2
+-    
++
+     def teardown
+       @inherited_after_each_var ||= 0
+       @inherited_after_each_var  += 1
+     end
+ 
+     attr_reader :inherited_after_each_var
+-    
++
+     startup do
+       @inherited_before_all_var ||= 0
+       @inherited_before_all_var  += 1
+     end
+ 
+     attr_reader :inherited_before_all_var
+-    
++
+     shutdown do
+       @inherited_after_all_var ||= 0
+       @inherited_after_all_var  += 1
+     end
+-  
++
+     attr_reader :inherited_after_all_var
+-    
+-    SAMPLE_TEST = context "hooks" do
++
++    SAMPLE_TEST1 = context "hooks1" do
+ 
+       setup do
+         @inherited_before_each_var ||= 0
+@@ -55,13 +55,17 @@
+       end
+ 
+       attr_reader :after_each_var
+-      
++
+       teardown :a_method
+ 
+       test "foo" do
+         assert :foo
+       end
+-      
++
++      # @override so its not auto-run
++      alias_method :default_run, :run
++      def run(result); result end
++
+     end
+ 
+     setup
+@@ -71,7 +75,7 @@
+     end
+ 
+     attr_reader :superclass_before_each_var
+-    
++
+     teardown
+     def a_teardown
+       @superclass_after_each_var ||= 0
+@@ -79,7 +83,7 @@
+     end
+ 
+     attr_reader :superclass_after_each_var
+-    
++
+     context "with (inherited) setup/teadown hooks" do
+ 
+       it "runs superclass before callbacks in order" do
+@@ -109,48 +113,57 @@
+       it "runs after callbacks specified with method names, instead of blocks" do
+         assert_equal "a method ran", @test.ivar
+       end
+-      
++
+       setup do
+-        @result = Test::Unit::TestResult.new
+-        @test = SAMPLE_TEST.new("test: hooks foo")
+-        @test.run(@result) { |inherited_after_each_var, v| }
++        result = Test::Unit::TestResult.new
++        @test = SAMPLE_TEST1.new("test: foo")
++        @test.default_run(result) { |inherited_after_each_var, v| }
++        verify_result_passed! result
+       end
+-      
++
+     end
+ 
+-    context "with redefined setup/teadown methods" do
++    SAMPLE_TEST2 = context "hooks2" do
+ 
+-      SAMPLE_TEST.class_eval do
+-        OLD_SETUP = instance_method(:setup)
+-        OLD_TEARDOWN = instance_method(:teardown)
+-      end
+-      
+       setup do
+-        SAMPLE_TEST.class_eval do
+-          def setup
+-            @superclass_before_each_var ||= 0
+-            @inherited_before_each_var_2 ||= 9
+-          end
+-          def teardown
+-            @superclass_after_each_var ||= 0
+-          end
+-        end
+-        
+-        @result = Test::Unit::TestResult.new
+-        @test = SAMPLE_TEST.new("test: hooks foo")
+-        @test.run(@result) { |inherited_after_each_var, v| }
++        @inherited_before_each_var ||= 0
++        @inherited_before_each_var  += 4
+       end
+-      
++
+       teardown do
+-        SAMPLE_TEST.class_eval do
+-          remove_method :setup
+-          remove_method :teardown
+-          
+-          define_method(:setup, OLD_SETUP)
+-          define_method(:teardown, OLD_TEARDOWN)
+-        end
++        @after_each_var ||= 0
++        @after_each_var  += 1
++      end
++
++      def setup
++        @superclass_before_each_var ||= 0
++        @inherited_before_each_var_2 ||= 9
++      end
++
++      def teardown
++        @superclass_after_each_var ||= 0
++      end
++
++      attr_reader :after_each_var
++
++      test "foo" do
++        assert :foo
+       end
+-      
++
++      # @override so its not auto-run
++      alias_method :default_run, :run
++      def run(result); result end
++
++    end
++
++    context "with redefined setup/teadown methods" do
++
++      setup do
++        @result = Test::Unit::TestResult.new
++        @test = SAMPLE_TEST2.new("test: foo")
++        @test.default_run(@result) { |inherited_after_each_var, v| }
++      end
++
+       it "runs superclass before callbacks" do
+         assert_equal 1, @test.superclass_before_each_var
+       end
+@@ -158,24 +171,54 @@
+       it "runs superclass after callbacks" do
+         assert_equal 1, @test.superclass_after_each_var
+       end
+-      
++
+       it "does not run inherited (re-defined) setup method" do
+         assert_equal 9, @test.inherited_before_each_var_2
+       end
+-      
++
+       it "runs inherited before callbacks (except previous setup method)" do
+         assert_equal 5, @test.inherited_before_each_var
+       end
+-      
++
+     end
+-    
++
++    SAMPLE_TEST3 = context "hooks3" do
++
++      setup do
++        #puts "hooks3 setup \n  #{caller.join("\n  ")}"
++        @inherited_before_each_var ||= 0
++        @inherited_before_each_var  += 4
++      end
++
++      teardown do
++        @after_each_var ||= 0
++        @after_each_var  += 1
++      end
++
++      attr_reader :after_each_var
++
++      test "foo" do
++        assert :foo
++      end
++
++      # @override so its not auto-run
++      alias_method :default_run, :run
++      def run(result); result end
++
++    end
++
+     # test that we aren't stomping on defined setup method
+     context "with setup/teardown methods" do
+-      
++
++      SAMPLE_TEST3.class_eval { attr_reader :one, :two }
++
+       setup
+       def custom_setup
+-        @result = Test::Unit::TestResult.new
+-        @test = SAMPLE_TEST.new("test: hooks foo")
++
++        #SAMPLE_TEST3.setup { @one = 1 }
++        #SAMPLE_TEST3.teardown { @two = 10 }
++
++        @test = SAMPLE_TEST3.new("test: foo")
+ 
+         @test.class.setup do
+           @one = 1
+@@ -185,55 +228,55 @@
+           @two = 10
+         end
+ 
+-        @test.run(@result) { |inherited_after_each_var, v| }
++        result = Test::Unit::TestResult.new
++        @test.default_run(result) { |inherited_after_each_var, v| }
++        verify_result_passed! result
+       end
+-      
+-      SAMPLE_TEST.class_eval { attr_reader :one, :two }
+-      
++
+       it "runs setup method block a la Shoulda" do
+         assert_equal 1, @test.one
+       end
+ 
+-      it "runs setup method block and regular callbacks" do
+-        assert_equal 7, @test.inherited_before_each_var
+-      end
+-
+       it "runs teardown method block a la Shoulda" do
+         assert_equal 10, @test.two
+       end
+ 
+       it "runs teardown method block and regular callbacks" do
++        assert_equal 7, @test.inherited_before_each_var
+         assert_equal 1, @test.after_each_var
+       end
+-      
++
+     end
+ 
+     def self.startup
+       @superclass_before_all_var ||= 0
+       @superclass_before_all_var  += 1
+     end
+-    
++
+     def self.shutdown
+       @superclass_after_all_var ||= 0
+       @superclass_after_all_var  += 1
+     end
+-    
+-    context "To be compatible with rails' expectations" do
+-      setup :a_method
+-
+-      test "should accept a symbol for an argument to setup and run that method at setup time" do
+-        assert_equal "a method ran", @ivar
+-      end
+-    end
+ 
+     protected
+-    
++
+     attr_reader :ivar
+-    
++
+     def a_method
+       @ivar = "a method ran"
+     end
+-    
++
++    private
++
++    def verify_result_passed!(test_result)
++      unless test_result.passed?
++        #raise test_result.faults[0] if test_result.faults.size == 1
++        #raise "test run failed: #{result.summary}\n#{faults.inspect}"
++        warn "test run failed: #{test_result.summary}\n#{test_result.inspect}"
++        raise test_result.faults.first unless test_result.faults.empty?
++      end
++    end
++
+   end
+-  
++
+ end
+\ No newline at end of file
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..d04b329
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+fix-tests.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-test-unit-context.git



More information about the Pkg-ruby-extras-commits mailing list