diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-02-12 15:55:21 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-02-12 15:55:21 +0800 |
commit | 1ecfd0ab7f1f511268fd6404dbc110c3c277b48c (patch) | |
tree | 49449a4076ded9bd937a51679318edbe2a532cae /works/life/lanqiao-selection-match/cpp-gen-out.rb | |
parent | 55d8b025e8d6ea971e8ee5762c892405fedc316b (diff) | |
parent | f8c10dd1fc55e60f35286475356e48c4f642eb63 (diff) | |
download | crupest-1ecfd0ab7f1f511268fd6404dbc110c3c277b48c.tar.gz crupest-1ecfd0ab7f1f511268fd6404dbc110c3c277b48c.tar.bz2 crupest-1ecfd0ab7f1f511268fd6404dbc110c3c277b48c.zip |
import(life): IMPORT crupest/life COMPLETE.
Diffstat (limited to 'works/life/lanqiao-selection-match/cpp-gen-out.rb')
-rwxr-xr-x | works/life/lanqiao-selection-match/cpp-gen-out.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/works/life/lanqiao-selection-match/cpp-gen-out.rb b/works/life/lanqiao-selection-match/cpp-gen-out.rb new file mode 100755 index 0000000..48ad68a --- /dev/null +++ b/works/life/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 |