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

ruby-changes:71035

From: Benoit <ko1@a...>
Date: Fri, 28 Jan 2022 22:43:09 +0900 (JST)
Subject: [ruby-changes:71035] bb5f710887 (master): Update to ruby/mspec@49adc2f

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

From bb5f71088774b14c96fe11718e5e1b7ffb20fff2 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Fri, 28 Jan 2022 14:42:36 +0100
Subject: Update to ruby/mspec@49adc2f

---
 spec/mspec/lib/mspec/helpers/numeric.rb        |  4 +++-
 spec/mspec/lib/mspec/runner/actions/timeout.rb | 29 ++++++++++++++++----------
 spec/mspec/spec/helpers/numeric_spec.rb        | 10 +++++++--
 spec/mspec/tool/remove_old_guards.rb           | 12 +++++++----
 4 files changed, 37 insertions(+), 18 deletions(-)

diff --git a/spec/mspec/lib/mspec/helpers/numeric.rb b/spec/mspec/lib/mspec/helpers/numeric.rb
index db1fde64d8f..c1ed81a2332 100644
--- a/spec/mspec/lib/mspec/helpers/numeric.rb
+++ b/spec/mspec/lib/mspec/helpers/numeric.rb
@@ -9,7 +9,9 @@ def infinity_value https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/helpers/numeric.rb#L9
 end
 
 def bignum_value(plus = 0)
-  0x8000_0000_0000_0000 + plus
+  # Must be >= fixnum_max + 2, so -bignum_value is < fixnum_min
+  # A fixed value has the advantage to be the same numeric value for all Rubies and is much easier to spec
+  (2**64) + plus
 end
 
 def max_long
diff --git a/spec/mspec/lib/mspec/runner/actions/timeout.rb b/spec/mspec/lib/mspec/runner/actions/timeout.rb
index fd5578be877..dddaa250b51 100644
--- a/spec/mspec/lib/mspec/runner/actions/timeout.rb
+++ b/spec/mspec/lib/mspec/runner/actions/timeout.rb
@@ -39,17 +39,7 @@ class TimeoutAction https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/runner/actions/timeout.rb#L39
               STDERR.puts "Example took longer than the configured timeout of #{@timeout}s"
               STDERR.flush
 
-              if RUBY_ENGINE == 'truffleruby'
-                STDERR.puts 'Java stacktraces:'
-                Process.kill :SIGQUIT, Process.pid
-                sleep 1
-
-                if defined?(Truffle::Debug.show_backtraces)
-                  STDERR.puts "\nRuby backtraces:"
-                  Truffle::Debug.show_backtraces
-                end
-              end
-
+              show_backtraces
               exit 2
             end
           end
@@ -70,4 +60,21 @@ class TimeoutAction https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/runner/actions/timeout.rb#L60
     @thread.kill
     @thread.join
   end
+
+  private def show_backtraces
+    if RUBY_ENGINE == 'truffleruby'
+      STDERR.puts 'Java stacktraces:'
+      Process.kill :SIGQUIT, Process.pid
+      sleep 1
+    end
+
+    STDERR.puts "\nRuby backtraces:"
+    if defined?(Truffle::Debug.show_backtraces)
+      Truffle::Debug.show_backtraces
+    else
+      Thread.list.each do |thread|
+        STDERR.puts thread.inspect, thread.backtrace, ''
+      end
+    end
+  end
 end
diff --git a/spec/mspec/spec/helpers/numeric_spec.rb b/spec/mspec/spec/helpers/numeric_spec.rb
index e65f3e86104..64495b72762 100644
--- a/spec/mspec/spec/helpers/numeric_spec.rb
+++ b/spec/mspec/spec/helpers/numeric_spec.rb
@@ -4,11 +4,17 @@ require 'mspec/helpers' https://github.com/ruby/ruby/blob/trunk/spec/mspec/spec/helpers/numeric_spec.rb#L4
 
 RSpec.describe Object, "#bignum_value" do
   it "returns a value that is an instance of Bignum on any platform" do
-    expect(bignum_value).to eq(0x8000_0000_0000_0000)
+    expect(bignum_value).to be > fixnum_max
   end
 
   it "returns the default value incremented by the argument" do
-    expect(bignum_value(42)).to eq(0x8000_0000_0000_002a)
+    expect(bignum_value(42)).to eq(bignum_value + 42)
+  end
+end
+
+RSpec.describe Object, "-bignum_value" do
+  it "returns a value that is an instance of Bignum on any platform" do
+    expect(-bignum_value).to be < fixnum_min
   end
 end
 
diff --git a/spec/mspec/tool/remove_old_guards.rb b/spec/mspec/tool/remove_old_guards.rb
index 718e351e117..67485446bb9 100644
--- a/spec/mspec/tool/remove_old_guards.rb
+++ b/spec/mspec/tool/remove_old_guards.rb
@@ -21,20 +21,24 @@ def remove_guards(guard, keep) https://github.com/ruby/ruby/blob/trunk/spec/mspec/tool/remove_old_guards.rb#L21
       puts file
       lines = contents.lines.to_a
       while first = lines.find_index { |line| line =~ guard }
+        comment = first
+        while comment > 0 and lines[comment-1] =~ /^(\s*)#/
+          comment -= 1
+        end
         indent = lines[first][/^(\s*)/, 1].length
         last = (first+1...lines.size).find { |i|
           space = lines[i][/^(\s*)end$/, 1] and space.length == indent
         }
         raise file unless last
         if keep
-          lines[first..last] = lines[first+1..last-1].map { |l| dedent(l) }
+          lines[comment..last] = lines[first+1..last-1].map { |l| dedent(l) }
         else
-          if first > 0 and lines[first-1] == "\n"
-            first -= 1
+          if comment > 0 and lines[comment-1] == "\n"
+            comment -= 1
           elsif lines[last+1] == "\n"
             last += 1
           end
-          lines[first..last] = []
+          lines[comment..last] = []
         end
       end
       File.binwrite file, lines.join
-- 
cgit v1.2.1


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

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