Skip to content

Commit 3058b24

Browse files
committed
[GR-48376] Increase specs timeout and TimeoutAction improvements
PullRequest: truffleruby/4052
2 parents 222e551 + 86fff42 commit 3058b24

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

spec/mspec/lib/mspec/runner/actions/timeout.rb

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ def start
4848

4949
show_backtraces
5050
if MSpec.subprocesses.empty?
51-
exit 2
51+
exit! 2
5252
else
5353
# Do not exit but signal the subprocess so we can get their output
5454
MSpec.subprocesses.each do |pid|
55-
Process.kill :SIGTERM, pid
55+
kill_wait_one_second :SIGTERM, pid
56+
hard_kill :SIGKILL, pid
5657
end
5758
@fail = true
5859
@current_state = nil
@@ -80,7 +81,7 @@ def after(state = nil)
8081

8182
if @fail
8283
STDERR.puts "\n\nThe last example #{@error_message}. See above for the subprocess stacktrace."
83-
exit 2
84+
exit! 2
8485
end
8586
end
8687

@@ -89,12 +90,28 @@ def finish
8990
@thread.join
9091
end
9192

93+
private def hard_kill(signal, pid)
94+
begin
95+
Process.kill signal, pid
96+
rescue Errno::ESRCH
97+
# Process already terminated
98+
end
99+
end
100+
101+
private def kill_wait_one_second(signal, pid)
102+
begin
103+
Process.kill signal, pid
104+
sleep 1
105+
rescue Errno::ESRCH
106+
# Process already terminated
107+
end
108+
end
109+
92110
private def show_backtraces
93111
java_stacktraces = -> pid {
94112
if RUBY_ENGINE == 'truffleruby' || RUBY_ENGINE == 'jruby'
95113
STDERR.puts 'Java stacktraces:'
96-
Process.kill :SIGQUIT, pid
97-
sleep 1
114+
kill_wait_one_second :SIGQUIT, pid
98115
end
99116
}
100117

@@ -118,8 +135,7 @@ def finish
118135

119136
if RUBY_ENGINE == 'truffleruby'
120137
STDERR.puts "\nRuby backtraces:"
121-
Process.kill :SIGALRM, pid
122-
sleep 1
138+
kill_wait_one_second :SIGALRM, pid
123139
else
124140
STDERR.puts "Don't know how to print backtraces of a subprocess on #{RUBY_ENGINE}"
125141
end

spec/truffle/thread/status_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@
2929
regexp =~ string
3030
end
3131

32+
saw_status = false
3233
while status = t.status
34+
saw_status = true
3335
status.should == "run"
3436
Thread.pass
3537
end
3638
t.join
39+
40+
skip 'unfair scheduling' unless saw_status
3741
end
3842

3943
end

test/mri/tests/lib/envutil.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ def capture_global_values
6161
end
6262
end
6363

64-
# TruffleRuby: startup can take longer, especially on highly loaded CI machines
65-
self.timeout_scale = 3 if defined?(::TruffleRuby)
64+
# TruffleRuby: startup can take longer, especially on highly loaded CI machines.
65+
# Note that EnvUtil.invoke_ruby has a timeout of 10 seconds * the scale.
66+
# We use 60 * 10 = 600s which is the same as the timeout for ruby/spec in jt.rb.
67+
self.timeout_scale = 60 if defined?(::TruffleRuby)
6668

6769
def apply_timeout_scale(t)
6870
if scale = EnvUtil.timeout_scale

tool/jt.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ def mspec(*args)
16821682
options += %w[--excl-tag slow]
16831683
end
16841684

1685-
options += %w[--timeout 300] if ci?
1685+
options += %w[--timeout 600] if ci?
16861686

16871687
args, ruby_args = args_split(args)
16881688
vm_args, ruby_args, parsed_options = ruby_options({}, ['--reveal', *ruby_args])

0 commit comments

Comments
 (0)