[前][次][番号順一覧][スレッド一覧]

ruby-changes:58509

From: Hiroshi <ko1@a...>
Date: Thu, 31 Oct 2019 08:40:07 +0900 (JST)
Subject: [ruby-changes:58509] 1c03026ea3 (master): Try to run assert_output_unchanged with racc tests

https://git.ruby-lang.org/ruby.git/commit/?id=1c03026ea3

From 1c03026ea3cd90cbc37eb4c612aca3c6129032c8 Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Wed, 30 Oct 2019 21:38:55 +0900
Subject: Try to run assert_output_unchanged with racc tests


diff --git a/test/racc/helper.rb b/test/racc/helper.rb
index 744c0a7..d05ba4a 100644
--- a/test/racc/helper.rb
+++ b/test/racc/helper.rb
@@ -2,7 +2,12 @@ verbose = $VERBOSE https://github.com/ruby/ruby/blob/trunk/test/racc/helper.rb#L2
 $VERBOSE = true
 begin
 
-require 'minitest/autorun'
+require 'test/unit'
+begin
+  require_relative './lib/core_assertions'
+  Test::Unit::TestCase.include Test::Unit::CoreAssertions
+rescue LoadError
+end
 require 'racc/static'
 require 'fileutils'
 require 'tempfile'
@@ -71,8 +76,9 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/helper.rb#L76
     end
 
     def assert_exec(asset)
+      lib_path = File.expand_path("../../lib", __FILE__)
       file = File.basename(asset, '.y')
-      ruby("#{@TAB_DIR}/#{file}")
+      ruby "-I#{lib_path}", "#{@TAB_DIR}/#{file}"
     end
 
     def strip_version(source)
@@ -80,6 +86,9 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/helper.rb#L86
     end
 
     def assert_output_unchanged(asset)
+      # racc generates the difference results in GitHub Actions
+      omit if ENV['GITHUB_ACTION']
+
       file = File.basename(asset, '.y')
 
       expected = File.read("#{REGRESS_DIR}/#{file}")
@@ -91,7 +100,8 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/helper.rb#L100
     end
 
     def racc(*arg, **opt)
-      ruby "-S", RACC, *arg, **opt
+      lib_path = File.expand_path("../../lib", __FILE__)
+      ruby "-I#{lib_path}", "-S", RACC, *arg, **opt
     end
 
     def ruby(*arg, **opt)
diff --git a/test/racc/test_racc_command.rb b/test/racc/test_racc_command.rb
index fcbe847..b4fc0c6 100644
--- a/test/racc/test_racc_command.rb
+++ b/test/racc/test_racc_command.rb
@@ -141,13 +141,13 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L141
     end
 
     def test_norule_y
-      assert_raise(MiniTest::Assertion) {
+      assert_raise(Test::Unit::AssertionFailedError) {
         assert_compile 'norule.y'
       }
     end
 
     def test_unterm_y
-      assert_raise(MiniTest::Assertion) {
+      assert_raise(Test::Unit::AssertionFailedError) {
         assert_compile 'unterm.y'
       }
     end
@@ -166,13 +166,13 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L166
     def test_ruby18
       assert_compile 'ruby18.y', [], timeout: 60
       assert_debugfile 'ruby18.y', []
-      # assert_output_unchanged 'ruby18.y'
+      assert_output_unchanged 'ruby18.y'
     end
 
     def test_ruby22
       assert_compile 'ruby22.y', [], timeout: 60
       assert_debugfile 'ruby22.y', []
-      # assert_output_unchanged 'ruby22.y'
+      assert_output_unchanged 'ruby22.y'
     end
 
     # .y file from csspool gem
@@ -180,7 +180,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L180
     def test_csspool
       assert_compile 'csspool.y'
       assert_debugfile 'csspool.y', [5, 3]
-      # assert_output_unchanged 'csspool.y'
+      assert_output_unchanged 'csspool.y'
     end
 
     # .y file from opal gem
@@ -188,7 +188,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L188
     def test_opal
       assert_compile 'opal.y', [], timeout: 60
       assert_debugfile 'opal.y', []
-      # assert_output_unchanged 'opal.y'
+      assert_output_unchanged 'opal.y'
     end
 
     # .y file from journey gem
@@ -196,7 +196,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L196
     def test_journey
       assert_compile 'journey.y'
       assert_debugfile 'journey.y', []
-      # assert_output_unchanged 'journey.y'
+      assert_output_unchanged 'journey.y'
     end
 
     # .y file from nokogiri gem
@@ -204,7 +204,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L204
     def test_nokogiri_css
       assert_compile 'nokogiri-css.y'
       assert_debugfile 'nokogiri-css.y', [0, 1]
-      # assert_output_unchanged 'nokogiri-css.y'
+      assert_output_unchanged 'nokogiri-css.y'
     end
 
     # .y file from edtf-ruby gem
@@ -212,7 +212,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L212
     def test_edtf
       assert_compile 'edtf.y'
       assert_debugfile 'edtf.y', [0, 0, 0, 0, 0]
-      # assert_output_unchanged 'edtf.y'
+      assert_output_unchanged 'edtf.y'
     end
 
     # .y file from namae gem
@@ -220,7 +220,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L220
     def test_namae
       assert_compile 'namae.y'
       assert_debugfile 'namae.y', [0, 0, 0, 0, 0]
-      # assert_output_unchanged 'namae.y'
+      assert_output_unchanged 'namae.y'
     end
 
     # .y file from liquor gem
@@ -228,7 +228,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L228
     def test_liquor
       assert_compile 'liquor.y'
       assert_debugfile 'liquor.y', [0, 0, 0, 0, 15]
-      # assert_output_unchanged 'liquor.y'
+      assert_output_unchanged 'liquor.y'
     end
 
     # .y file from nasl gem
@@ -236,7 +236,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L236
     def test_nasl
       assert_compile 'nasl.y'
       assert_debugfile 'nasl.y', [0, 0, 0, 0, 1]
-      # assert_output_unchanged 'nasl.y'
+      assert_output_unchanged 'nasl.y'
     end
 
     # .y file from riml gem
@@ -244,7 +244,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L244
     def test_riml
       assert_compile 'riml.y'
       assert_debugfile 'riml.y', [289, 0, 0, 0]
-      # assert_output_unchanged 'riml.y'
+      assert_output_unchanged 'riml.y'
     end
 
     # .y file from ruby-php-serialization gem
@@ -252,7 +252,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L252
     def test_php_serialization
       assert_compile 'php_serialization.y'
       assert_debugfile 'php_serialization.y', [0, 0, 0, 0]
-      # assert_output_unchanged 'php_serialization.y'
+      assert_output_unchanged 'php_serialization.y'
     end
 
     # .y file from huia language implementation
@@ -260,7 +260,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L260
     def test_huia
       assert_compile 'huia.y'
       assert_debugfile 'huia.y', [285, 0, 0, 0]
-      # assert_output_unchanged 'huia.y'
+      assert_output_unchanged 'huia.y'
     end
 
     # .y file from cast gem
@@ -268,7 +268,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L268
     def test_cast
       assert_compile 'cast.y'
       assert_debugfile 'cast.y', [0, 0, 0, 0, 1]
-      # assert_output_unchanged 'cast.y'
+      assert_output_unchanged 'cast.y'
     end
 
     # .y file from cadenza gem
@@ -276,7 +276,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L276
     def test_cadenza
       assert_compile 'cadenza.y'
       assert_debugfile 'cadenza.y', [0, 0, 0, 0, 37]
-      # assert_output_unchanged 'cadenza.y'
+      assert_output_unchanged 'cadenza.y'
     end
 
     # .y file from mediacloth gem
@@ -284,7 +284,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L284
     def test_mediacloth
       assert_compile 'mediacloth.y'
       assert_debugfile 'mediacloth.y', [0, 0, 0, 0]
-      # assert_output_unchanged 'mediacloth.y'
+      assert_output_unchanged 'mediacloth.y'
     end
 
     # .y file from twowaysql gem
@@ -292,7 +292,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L292
     def test_twowaysql
       assert_compile 'twowaysql.y'
       assert_debugfile 'twowaysql.y', [4, 0, 0, 0]
-      # assert_output_unchanged 'twowaysql.y'
+      assert_output_unchanged 'twowaysql.y'
     end
 
     # .y file from machete gem
@@ -300,7 +300,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L300
     def test_machete
       assert_compile 'machete.y'
       assert_debugfile 'machete.y', [0, 0, 0, 0]
-      # assert_output_unchanged 'machete.y'
+      assert_output_unchanged 'machete.y'
     end
 
     # .y file from mof gem
@@ -308,7 +308,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L308
     def test_mof
       assert_compile 'mof.y'
       assert_debugfile 'mof.y', [7, 4, 0, 0]
-      # assert_output_unchanged 'mof.y'
+      assert_output_unchanged 'mof.y'
     end
 
     # .y file from tp_plus gem
@@ -316,7 +316,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/test/racc/test_racc_command.rb#L316
     def test_tp_plus
       assert_compile 'tp_plus.y'
       assert_debugfile 'tp_plus.y', [21, 0, 0, 0]
-      # assert_output_unchanged 'tp_plus.y'
+      assert_output_unchanged 'tp_plus.y'
     end
   end
 end
diff --git a/tool/lib/test/unit/core_assertions.rb b/tool/lib/test/unit/core_assertions.rb
index 1c4a254..63d79ae 100644
--- a/tool/lib/test/unit/core_assertions.rb
+++ b/tool/lib/test/unit/core_assertions.rb
@@ -28,6 +28,9 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/core_assertions.rb#L28
         require_relative '../../envutil'
         # for ruby core testing
         include MiniTest::Assertions
+
+        # Compatibility hack for assert_raise
+        Test::Unit::AssertionFailedError = MiniTest::Assertion
       else
         module MiniTest
           class Assertion < Exception; end
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]