Class: AtCoderFriends::TestRunner::Judge
- Includes:
- PathUtil
- Defined in:
- lib/at_coder_friends/test_runner/judge.rb
Overview
run test cases for the specified program with judge input/output.
Constant Summary
Constants included from PathUtil
PathUtil::CASES_DIR, PathUtil::SMP_DIR, PathUtil::TMP_DIR
Instance Attribute Summary collapse
-
#data_dir ⇒ Object
readonly
Returns the value of attribute data_dir.
-
#result_dir ⇒ Object
readonly
Returns the value of attribute result_dir.
Attributes inherited from Base
#base, #ctx, #dir, #ext, #path, #prg, #q
Instance Method Summary collapse
-
#initialize(ctx) ⇒ Judge
constructor
A new instance of Judge.
- #judge(id, detail = true) ⇒ Object
- #judge_all ⇒ Object
- #judge_one(id) ⇒ Object
- #show_result(is_success, input, result, expected) ⇒ Object
Methods included from PathUtil
cases_dir, contest_name, makedirs_unless, smp_dir, split_prg_path, tmp_dir
Methods inherited from Base
#call_remote_test, #config, #detail_str, #local_test, #remote_test, #result_str, #run_test, #test_cmd, #test_loc, #test_mtd, #which_os
Constructor Details
#initialize(ctx) ⇒ Judge
Returns a new instance of Judge.
11 12 13 14 15 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 11 def initialize(ctx) super(ctx) @data_dir = cases_dir(dir) @result_dir = cases_dir(tmp_dir(path)) end |
Instance Attribute Details
#data_dir ⇒ Object (readonly)
Returns the value of attribute data_dir.
9 10 11 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 9 def data_dir @data_dir end |
#result_dir ⇒ Object (readonly)
Returns the value of attribute result_dir.
9 10 11 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 9 def result_dir @result_dir end |
Instance Method Details
#judge(id, detail = true) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 30 def judge(id, detail = true) @detail = detail infile = "#{data_dir}/#{q}/in/#{id}.txt" outfile = "#{result_dir}/#{q}/result/#{id}.txt" expfile = "#{data_dir}/#{q}/out/#{id}.txt" run_test(id, infile, outfile, expfile) end |
#judge_all ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 17 def judge_all puts "***** judge_all #{prg} (#{test_loc}) *****" Dir["#{data_dir}/#{q}/in/*.txt"].sort.each do |infile| id = File.basename(infile, '.txt') judge(id, false) end end |
#judge_one(id) ⇒ Object
25 26 27 28 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 25 def judge_one(id) puts "***** judge_one #{prg} (#{test_loc}) *****" judge(id, true) end |
#show_result(is_success, input, result, expected) ⇒ Object
38 39 40 41 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 38 def show_result(is_success, input, result, expected) print detail_str(input, result, expected) if @detail puts result_str(is_success, result, expected) end |