class Gobstones::MultipleExecutionsRunner

Public Instance Methods

run(output, example) click to toggle source
# File lib/multiple_executions_runner.rb, line 3
def run(output, example)
  execution = output[example[:id]]
  execution[:status] = execution[:status].to_sym

  convert_compilation_to_runtime_errors! execution if compilation_error?(execution)
  convert_no_program_error! execution if no_program?(execution)

  raise Mumukit::Metatest::Errored, error_message(execution) unless success?(execution)
  execution
end

Private Instance Methods

compilation_error?(execution) click to toggle source
# File lib/multiple_executions_runner.rb, line 20
def compilation_error?(execution)
  execution[:status] == :compilation_error
end
convert_compilation_to_runtime_errors!(execution) click to toggle source
# File lib/multiple_executions_runner.rb, line 35
def convert_compilation_to_runtime_errors!(execution)
  if execution[:result][:finalBoardError][:reason][:code].include? 'arity-mismatch'
    execution[:status] = :runtime_error
  end
end
convert_no_program_error!(execution) click to toggle source
# File lib/multiple_executions_runner.rb, line 41
def convert_no_program_error!(execution)
  execution[:status] = :compilation_error
  execution[:result][:finalBoardError] = {
    on: {
      range: {
        start: {
          row: 0,
          column: 0
        }
      }
    },
    reason: { code: 'no-program-found' },
    message: I18n.t('no_program_found')
  }
end
error_message(execution) click to toggle source
# File lib/multiple_executions_runner.rb, line 28
def error_message(execution)
  return format execution.except(:result).to_json unless compilation_error?(execution)

  error = execution[:result][:finalBoardError]
  format Gobstones.build_error(error)
end
format(error) click to toggle source
# File lib/multiple_executions_runner.rb, line 57
def format(error)
  "<pre>#{error}</pre>"
end
no_program?(execution) click to toggle source
# File lib/multiple_executions_runner.rb, line 24
def no_program?(execution)
  execution[:status] == :no_program_found
end
success?(execution) click to toggle source
# File lib/multiple_executions_runner.rb, line 16
def success?(execution)
  [:passed, :runtime_error].include? execution[:status]
end