Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: eb491a784201
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2255c6fcff6f
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Mar 8, 2015

  1. Copy the full SHA
    32ae3eb View commit details
  2. Merge pull request #2664 from bjfish/truffle_spec_tools

    [Truffle] Adding spec running scripts to tools.
    chrisseaton committed Mar 8, 2015
    Copy the full SHA
    2255c6f View commit details
Showing with 110 additions and 0 deletions.
  1. +24 −0 tool/truffle/run_each_core_dir.rb
  2. +86 −0 tool/truffle/run_each_spec.rb
24 changes: 24 additions & 0 deletions tool/truffle/run_each_core_dir.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This script runs 'jt test' on each spec subdirectory of the spec/ruby/core directory.
# Each is run with a 90 second timeout which kills the test process to resolve
# tests that hang.

require 'timeout'

files = Dir.glob("spec/ruby/core/*/")
files.map! {|x| x[0..-2] }

files.each do |file|
command = "ruby tool/jt.rb untag #{file}"
puts "starting process #{command}"
pid = Process.spawn(command)
begin
Timeout.timeout(90) do
puts "waiting for the #{file} process to end"
Process.wait(pid)
puts 'process #{file} finished in time'
end
rescue Timeout::Error
puts "process #{file} not finished in time, killing it"
Process.kill('TERM', pid)
end
end
86 changes: 86 additions & 0 deletions tool/truffle/run_each_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# This script will run 'jt untag' on each spec. If examples in that spec are untagged,
# it will then run 'jt test' to verify the untagging worked correctly. If 'jt test' fails,
# it will run 'git checkout' on the tag file that was changed.
# This still produces 'jt test' suite errors after running because of presumed test pollution
# between the specs when running as a suite.
# The 'test' and 'untag' commands are run with a 90 second timeout will kills the process if it
# finished yet to resolve tests that hang.
# This currently takes greater than 4 hours to complete one run of this script.

require 'timeout'

files = Dir.glob("spec/ruby/core/*/*")
files.reject! { |f| File.directory?(f) }

num = 1
total = files.size
files.each_with_index do |file, index|
specname = file.split('/').last.split('_')[0..-2].join('_')
puts "specname #{specname}"
command = "ruby tool/jt.rb untag #{file}"
puts "starting #{num} of #{total} process #{command}"
rout, wout = IO.pipe
rerr, werr = IO.pipe
pid = Process.spawn(command, :out => wout, :err => werr)
finished = false
begin
Timeout.timeout(90) do
puts "waiting for the #{file} process to end"
Process.wait(pid)
finished = true
puts "process #{file} finished in time"
end
rescue Timeout::Error
puts "process #{file} with pid #{pid} not finished in time, killing it"
Process.kill('TERM', pid)
end
# close write ends so we could read them
wout.close unless wout.closed?
werr.close unless werr.closed?

@stdout = if finished
rout.readlines.join("\n")
else
""
end

@stderr = if finished
rerr.readlines.join("\n")
else
""
end

# dispose the read ends of the pipes
rout.close unless rout.closed?
rerr.close unless rerr.closed?

tags_deleted = "no tags 'fails' were deleted"
puts "finished #{finished}"
puts "status #{$? != 0}"
#puts @stdout
puts "contains #{!@stdout.include?(tags_deleted)}"

if finished && $? != 0 && !@stdout.include?(tags_deleted)
test_command = "ruby tool/jt.rb test #{file}"
puts "testing process #{test_command}"
test_pid = Process.spawn(test_command)
begin
Timeout.timeout(90) do
puts "waiting for the '#{test_command}' to end"
Process.wait(test_pid)
puts "process '#{test_command}' finished in time"
if $? != 0
tag_file = "spec/truffle/tags/core/#{file.split('/')[-2]}/#{specname}_tags.txt"
print "\a"
puts "resetting with command 'git checkout #{tag_file}"
output = system("git checkout #{tag_file}")
puts output
end
end
rescue Timeout::Error
puts "process #{file} with pid #{test_pid} not finished in time, killing it"
Process.kill('TERM', test_pid)
end
end
num += 1
end