From dfdb5012705bcb3e13c10b22c63a351b9b2a708c Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 18 Dec 2021 19:39:43 +0800 Subject: ... --- lanqiao-selection-match/cpp-gen-out.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 lanqiao-selection-match/cpp-gen-out.rb (limited to 'lanqiao-selection-match/cpp-gen-out.rb') diff --git a/lanqiao-selection-match/cpp-gen-out.rb b/lanqiao-selection-match/cpp-gen-out.rb new file mode 100755 index 0000000..48ad68a --- /dev/null +++ b/lanqiao-selection-match/cpp-gen-out.rb @@ -0,0 +1,24 @@ +#!/usr/bin/env ruby + +require 'timeout' + +def run(no, count) + Dir.glob("./build/*#{no}").each do |f| + count.times do |i| + in_file = "./generator/#{no}-#{i + 1}.in" + out_file = "#{f.sub('build', 'out')}-#{i + 1}.out" + pid = Process.spawn "#{f} < #{in_file} > #{out_file}" + Timeout.timeout(1) do + Process.wait pid + end + rescue Timeout::Error + puts "Timeout for #{f} when tests #{i + 1} case" + File.delete out_file + Process.kill 'KILL', pid + end + end +end + +run 'A', 3 +run 'B', 3 +run 'C', 4 -- cgit v1.2.3