Description:
Merge branch 'master' of gitorious.org:cafe-grader/cafe-grader-judge-scripts into win-local
Commit status:
[Not Reviewed]
References:
merge default
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r106:502201e59a2c - - 1 file changed: 2 inserted, 0 deleted

@@ -1,50 +1,52
1 #!/usr/bin/ruby
1 #!/usr/bin/ruby
2
2
3 + require 'fileutils'
4 +
3 def log(str='')
5 def log(str='')
4 if ENV['TALKATIVE']!=nil
6 if ENV['TALKATIVE']!=nil
5 puts str
7 puts str
6 end
8 end
7 if ENV['GRADER_LOGGING']!=nil
9 if ENV['GRADER_LOGGING']!=nil
8 log_fname = ENV['GRADER_LOGGING']
10 log_fname = ENV['GRADER_LOGGING']
9 fp = File.open(log_fname,"a")
11 fp = File.open(log_fname,"a")
10 fp.puts("run: #{Time.new.strftime("%H:%M")} #{str}")
12 fp.puts("run: #{Time.new.strftime("%H:%M")} #{str}")
11 fp.close
13 fp.close
12 end
14 end
13 end
15 end
14
16
15 def extract_time(t)
17 def extract_time(t)
16 # puts "TIME: #{t}"
18 # puts "TIME: #{t}"
17 if (result=/^(.*)r(.*)u(.*)s/.match(t))
19 if (result=/^(.*)r(.*)u(.*)s/.match(t))
18 {:real => result[1], :user => result[2], :sys => result[3]}
20 {:real => result[1], :user => result[2], :sys => result[3]}
19 else
21 else
20 #{:real => 0, :user => 0, :sys => 0}
22 #{:real => 0, :user => 0, :sys => 0}
21 #puts "ERROR READING RUNNING TIME: #{t}"
23 #puts "ERROR READING RUNNING TIME: #{t}"
22 raise "Error reading running time: #{t}"
24 raise "Error reading running time: #{t}"
23 end
25 end
24 end
26 end
25
27
26 def compile_box(source,bin)
28 def compile_box(source,bin)
27 system("g++ #{source} -o #{bin}")
29 system("g++ #{source} -o #{bin}")
28 end
30 end
29
31
30 if ARGV.length < 2 || ARGV.length > 3
32 if ARGV.length < 2 || ARGV.length > 3
31 puts "Usage: run <language> <test-num> [<program-name>]"
33 puts "Usage: run <language> <test-num> [<program-name>]"
32 exit(127)
34 exit(127)
33 end
35 end
34
36
35 language = ARGV[0]
37 language = ARGV[0]
36 test_num = ARGV[1].to_i
38 test_num = ARGV[1].to_i
37 if ARGV.length > 2
39 if ARGV.length > 2
38 program_name = ARGV[2]
40 program_name = ARGV[2]
39 else
41 else
40 program_name = "a.out"
42 program_name = "a.out"
41 end
43 end
42
44
43 problem_home = ENV['PROBLEM_HOME']
45 problem_home = ENV['PROBLEM_HOME']
44 require "#{problem_home}/script/test_dsl.rb"
46 require "#{problem_home}/script/test_dsl.rb"
45 load "#{problem_home}/test_cases/all_tests.cfg"
47 load "#{problem_home}/test_cases/all_tests.cfg"
46 problem = Problem.get_instance
48 problem = Problem.get_instance
47
49
48 if problem.well_formed? == false
50 if problem.well_formed? == false
49 log "The problem specification is not well formed."
51 log "The problem specification is not well formed."
50 exit(127)
52 exit(127)
You need to be logged in to leave comments. Login now