Skip to content

Instantly share code, notes, and snippets.

@bjfish
Created March 5, 2015 14:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bjfish/eafa28b6bc82eb2299a3 to your computer and use it in GitHub Desktop.
run jt untag with 90 second timeout, then jt test if specs were untagged, if jt test fails checkout the changes to the tag file
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment