Skip to content

Commit 63e2696

Browse files
committed
[GR-47629] [GR-50893] Add more tool specs
PullRequest: truffleruby/4105
2 parents 410e95a + cdbd1d9 commit 63e2696

File tree

2 files changed

+40
-3
lines changed

2 files changed

+40
-3
lines changed

spec/tags/truffle/tools_tags.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ slow:Tools --coverage is available and works
22
slow:Tools --coverage works for internal sources
33
slow:Tools --engine.TraceCompilation works and outputs to STDERR
44
slow:Tools --cpusampler works if Thread#kill is used
5+
slow:Tools SIGQUIT shows Java stacktraces
6+
slow:Tools SIGALRM shows Ruby backtraces
7+
slow:Tools --cpusampler works if interrupted by Ctrl+C

spec/truffle/tools_spec.rb

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@
2929
end
3030
end
3131

32+
describe "SIGQUIT" do
33+
it "shows Java stacktraces" do
34+
code = 'Process.kill :SIGQUIT, Process.pid; sleep 1'
35+
out = ruby_exe(code, args: "2>&1")
36+
out.should.include?("Full thread dump")
37+
out.should.include?("RubyLauncher.runRubyMain")
38+
end
39+
end
40+
41+
describe "SIGALRM" do
42+
it "shows Ruby backtraces" do
43+
code = 'Process.kill :SIGALRM, Process.pid; sleep 1'
44+
out = ruby_exe(code, args: "2>&1")
45+
out.should.include?("All Thread and Fiber backtraces:")
46+
out.should.include?(":in `show_backtraces'")
47+
end
48+
end
49+
3250
describe "--coverage" do
3351
before :each do
3452
@file = tmp("main.rb")
@@ -43,14 +61,12 @@
4361
out = ruby_exe(@file, options: "--coverage")
4462
out.should =~ /#{Regexp.escape @file}.+100(\.\d*)?%/
4563
out.should.include?("42")
46-
$?.should.success?
4764
end
4865

4966
it "works for internal sources" do
5067
out = ruby_exe(@file, options: "--coverage --experimental-options --coverage.TrackInternal")
5168
out.should =~ /#{Regexp.escape @file}.+100(\.\d*)?%/
5269
out.should.include?("42")
53-
$?.should.success?
5470
end
5571
end
5672

@@ -70,9 +86,27 @@ def foo
7086
RUBY
7187
out = ruby_exe(code, options: "--cpusampler")
7288
out.should.include?(":kill")
89+
out.should.include?("Sampling Histogram")
7390
out.should.include?("Kernel#loop")
7491
out.should_not.include?('KillException')
75-
$?.should.success?
92+
end
93+
94+
it "works if interrupted by Ctrl+C" do
95+
code = <<~RUBY
96+
def foo
97+
n = 0
98+
loop { yield_self { n += 1 } }
99+
n
100+
end
101+
Thread.new { foo }
102+
sleep 0.1
103+
Process.kill :INT, Process.pid
104+
sleep
105+
RUBY
106+
out = ruby_exe(code, options: "--cpusampler", args: "2>&1", exit_status: :SIGINT)
107+
out.should.include?('Interrupt (Interrupt)')
108+
out.should.include?("Sampling Histogram")
109+
out.should.include?("Kernel#loop")
76110
end
77111
end
78112
end

0 commit comments

Comments
 (0)