Class: AtCoderFriends::TestRunner::Sample
- Includes:
- PathUtil
- Defined in:
- lib/at_coder_friends/test_runner/sample.rb
Overview
run test cases for the specified program with sample input/output.
Constant Summary
Constants included from PathUtil
PathUtil::CASES_DIR, PathUtil::SMP_DIR, PathUtil::TMP_DIR
Constants inherited from Base
Instance Attribute Summary collapse
-
#data_dir ⇒ Object
readonly
Returns the value of attribute data_dir.
Attributes inherited from Base
#base, #ctx, #dir, #ext, #path, #prg, #q
Instance Method Summary collapse
-
#initialize(ctx) ⇒ Sample
constructor
A new instance of Sample.
- #test(id) ⇒ Object
- #test_all ⇒ Object
- #test_one(id) ⇒ 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, #check_file, #check_status, #detail_str, #local_test, #remote_test, #run_test, #test_cmd, #test_loc, #test_mtd, #which_os
Constructor Details
#initialize(ctx) ⇒ Sample
11 12 13 14 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 11 def initialize(ctx) super(ctx) @data_dir = smp_dir(dir) 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/sample.rb', line 9 def data_dir @data_dir end |
Instance Method Details
#test(id) ⇒ Object
30 31 32 33 34 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 30 def test(id) id = format('%<q>s_%<id>s', q: q, id: id) files = %w[in out exp].map { |ext| "#{data_dir}/#{id}.#{ext}" } run_test(id, *files) end |
#test_all ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 16 def test_all puts "***** test_all #{prg} (#{test_loc}) *****" results = Dir["#{data_dir}/#{q}_*.in"].sort.map do |infile| id = File.basename(infile, '.in').sub(/[^_]+_/, '') test(id) end !results.empty? && results.all? end |
#test_one(id) ⇒ Object
25 26 27 28 |
# File 'lib/at_coder_friends/test_runner/sample.rb', line 25 def test_one(id) puts "***** test_one #{prg} (#{test_loc}) *****" test(id) end |