diff --git a/std-script/grade b/std-script/grade --- a/std-script/grade +++ b/std-script/grade @@ -62,6 +62,15 @@ result_file.close end end + + # find total score for this run + run_total_score = 0 + problem = Problem.get_instance + run.tests.each { |test_num| run_total_score += problem.get_score(test_num) } + + if run_total_score!=run_score # fail in some test cases, fail the run + run_score = 0 + end run_result_file = File.new("result-#{k}", "w") run_result_file.write run_score @@ -73,6 +82,11 @@ run_comment_file.close all_score = all_score + run_score + + # append comment for test run with many test cases + if run.tests.length > 1 + run_comment_short = '[' + run_comment_short + ']' + end all_comment += run_comment_short end diff --git a/test/data/add_fail_test_case_1.c b/test/data/add_fail_test_case_1.c new file mode 100644 --- /dev/null +++ b/test/data/add_fail_test_case_1.c @@ -0,0 +1,13 @@ +#include + +int main() +{ + int a,b; + scanf("%d %d",&a,&b); + if((a==1) && (b==1)) + printf("100\n"); + else + printf("%d\n",a+b); + return 0; +} + diff --git a/test/engine_spec.rb b/test/engine_spec.rb --- a/test/engine_spec.rb +++ b/test/engine_spec.rb @@ -81,6 +81,14 @@ :comment => /FAILED: [^P]P/}) end + it "should score test runs correctly when submission fails in some test case" do + grader_should(:grade => "add_fail_test_case_1.c", + :on => @problem_test_normal, + :and_report => { + :score => 105, + :comment => /^FAILED:/}) + end + it "should fail submission with non-zero exit status" do violated("has not been implemented") end