Class: AtCoderFriends::TestRunner::Judge
- 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 inherited from Base
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
Methods inherited from Base
#call_remote_test, #check_file, #check_status, #detail_str, #local_test, #remote_test, #run_test, #test_cmd, #test_loc, #test_mtd, #which_os
Methods included from PathUtil
Constructor Details
#initialize(ctx) ⇒ Judge
Returns a new instance of Judge.
9 10 11 12 13 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 9 def initialize(ctx) super(ctx) @data_dir = ctx.path_info.cases_dir @result_dir = ctx.path_info.cases_out_dir end |
Instance Attribute Details
#data_dir ⇒ Object (readonly)
Returns the value of attribute data_dir.
7 8 9 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 7 def data_dir @data_dir end |
#result_dir ⇒ Object (readonly)
Returns the value of attribute result_dir.
7 8 9 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 7 def result_dir @result_dir end |
Instance Method Details
#judge(id, detail: true) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 29 def judge(id, detail: true) @detail = detail infile = "#{data_dir}/#{q}/in/#{id}" outfile = "#{result_dir}/#{q}/result/#{id}" expfile = "#{data_dir}/#{q}/out/#{id}" run_test(id, infile, outfile, expfile) end |
#judge_all ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 15 def judge_all puts "***** judge_all #{prg} (#{test_loc}) *****" results = Dir["#{data_dir}/#{q}/in/*"].sort.map do |infile| id = File.basename(infile) judge(id, detail: false) end !results.empty? && results.all? end |
#judge_one(id) ⇒ Object
24 25 26 27 |
# File 'lib/at_coder_friends/test_runner/judge.rb', line 24 def judge_one(id) puts "***** judge_one #{prg} (#{test_loc}) *****" judge(id, detail: true) end |