Use TestrunMessages instead of Testrun.output when displaying output
This commit is contained in:
@ -17,4 +17,8 @@ class Testrun < ApplicationRecord
|
|||||||
|
|
||||||
validates :exit_code, numericality: {only_integer: true, min: 0, max: 255}, allow_nil: true
|
validates :exit_code, numericality: {only_integer: true, min: 0, max: 255}, allow_nil: true
|
||||||
validates :status, presence: true
|
validates :status, presence: true
|
||||||
|
|
||||||
|
def log
|
||||||
|
testrun_messages.output.select(:log).map(&:log).join.presence
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -33,6 +33,9 @@ class TestrunMessage < ApplicationRecord
|
|||||||
validates :log, length: {minimum: 0, allow_nil: false}, if: -> { cmd_write? }
|
validates :log, length: {minimum: 0, allow_nil: false}, if: -> { cmd_write? }
|
||||||
validate :either_data_or_log
|
validate :either_data_or_log
|
||||||
|
|
||||||
|
default_scope { order(timestamp: :asc) }
|
||||||
|
scope :output, -> { where(cmd: 1, stream: %i[stdout stderr]) }
|
||||||
|
|
||||||
def self.create_for(testrun, messages)
|
def self.create_for(testrun, messages)
|
||||||
# We don't want to store anything if the testrun passed
|
# We don't want to store anything if the testrun passed
|
||||||
return if testrun.passed?
|
return if testrun.passed?
|
||||||
|
@ -65,9 +65,9 @@ h1
|
|||||||
td.align-middle
|
td.align-middle
|
||||||
-this.testruns.includes(:file).order("files.name").each do |run|
|
-this.testruns.includes(:file).order("files.name").each do |run|
|
||||||
- if run.passed
|
- if run.passed
|
||||||
.unit-test-result.positive-result title=[run.file&.filepath, run.output].join("\n").strip
|
.unit-test-result.positive-result title=[run.file&.filepath, run.log].join.strip
|
||||||
- else
|
- else
|
||||||
.unit-test-result.unknown-result title=[run.file&.filepath, run.output].join("\n").strip
|
.unit-test-result.unknown-result title=[run.file&.filepath, run.log].join.strip
|
||||||
td = @working_times_until[index] if index > 0 if policy(@exercise).detailed_statistics?
|
td = @working_times_until[index] if index > 0 if policy(@exercise).detailed_statistics?
|
||||||
- elsif this.is_a? UserExerciseIntervention
|
- elsif this.is_a? UserExerciseIntervention
|
||||||
td = this.created_at.strftime("%F %T")
|
td = this.created_at.strftime("%F %T")
|
||||||
|
@ -38,20 +38,7 @@
|
|||||||
.collapsed.testrun-output.text
|
.collapsed.testrun-output.text
|
||||||
span.fa.fa-chevron-down.collapse-button
|
span.fa.fa-chevron-down.collapse-button
|
||||||
- output_runs.each do |testrun|
|
- output_runs.each do |testrun|
|
||||||
- output = testrun.try(:output)
|
pre= testrun.log or t('request_for_comments.no_output')
|
||||||
- if output
|
|
||||||
- Sentry.set_extras(output: output)
|
|
||||||
- begin
|
|
||||||
- Timeout::timeout(2) do
|
|
||||||
// (?:\\"|.) is required to correctly identify " within the output.
|
|
||||||
// The outer (?: |\d+?) is used to correctly identify integers within the JSON
|
|
||||||
- messages = output.scan(/{(?:(?:"(?:\\"|.)+?":(?:"(?:\\"|.)*?"|-?\d+?|\[.*?\]|null))+?,?)+}/)
|
|
||||||
- messages.map! {|el| JSON.parse(el)}
|
|
||||||
- messages.keep_if {|message| message['cmd'] == 'write'}
|
|
||||||
- messages.map! {|message| message['data']}
|
|
||||||
- output = messages.join ''
|
|
||||||
- rescue Timeout::Error
|
|
||||||
pre= output or t('request_for_comments.no_output')
|
|
||||||
|
|
||||||
- assess_runs = testruns.select {|run| run.cause == 'assess' }
|
- assess_runs = testruns.select {|run| run.cause == 'assess' }
|
||||||
- unless @current_user.admin?
|
- unless @current_user.admin?
|
||||||
@ -64,7 +51,7 @@
|
|||||||
div class=("result #{testrun.passed ? 'passed' : 'failed'}")
|
div class=("result #{testrun.passed ? 'passed' : 'failed'}")
|
||||||
.collapsed.testrun-output.text
|
.collapsed.testrun-output.text
|
||||||
span.fa.fa-chevron-down.collapse-button
|
span.fa.fa-chevron-down.collapse-button
|
||||||
pre= testrun.output or t('request_for_comments.no_output')
|
pre= testrun.log or t('request_for_comments.no_output')
|
||||||
|
|
||||||
- if @current_user.admin? && user.is_a?(ExternalUser)
|
- if @current_user.admin? && user.is_a?(ExternalUser)
|
||||||
= render('admin_menu')
|
= render('admin_menu')
|
||||||
|
Reference in New Issue
Block a user