summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBenoit Daloze <eregontp@gmail.com>2022-01-28 14:42:36 +0100
committerBenoit Daloze <eregontp@gmail.com>2022-01-28 14:42:36 +0100
commitbb5f71088774b14c96fe11718e5e1b7ffb20fff2 (patch)
treebdb2466448e7b61100169e58e110c047a56d5072 /spec
parentd66e7ec77b0067b113e1b9f584e7f5f741d6cd78 (diff)
Update to ruby/mspec@49adc2f
Diffstat (limited to 'spec')
-rw-r--r--spec/mspec/lib/mspec/helpers/numeric.rb4
-rw-r--r--spec/mspec/lib/mspec/runner/actions/timeout.rb29
-rw-r--r--spec/mspec/spec/helpers/numeric_spec.rb10
-rw-r--r--spec/mspec/tool/remove_old_guards.rb12
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 db1fde64d8..c1ed81a233 100644
--- a/spec/mspec/lib/mspec/helpers/numeric.rb
+++ b/spec/mspec/lib/mspec/helpers/numeric.rb
@@ -9,7 +9,9 @@ def infinity_value
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 fd5578be87..dddaa250b5 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
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
@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 e65f3e8610..64495b7276 100644
--- a/spec/mspec/spec/helpers/numeric_spec.rb
+++ b/spec/mspec/spec/helpers/numeric_spec.rb
@@ -4,11 +4,17 @@ require 'mspec/helpers'
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 718e351e11..67485446bb 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)
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