Re-add test method for SubmissionsController
This commit is contained in:
@ -190,23 +190,18 @@ class SubmissionsController < ApplicationController
|
|||||||
|
|
||||||
def statistics; end
|
def statistics; end
|
||||||
|
|
||||||
# TODO: make this run, but with the test command
|
def test
|
||||||
# TODO: add this method to the before action for set_submission again
|
hijack do |tubesock|
|
||||||
# def test
|
return kill_client_socket(tubesock) if @embed_options[:disable_run]
|
||||||
# hijack do |tubesock|
|
|
||||||
# unless EventMachine.reactor_running? && EventMachine.reactor_thread.alive?
|
tubesock.send_data(JSON.dump(@submission.test(@file)))
|
||||||
# Thread.new do
|
rescue Runner::Error => e
|
||||||
# EventMachine.run
|
tubesock.send_data JSON.dump({cmd: :status, status: :container_depleted})
|
||||||
# ensure
|
Rails.logger.debug { "Runner error while testing submission #{@submission.id}: #{e.message}" }
|
||||||
# ActiveRecord::Base.connection_pool.release_connection
|
ensure
|
||||||
# end
|
kill_client_socket(tubesock)
|
||||||
# end
|
end
|
||||||
# output = @docker_client.execute_test_command(@submission, sanitize_filename)
|
end
|
||||||
# # tubesock is the socket to the client
|
|
||||||
# tubesock.send_data JSON.dump(output)
|
|
||||||
# tubesock.send_data JSON.dump('cmd' => 'exit')
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
@ -161,6 +161,16 @@ class Submission < ApplicationRecord
|
|||||||
durations
|
durations
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test(file)
|
||||||
|
prepared_runner do |runner, waiting_duration|
|
||||||
|
output = run_test_file file, runner, waiting_duration
|
||||||
|
score_file output, file
|
||||||
|
rescue Runner::Error => e
|
||||||
|
e.waiting_duration = waiting_duration
|
||||||
|
raise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def run_test_file(file, runner, waiting_duration)
|
def run_test_file(file, runner, waiting_duration)
|
||||||
score_command = command_for execution_environment.test_command, file.name_with_extension
|
score_command = command_for execution_environment.test_command, file.name_with_extension
|
||||||
output = {file_role: file.role, waiting_for_container_time: waiting_duration}
|
output = {file_role: file.role, waiting_for_container_time: waiting_duration}
|
||||||
|
Reference in New Issue
Block a user