Show More
Commit Description:
[grader] import script now support raw with testruns...
Commit Description:
[grader] import script now support raw with testruns git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@267 6386c4cd-e34a-4fa8-8920-d93eb39b512e
File last commit:
Show/Diff file:
Action:
new_problem | 73 lines | 1.6 KiB | text/plain | TextLexer |
jittat
update import_problem info, add new_problem...
r14 #!/usr/bin/ruby
# new_problem:
# * creates a directory for a problem in the current directory,
# * create standard testcase config file
require 'erb'
def process_options(options)
i = 2
while i<ARGV.length
if ARGV[i]=='-t'
options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1
i += 1
end
if ARGV[i]=='-m'
options[:mem_limit] = ARGV[i+1].to_i if ARGV.length>i+1
i += 1
end
i += 1
end
end
jittat
[grader] obsolete new_problem, fixed memory measurement bug in box.cc...
r49
puts "This script is out of dated, shall be fixed soon"
puts "Right now, you can create raw_ev and import"
exit(0)
jittat
update import_problem info, add new_problem...
r14 GRADER_DIR = File.dirname(__FILE__)
# print usage
if ARGV.length < 2
jittat
add more description to new_problem...
r19 puts <<USAGE
using: new_problem problem number_of_testcase [options]
* creates a directory for a problem in the current directory,
* create standard testcase config file
* options: -t time-limit (in seconds)
-m mem-limit (in MB)
USAGE
jittat
update import_problem info, add new_problem...
r14 exit(127)
end
# processing arguments
problem = ARGV[0]
num_testcases = ARGV[1].to_i
options = {:time_limit => 1, :mem_limit => 16}
process_options(options)
# start working
puts "creating directories"
system("mkdir #{problem}")
system("mkdir #{problem}/script")
system("mkdir #{problem}/test_cases")
puts "creating testcases directories"
1.upto(num_testcases) do |i|
system("mkdir #{problem}/test_cases/#{i}")
end
# generating all_tests.cfg
puts "generating testcase config file"
jittat
[grader] obsolete new_problem, fixed memory measurement bug in box.cc...
r49 template = File.open(File.dirname(__FILE__) + "/templates/all_tests.cfg.erb").read
jittat
update import_problem info, add new_problem...
r14 all_test_cfg = ERB.new(template)
cfg_file = File.open("#{problem}/test_cases/all_tests.cfg","w")
cfg_file.puts all_test_cfg.result
cfg_file.close
puts "done"