Description:
removed calls to 'pwd', other uses of back quotes
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r102:a3aedb7e3776 - - 4 files changed: 7 inserted, 5 deleted
@@ -1,8 +1,10 | |||
|
1 | 1 | #!/usr/bin/ruby |
|
2 | 2 | |
|
3 | + require 'fileutils' | |
|
4 | + | |
|
3 | 5 | def talk(str) |
|
4 | 6 | if TALKATIVE |
|
5 | 7 | puts str |
|
6 | 8 | end |
|
7 | 9 | end |
|
8 | 10 | |
@@ -82,8 +84,8 | |||
|
82 | 84 | #main program |
|
83 | 85 | talk 'Reading rails environment' |
|
84 | 86 | |
|
85 | 87 | RAILS_ENV = 'development' |
|
86 | 88 | require RAILS_APP_DIR + '/config/environment' |
|
87 | 89 | |
|
88 |
- current_dir = |
|
|
90 | + current_dir = FileUtils.pwd | |
|
89 | 91 | grade(ARGV[0].to_i) |
@@ -28,13 +28,13 | |||
|
28 | 28 | @reporter = options[:reporter] |
|
29 | 29 | end |
|
30 | 30 | |
|
31 | 31 | # takes a submission, asks room_maker to produce grading directories, |
|
32 | 32 | # calls grader scripts, and asks reporter to save the result |
|
33 | 33 | def grade(submission) |
|
34 |
- current_dir = |
|
|
34 | + current_dir = FileUtils.pwd | |
|
35 | 35 | |
|
36 | 36 | user = submission.user |
|
37 | 37 | problem = submission.problem |
|
38 | 38 | |
|
39 | 39 | # TODO: will have to create real exception for this |
|
40 | 40 | if user==nil or problem == nil |
@@ -63,13 +63,13 | |||
|
63 | 63 | log "The source file does not exist." |
|
64 | 64 | exit(127) |
|
65 | 65 | end |
|
66 | 66 | |
|
67 | 67 | log "Making test result and sandbox directories..." |
|
68 | 68 | |
|
69 |
- current_dir = |
|
|
69 | + current_dir = FileUtils.pwd | |
|
70 | 70 | current_dir.strip! |
|
71 | 71 | |
|
72 | 72 | if ARGV.length >= 3 |
|
73 | 73 | test_result_dir = ARGV[2] |
|
74 | 74 | else |
|
75 | 75 | test_result_dir = "#{current_dir}/test-result" |
@@ -96,13 +96,13 | |||
|
96 | 96 | Dir.chdir sandbox_dir |
|
97 | 97 | rescue |
|
98 | 98 | log "ERROR: Cannot change directory to #{sandbox_dir}." |
|
99 | 99 | exit(127) |
|
100 | 100 | end |
|
101 | 101 | execute("#{problem_home}/script/compile #{language} #{source_file}", "Compilation error!") |
|
102 |
- compile_message = |
|
|
102 | + compile_message = open("compiler_message").read | |
|
103 | 103 | compile_message.strip! |
|
104 | 104 | call_and_log("Cannot move the compiler message to #{test_result_dir}.") { |
|
105 | 105 | FileUtils.mv("compiler_message", test_result_dir) |
|
106 | 106 | } |
|
107 | 107 | if !FileTest.exist?("a.out") |
|
108 | 108 | log "Cannot compile the source code. See message in #{test_result_dir}/compile_message" |
@@ -108,13 +108,13 | |||
|
108 | 108 | result_file.write "\n" |
|
109 | 109 | result_file.write points.to_s.strip |
|
110 | 110 | result_file.write "\n" |
|
111 | 111 | result_file.write run_stat.strip |
|
112 | 112 | result_file.write "\n" |
|
113 | 113 | result_file.close |
|
114 |
- |
|
|
114 | + FileUtils.rm "run_result" | |
|
115 | 115 | # `rm output.txt` --- keep the output |
|
116 | 116 | |
|
117 | 117 | comment_file.write comment |
|
118 | 118 | |
|
119 | 119 | # added for debuggin --- jittat |
|
120 | 120 | comment_file.write "--run-result--\n" |
You need to be logged in to leave comments.
Login now