#!/usr/bin/env ruby HELP = < (command) do logfile.puts "" logfile.puts "##### #{command} #####" logfile.flush pid = Process.spawn(command, chdir: dir, out: logfile, err: logfile) Process.waitpid(pid) $?.success? end # parallel `vagrant up` commands can be flaky with VirtualBox due to lock contention, # so give it a few retries. with_retries(3, sleep: 1.0, sleep_jitter: 0.5) do unless run_and_log.call "vagrant up" raise "vagrant up failed" end end unless run_and_log.call "vagrant rsync" raise "vagrant rsync failed" end unless run_and_log.call "vagrant ssh -c 'cd /bindfs && sudo rm -Rf tests/tmp_test_bindfs && ./configure && make distclean && ./configure && make && make check && sudo make check'" mutex.synchronize do errors << "VM #{dir} tests failed." end end if halt_vms unless run_and_log.call "vagrant halt" raise "vagrant halt failed" end end end rescue mutex.synchronize do errors << "VM #{dir} error: #{$!}" end ensure mutex.synchronize do puts "Finished VM: #{dir}" end if print_logs puts File.read(dir + "/test.log") puts end end end end threads.each(&:join) if errors.empty? puts "All OK" else unless errors.empty? puts puts "Errors:" errors.each { |err| puts " #{err}" } puts puts "See test.log in a failed VM's directory for more information" puts exit 1 end end