Skip to content

Commit 375db73

Browse files
committed
[GR-32154] Add test for --cpusampler + Thread#kill
(cherry picked from commit ed1b470)
1 parent fc5279d commit 375db73

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

spec/tags/truffle/tools_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
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
4+
slow:Tools --cpusampler works if Thread#kill is used

spec/truffle/tools_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,26 @@
5353
$?.should.success?
5454
end
5555
end
56+
57+
describe "--cpusampler" do
58+
it "works if Thread#kill is used" do
59+
code = <<~RUBY
60+
def foo
61+
n = 0
62+
loop { itself { n += 1 } }
63+
n
64+
end
65+
t = Thread.new { foo }
66+
sleep 1
67+
p :kill
68+
t.kill
69+
t.join
70+
RUBY
71+
out = ruby_exe(code, options: "--cpusampler --cpusampler.Mode=roots")
72+
out.should.include?(":kill")
73+
out.should.include?("block in Object#foo")
74+
out.should_not.include?('KillException')
75+
$?.should.success?
76+
end
77+
end
5678
end

0 commit comments

Comments
 (0)