Class: AtCoderFriends::TestRunner::Judge

Inherits:
Base
  • Object
show all
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

Constants inherited from Base

Base::STATUS_STR

Instance Attribute Summary collapse

Attributes inherited from Base

#base, #ctx, #dir, #ext, #path, #prg, #q

Instance Method Summary collapse

Methods included from PathUtil

cases_dir, contest_name, makedirs_unless, smp_dir, split_prg_path, tmp_dir

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

Constructor Details

#initialize(ctx) ⇒ 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_dirObject (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_dirObject (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



31
32
33
34
35
36
37
# File 'lib/at_coder_friends/test_runner/judge.rb', line 31

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_allObject



17
18
19
20
21
22
23
24
# File 'lib/at_coder_friends/test_runner/judge.rb', line 17

def judge_all
  puts "***** judge_all #{prg} (#{test_loc}) *****"
  results = Dir["#{data_dir}/#{q}/in/*.txt"].sort.map do |infile|
    id = File.basename(infile, '.txt')
    judge(id, false)
  end
  !results.empty? && results.all?
end

#judge_one(id) ⇒ Object



26
27
28
29
# File 'lib/at_coder_friends/test_runner/judge.rb', line 26

def judge_one(id)
  puts "***** judge_one #{prg} (#{test_loc}) *****"
  judge(id, true)
end