29
29
end
30
30
end
31
31
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
+
32
50
describe "--coverage" do
33
51
before :each do
34
52
@file = tmp ( "main.rb" )
43
61
out = ruby_exe ( @file , options : "--coverage" )
44
62
out . should =~ /#{ Regexp . escape @file } .+100(\. \d *)?%/
45
63
out . should . include? ( "42" )
46
- $?. should . success?
47
64
end
48
65
49
66
it "works for internal sources" do
50
67
out = ruby_exe ( @file , options : "--coverage --experimental-options --coverage.TrackInternal" )
51
68
out . should =~ /#{ Regexp . escape @file } .+100(\. \d *)?%/
52
69
out . should . include? ( "42" )
53
- $?. should . success?
54
70
end
55
71
end
56
72
@@ -70,9 +86,27 @@ def foo
70
86
RUBY
71
87
out = ruby_exe ( code , options : "--cpusampler" )
72
88
out . should . include? ( ":kill" )
89
+ out . should . include? ( "Sampling Histogram" )
73
90
out . should . include? ( "Kernel#loop" )
74
91
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" )
76
110
end
77
111
end
78
112
end
0 commit comments