Change default of raise_exception for execute_command
This commit is contained in:
@ -31,8 +31,8 @@ class ExecutionEnvironmentsController < ApplicationController
|
||||
|
||||
def execute_command
|
||||
runner = Runner.for(current_user, @execution_environment)
|
||||
output = runner.execute_command(params[:command])
|
||||
render(json: output)
|
||||
output = runner.execute_command(params[:command], raise_exception: false)
|
||||
render json: output
|
||||
end
|
||||
|
||||
def working_time_query
|
||||
|
@ -79,7 +79,7 @@ class ExecutionEnvironment < ApplicationRecord
|
||||
|
||||
def working_docker_image?
|
||||
runner = Runner.for(author, self)
|
||||
output = runner.execute_command(VALIDATION_COMMAND, raise_exception: true)
|
||||
output = runner.execute_command(VALIDATION_COMMAND)
|
||||
errors.add(:docker_image, "error: #{output[:stderr]}") if output[:stderr].present?
|
||||
rescue Runner::Error => e
|
||||
errors.add(:docker_image, "error: #{e}")
|
||||
|
@ -64,7 +64,7 @@ class Runner < ApplicationRecord
|
||||
Time.zone.now - starting_time # execution duration
|
||||
end
|
||||
|
||||
def execute_command(command, raise_exception: false)
|
||||
def execute_command(command, raise_exception: true)
|
||||
output = {}
|
||||
stdout = +''
|
||||
stderr = +''
|
||||
|
@ -162,7 +162,7 @@ describe ExecutionEnvironment do
|
||||
it 'executes the validation command' do
|
||||
allow(runner).to receive(:execute_command).and_return({})
|
||||
working_docker_image?
|
||||
expect(runner).to have_received(:execute_command).with(ExecutionEnvironment::VALIDATION_COMMAND, raise_exception: true)
|
||||
expect(runner).to have_received(:execute_command).with(ExecutionEnvironment::VALIDATION_COMMAND)
|
||||
end
|
||||
|
||||
context 'when the command produces an error' do
|
||||
|
Reference in New Issue
Block a user