ruby-changes:63565
From: Yusuke <ko1@a...>
Date: Tue, 10 Nov 2020 07:49:44 +0900 (JST)
Subject: [ruby-changes:63565] 2fed5f0ad8 (master): lib/racc/statetransitiontable.rb: Make the racc output stable
https://git.ruby-lang.org/ruby.git/commit/?id=2fed5f0ad8 From 2fed5f0ad806869139d0e0b1ffc30c517e6baf20 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Mon, 9 Nov 2020 19:49:04 +0900 Subject: lib/racc/statetransitiontable.rb: Make the racc output stable Racc calls `Array#sort!` to build a state transition table. As `Array#sort!` is not a stable sort, the output may differ depending upon the environment. This changeset makes the sort stable manually, and updates all expectation files. diff --git a/lib/racc/statetransitiontable.rb b/lib/racc/statetransitiontable.rb index 5d1288c..78b6da9 100644 --- a/lib/racc/statetransitiontable.rb +++ b/lib/racc/statetransitiontable.rb @@ -231,7 +231,7 @@ module Racc https://github.com/ruby/ruby/blob/trunk/lib/racc/statetransitiontable.rb#L231 map = '-' * 10240 # sort long to short - entries.sort! {|a,b| b[0].size <=> a[0].size } + entries.sort_by!.with_index {|a,i| [-a[0].size, i] } entries.each do |arr, chkval, expr, min, ptri| if upper + arr.size > map.size diff --git a/test/racc/helper.rb b/test/racc/helper.rb index 2862a79..146beb5 100644 --- a/test/racc/helper.rb +++ b/test/racc/helper.rb @@ -86,11 +86,11 @@ 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 unless RUBY_PLATFORM =~ /darwin/ - file = File.basename(asset, '.y') + # Code to re-generate the expectation files + # File.write("#{REGRESS_DIR}/#{file}", File.read("#{@TAB_DIR}/#{file}")) + expected = File.read("#{REGRESS_DIR}/#{file}") actual = File.read("#{@TAB_DIR}/#{file}") result = (strip_version(expected) == strip_version(actual)) diff --git a/test/racc/regress/cadenza b/test/racc/regress/cadenza index b8f9404..dafce3c 100644 --- a/test/racc/regress/cadenza +++ b/test/racc/regress/cadenza @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/test/racc/regress/cadenza#L1 # # DO NOT MODIFY!!!! -# This file is automatically generated by Racc 1.4.16 +# This file is automatically generated by Racc 1.5.0 # from Racc grammar file "". # @@ -17,81 +17,81 @@ module_eval(<<'...end cadenza.y/module_eval...', 'cadenza.y', 171) https://github.com/ruby/ruby/blob/trunk/test/racc/regress/cadenza#L17 ##### State transition tables begin ### racc_action_table = [ - 37, 89, 90, 20, 21, 22, 23, 24, 121, 3, - 89, 4, 72, 37, 71, 3, 68, 39, 3, 29, - 43, 37, 65, 66, 33, 9, 34, 110, 74, 50, - 35, 9, 37, 36, 9, 122, 38, 33, 128, 34, - 77, 78, 79, 35, 89, 33, 36, 34, 37, 38, - 3, 35, 46, 17, 36, 85, 33, 38, 34, 37, - 76, 103, 35, 75, 83, 36, 9, 131, 38, 54, - 55, 3, 33, 4, 34, 124, 78, 79, 35, 65, - 66, 36, 67, 33, 38, 34, 125, 9, 109, 35, - 56, 57, 36, 54, 55, 38, 20, 21, 22, 23, - 24, 20, 21, 22, 23, 24, 20, 21, 22, 23, - 24, 108, 29, 65, 66, 54, 55, 29, 56, 57, - 111, 107, 29, 20, 21, 22, 23, 24, 20, 21, - 22, 23, 24, 20, 21, 22, 23, 24, 112, 29, - 3, 113, 116, 114, 29, 115, 3, 103, 39, 29, - 20, 21, 22, 23, 24, 120, 9, 20, 21, 22, - 23, 24, 9, 3, nil, 4, 29, 3, 3, 43, - 46, nil, 3, 29, 87, 3, 3, 4, 116, 9, - 56, 57, nil, 9, 9, 56, 57, 3, 9, 116, - nil, 9, 9, 20, 21, 22, 23, 24, 20, 21, - 22, 23, 24, 9, 65, 66, 56, 57, nil, 29, - 56, 57, 106, nil, 29, 58, 59, 60, 61, 62, - 63, 58, 59, 60, 61, 62, 63, 20, 21, 22, - 23, 24, 20, 21, 22, 23, 24, 20, 21, 22, - 23, 24, 20, 21, 22, 23, 24, 20, 21, 22, - 23, 24, 20, 21, 22, 23, 24, 20, 21, 22, - 23, 24, 20, 21, 22, 23, 24, 20, 21, 22, - 23, 24, 20, 21, 22, 23, 24, 20, 21, 22, - 23, 24, 56, 57, 65, 66 ] + 37, 89, 65, 66, 20, 21, 22, 23, 24, 17, + 106, 37, 3, 76, 4, 3, 75, 4, 50, 37, + 29, 68, 65, 66, 33, 67, 34, 110, 9, 74, + 35, 9, 37, 36, 71, 33, 38, 34, 77, 78, + 79, 35, 72, 33, 36, 34, 37, 38, 3, 35, + 39, 83, 36, 54, 55, 38, 33, 89, 34, 37, + 90, 3, 35, 43, 9, 36, 85, 103, 38, 108, + 33, 109, 34, 56, 57, 111, 35, 9, 3, 36, + 46, 122, 38, 33, 112, 34, 113, 78, 79, 35, + 114, 3, 36, 4, 9, 38, 20, 21, 22, 23, + 24, 20, 21, 22, 23, 24, 115, 9, 65, 66, + 65, 66, 29, 54, 55, 120, 107, 29, 20, 21, + 22, 23, 24, 20, 21, 22, 23, 24, 20, 21, + 22, 23, 24, 3, 29, 39, 3, 121, 4, 29, + 3, 3, 43, 46, 29, 3, 124, 87, 125, 9, + 54, 55, 9, 56, 57, 128, 9, 9, 3, 103, + 116, 9, 20, 21, 22, 23, 24, 20, 21, 22, + 23, 24, 131, 3, 9, 116, 56, 57, 29, 3, + 89, 116, nil, 29, 20, 21, 22, 23, 24, 9, + 20, 21, 22, 23, 24, 9, 56, 57, 56, 57, + 29, 20, 21, 22, 23, 24, 29, 58, 59, 60, + 61, 62, 63, 56, 57, 56, 57, 29, 58, 59, + 60, 61, 62, 63, 20, 21, 22, 23, 24, 20, + 21, 22, 23, 24, 20, 21, 22, 23, 24, 20, + 21, 22, 23, 24, 20, 21, 22, 23, 24, 20, + 21, 22, 23, 24, 20, 21, 22, 23, 24, 20, + 21, 22, 23, 24, 20, 21, 22, 23, 24, 20, + 21, 22, 23, 24, 20, 21, 22, 23, 24, 65, + 66 ] racc_action_check = [ - 87, 73, 53, 37, 37, 37, 37, 37, 85, 2, - 52, 2, 36, 39, 35, 5, 32, 5, 6, 37, - 6, 46, 51, 51, 87, 2, 87, 73, 37, 17, - 87, 5, 43, 87, 6, 87, 87, 39, 122, 39, - 39, 39, 39, 39, 129, 46, 39, 46, 116, 39, - 7, 46, 7, 1, 46, 46, 43, 46, 43, 4, - 38, 125, 43, 38, 43, 43, 7, 126, 43, 26, - 26, 8, 116, 8, 116, 103, 116, 116, 116, 31, - 31, 116, 31, 4, 116, 4, 105, 8, 72, 4, - 27, 27, 4, 93, 93, 4, 24, 24, 24, 24, - 24, 33, 33, 33, 33, 33, 34, 34, 34, 34, - 34, 71, 24, 70, 70, 94, 94, 33, 95, 95, - 75, 70, 34, 108, 108, 108, 108, 108, 89, 89, - 89, 89, 89, 124, 124, 124, 124, 124, 76, 108, - 118, 77, 118, 78, 89, 79, 41, 67, 41, 124, - 3, 3, 3, 3, 3, 83, 118, 20, 20, 20, - 20, 20, 41, 42, nil, 42, 3, 45, 48, 45, - 48, nil, 49, 20, 49, 0, 82, 0, 82, 42, - 96, 96, nil, 45, 48, 97, 97, 81, 49, 81, - nil, 0, 82, 65, 65, 65, 65, 65, 66, 66, - 66, 66, 66, 81, 69, 69, 98, 98, nil, 65, - 99, 99, 69, nil, 66, 28, 28, 28, 28, 28, - 28, 64, 64, 64, 64, 64, 64, 57, 57, 57, - 57, 57, 29, 29, 29, 29, 29, 58, 58, 58, - 58, 58, 59, 59, 59, 59, 59, 63, 63, 63, - 63, 63, 54, 54, 54, 54, 54, 55, 55, 55, - 55, 55, 56, 56, 56, 56, 56, 61, 61, 61, - 61, 61, 62, 62, 62, 62, 62, 60, 60, 60, - 60, 60, 100, 100, 123, 123 ] + 4, 73, 69, 69, 37, 37, 37, 37, 37, 1, + 69, 39, 0, 38, 0, 2, 38, 2, 17, 43, + 37, 32, 31, 31, 4, 31, 4, 73, 0, 37, + 4, 2, 46, 4, 35, 39, 4, 39, 39, 39, + 39, 39, 36, 43, 39, 43, 87, 39, 5, 43, + 5, 43, 43, 26, 26, 43, 46, 52, 46, 116, + 53, 6, 46, 6, 5, 46, 46, 67, 46, 71, + 87, 72, 87, 27, 27, 75, 87, 6, 7, 87, + 7, 87, 87, 116, 76, 116, 77, 116, 116, 116, + 78, 8, 116, 8, 7, 116, 3, 3, 3, 3, + 3, 20, 20, 20, 20, 20, 79, 8, 70, 70, + 51, 51, 3, 93, 93, 83, 70, 20, 24, 24, + 24, 24, 24, 33, 33, 33, 33, 33, 34, 34, + 34, 34, 34, 41, 24, 41, 42, 85, 42, 33, + 45, 48, 45, 48, 34, 49, 103, 49, 105, 41, + 94, 94, 42, 95, 95, 122, 45, 48, 81, 125, + 81, 49, 65, 65, 65, 65, 65, 66, 66, 66, + 66, 66, 126, 82, 81, 82, 96, 96, 65, 118, + 129, 118, nil, 66, 89, 89, 89, 89, 89, 82, + 108, 108, 108, 108, 108, 118, 97, 9 (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/