Description:
[grader] finish engine spec on grading non-zero exit status git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@127 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r33:e7a6930e8c87 - - 1 file changed: 5 inserted, 1 deleted

@@ -69,49 +69,53
69 :score => 10,
69 :score => 10,
70 :comment => /FAILED: [^P]P/})
70 :comment => /FAILED: [^P]P/})
71 end
71 end
72
72
73 it "should not allow submission to allocate too much dynamic memory" do
73 it "should not allow submission to allocate too much dynamic memory" do
74 @problem_test_memory = stub(Problem,
74 @problem_test_memory = stub(Problem,
75 :id => 1, :name => 'test_memory',
75 :id => 1, :name => 'test_memory',
76 :full_score => 20)
76 :full_score => 20)
77 grader_should(:grade => "add_too_much_memory_dynamic.c",
77 grader_should(:grade => "add_too_much_memory_dynamic.c",
78 :on => @problem_test_memory,
78 :on => @problem_test_memory,
79 :and_report => {
79 :and_report => {
80 :score => 10,
80 :score => 10,
81 :comment => /FAILED: [^P]P/})
81 :comment => /FAILED: [^P]P/})
82 end
82 end
83
83
84 it "should score test runs correctly when submission fails in some test case" do
84 it "should score test runs correctly when submission fails in some test case" do
85 grader_should(:grade => "add_fail_test_case_1.c",
85 grader_should(:grade => "add_fail_test_case_1.c",
86 :on => @problem_test_normal,
86 :on => @problem_test_normal,
87 :and_report => {
87 :and_report => {
88 :score => 105,
88 :score => 105,
89 :comment => /^FAILED:/})
89 :comment => /^FAILED:/})
90 end
90 end
91
91
92 it "should fail submission with non-zero exit status" do
92 it "should fail submission with non-zero exit status" do
93 - violated("has not been implemented")
93 + grader_should(:grade => "add_nonzero_exit_status.c",
94 + :on => @problem_test_normal,
95 + :and_report => {
96 + :score => 0,
97 + :comment => /^FAILED:/})
94 end
98 end
95
99
96 def grader_should(args)
100 def grader_should(args)
97 @user1 = stub(User,
101 @user1 = stub(User,
98 :id => 1, :login => 'user1')
102 :id => 1, :login => 'user1')
99 submission =
103 submission =
100 create_submission_from_file(1, @user1, args[:on], args[:grade])
104 create_submission_from_file(1, @user1, args[:on], args[:grade])
101 submission.should_receive(:graded_at=)
105 submission.should_receive(:graded_at=)
102
106
103 expected_score = args[:and_report][:score]
107 expected_score = args[:and_report][:score]
104 expected_comment = args[:and_report][:comment]
108 expected_comment = args[:and_report][:comment]
105 if args[:and_report][:compiler_message]!=nil
109 if args[:and_report][:compiler_message]!=nil
106 expected_compiler_message = args[:and_report][:compiler_message]
110 expected_compiler_message = args[:and_report][:compiler_message]
107 else
111 else
108 expected_compiler_message = ''
112 expected_compiler_message = ''
109 end
113 end
110
114
111 submission.should_receive(:points=).with(expected_score)
115 submission.should_receive(:points=).with(expected_score)
112 submission.should_receive(:grader_comment=).with(expected_comment)
116 submission.should_receive(:grader_comment=).with(expected_comment)
113 submission.should_receive(:compiler_message=).with(expected_compiler_message)
117 submission.should_receive(:compiler_message=).with(expected_compiler_message)
114 submission.should_receive(:save)
118 submission.should_receive(:save)
115
119
116 @engine.grade(submission)
120 @engine.grade(submission)
117 end
121 end
You need to be logged in to leave comments. Login now