# HG changeset patch # User unknown # Date 2010-05-04 15:59:12 # Node ID ca6ce454fda9036cfcde9ab0b3a905b3ea6f4ae6 # Parent d5c4e1d8daa2bcb74627155aabd9909ecca01d3b autonew skips submissions with bad problems, forbids getch, better compiler msg when preprocessing fails, reports compile error when the executable is too large (100MB) diff --git a/grader b/grader --- a/grader +++ b/grader @@ -249,6 +249,9 @@ if submissions.length != 0 submissions.each do |submission| + if (submission.problem == nil) or (!submission.problem.available) + next + end if ! graded_submission_ids[submission.id] runner.grade_submission(submission) graded_submission_ids[submission.id] = true diff --git a/std-script/compile b/std-script/compile --- a/std-script/compile +++ b/std-script/compile @@ -82,7 +82,7 @@ params[:prog_lang] = 'c++' end -forbidden_functions = ['system', 'fopen', 'freopen', 'open', 'remove', 'rename'] +forbidden_functions = ['system', 'fopen', 'freopen', 'open', 'remove', 'rename', 'getch'] redefine_list = [] forbidden_count = 0 forbidden_key = (rand(8999) + 1000).to_s @@ -97,18 +97,21 @@ case params[:prog_lang] when "c" - command = "#{C_COMPILER} -E #{params[:source_file]} -o source_prep.c" + command = "#{C_COMPILER} -E #{params[:source_file]} -o source_prep.c 2> #{params[:message_file]}" system(command) - command = "#{C_COMPILER} source_prep.c #{redefine_str} -o #{params[:output_file]} #{C_OPTIONS} 2> #{params[:message_file]}" - puts command - system(command) + if FileTest.exist? "source_prep.c" + command = "#{C_COMPILER} source_prep.c #{redefine_str} -o #{params[:output_file]} #{C_OPTIONS} 2> #{params[:message_file]}" + system(command) + end when "c++" - command = "#{CPLUSPLUS_COMPILER} -E #{params[:source_file]} -o source_prep.cpp" + command = "#{CPLUSPLUS_COMPILER} -E #{params[:source_file]} -o source_prep.cpp 2> #{params[:message_file]}" system(command) - command = "#{CPLUSPLUS_COMPILER} #{redefine_str} source_prep.cpp -o #{params[:output_file]} #{CPLUSPLUS_OPTIONS} 2> #{params[:message_file]}" - system(command) - + if FileTest.exist? "source_prep.cpp" + command = "#{CPLUSPLUS_COMPILER} #{redefine_str} source_prep.cpp -o #{params[:output_file]} #{CPLUSPLUS_OPTIONS} 2> #{params[:message_file]}" + system(command) + end + when "pas" command = "#{PASCAL_COMPILER} #{params[:source_file]} -ooutpas #{PASCAL_OPTIONS} > #{params[:message_file]}" system(command) @@ -124,7 +127,15 @@ # Report success or failure. if FileTest.exists? params[:output_file] - talk "Compilation was successful!" + talk "Compilation was successful!" + + if File.size(params[:output_file]) > 100000000 + talk "But the executable is too big." + open(params[:message_file],"w+") do |f| + f.puts "Executable is too large." + end + File.delete(params[:output_file]) + end else talk "ERROR: Something was wrong during the compilation!" end