Show More
Commit Description:
ignoring files...
Commit Description:
ignoring files git-svn-id: http://theory.cpe.ku.ac.th/grader/cli/trunk/scripts@34 6386c4cd-e34a-4fa8-8920-d93eb39b512e
File last commit:
Show/Diff file:
Action:
new_problem | 62 lines | 1.3 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
GRADER_DIR = File.dirname(__FILE__)
# print usage
if ARGV.length < 2
puts "using: new_problem problem number_of_testcase [options]"
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"
template = File.open(File.dirname(__FILE__) + "/all_tests.cfg.erb").read
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"