Skip to content

Commit 66b641f

Browse files
committed
[GR-47629] Add spec for --cpusampler + Ctrl+C
1 parent 00307c2 commit 66b641f

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

spec/truffle/tools_spec.rb

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@
4343
out = ruby_exe(@file, options: "--coverage")
4444
out.should =~ /#{Regexp.escape @file}.+100(\.\d*)?%/
4545
out.should.include?("42")
46-
$?.should.success?
4746
end
4847

4948
it "works for internal sources" do
5049
out = ruby_exe(@file, options: "--coverage --experimental-options --coverage.TrackInternal")
5150
out.should =~ /#{Regexp.escape @file}.+100(\.\d*)?%/
5251
out.should.include?("42")
53-
$?.should.success?
5452
end
5553
end
5654

@@ -70,9 +68,27 @@ def foo
7068
RUBY
7169
out = ruby_exe(code, options: "--cpusampler")
7270
out.should.include?(":kill")
71+
out.should.include?("Sampling Histogram")
7372
out.should.include?("Kernel#loop")
7473
out.should_not.include?('KillException')
75-
$?.should.success?
74+
end
75+
76+
it "works if interrupted by Ctrl+C" do
77+
code = <<~RUBY
78+
def foo
79+
n = 0
80+
loop { yield_self { n += 1 } }
81+
n
82+
end
83+
Thread.new { foo }
84+
sleep 0.1
85+
Process.kill :INT, Process.pid
86+
sleep
87+
RUBY
88+
out = ruby_exe(code, options: "--cpusampler", args: "2>&1", exit_status: :SIGINT)
89+
out.should.include?('Interrupt (Interrupt)')
90+
out.should.include?("Sampling Histogram")
91+
out.should.include?("Kernel#loop")
7692
end
7793
end
7894
end

0 commit comments

Comments
 (0)