diff --git a/test/ruby/test_jit.rb b/test/ruby/test_jit.rb index b20ae881b8..60768812ff 100644 --- a/test/ruby/test_jit.rb +++ b/test/ruby/test_jit.rb @@ -730,19 +730,6 @@ class TestJIT < Test::Unit::TestCase out, err = eval_with_jit(script, verbose: 1, min_calls: min_calls) actual = err.scan(/^#{JIT_SUCCESS_PREFIX}:/).size - # Debugging on CI - if err.include?("error trying to exec 'cc1': execvp: No such file or directory") && RbConfig::CONFIG['CC'].start_with?('gcc') - $stderr.puts "\ntest/ruby/test_jit.rb: DEBUG OUTPUT:" - cc1 = %x`gcc -print-prog-name=cc1`.rstrip - if $?.success? - $stderr.puts "cc1 path: #{cc1}" - $stderr.puts "executable?: #{File.executable?(cc1)}" - $stderr.puts "ls:\n#{IO.popen(['ls', '-la', File.dirname(cc1)], &:read)}" - else - $stderr.puts 'Failed to fetch cc1 path' - end - end - # Make sure that the script has insns expected to be tested used_insns = method_insns(script) insns.each do |insn| @@ -799,11 +786,22 @@ class TestJIT < Test::Unit::TestCase # Run Ruby script with --jit-wait (Synchronous JIT compilation). # Returns [stdout, stderr] def eval_with_jit(env = nil, script, **opts) - stdout, stderr, status = super - assert_equal(true, status.success?, "Failed to run script with JIT:\n#{code_block(script)}\nstdout:\n#{code_block(stdout)}\nstderr:\n#{code_block(stderr)}") + stdout, stderr = nil, nil + # retry 3 times while cc1 error happens. + 3.times do |i| + stdout, stderr, status = super + assert_equal(true, status.success?, "Failed to run script with JIT:\n#{code_block(script)}\nstdout:\n#{code_block(stdout)}\nstderr:\n#{code_block(stderr)}") + break unless retried_stderr?(stderr) + end [stdout, stderr] end + # We're retrying cc1 not found error on gcc, which should be solved in the future but ignored for now. + def retried_stderr?(stderr) + RbConfig::CONFIG['CC'].start_with?('gcc') && + stderr.include?("error trying to exec 'cc1': execvp: No such file or directory") + end + def code_block(code) "```\n#{code}\n```\n\n" end