Spec: Improve jenkins page formatters

This will allow the test result pages in jenkins to *always*
show timestamps so it's clear what we mean by "oldest"
and "newest."

Change-Id: If7a317250eab118e961a0bc29103c86e134ce09c
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/240189
QA-Review: James Butters <jbutters@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Aaron Ogata <aogata@instructure.com>
Reviewed-by: James Butters <jbutters@instructure.com>
Product-Review: Derek Bender <djbender@instructure.com>
This commit is contained in:
Derek Bender 2020-06-15 09:05:08 -05:00
parent e9ad048677
commit 8b25095c54
2 changed files with 5 additions and 3 deletions

View File

@ -100,9 +100,10 @@ module ErrorContext
def note_recent_spec_run(example)
recent_spec_runs << {
location: RerunArgument.for(example),
exception: example.exception,
pending: example.pending
location: RerunArgument.for(example),
pending: example.pending,
recorded_at: Time.zone.now
}
self.num_failures += 1 if example.exception
end

View File

@ -60,13 +60,14 @@ module ErrorContext
base_path = "../" + ("../" * summary.spec_path.count("/"))
errors = ErrorSummary.recent_spec_runs.reverse.map do |run|
location = ERB::Util.html_escape(run[:location])
if run[:pending]
contents = if run[:pending]
"bin/rspec #{location} (pending)"
elsif run[:exception]
"bin/rspec <a href=\"#{base_path + location}/index.html\">#{location}</a> (failed)"
else
"bin/rspec #{location}"
end
"#{run[:recorded_at]}: #{contents}"
end.join("<br>")
"(newest)<br>#{errors}<br>(oldest)".html_safe