From 8b25095c544cdb85cce53deed13ad101f429bd0e Mon Sep 17 00:00:00 2001 From: Derek Bender Date: Mon, 15 Jun 2020 09:05:08 -0500 Subject: [PATCH] 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 Tested-by: Service Cloud Jenkins Reviewed-by: Aaron Ogata Reviewed-by: James Butters Product-Review: Derek Bender --- spec/formatters/error_context/base_formatter.rb | 5 +++-- spec/formatters/error_context/html_page_formatter.rb | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/formatters/error_context/base_formatter.rb b/spec/formatters/error_context/base_formatter.rb index ec5a5089c97..750db71a095 100644 --- a/spec/formatters/error_context/base_formatter.rb +++ b/spec/formatters/error_context/base_formatter.rb @@ -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 diff --git a/spec/formatters/error_context/html_page_formatter.rb b/spec/formatters/error_context/html_page_formatter.rb index 8b85899361b..0d702065d0c 100644 --- a/spec/formatters/error_context/html_page_formatter.rb +++ b/spec/formatters/error_context/html_page_formatter.rb @@ -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 #{location} (failed)" else "bin/rspec #{location}" end + "#{run[:recorded_at]}: #{contents}" end.join("
") "(newest)
#{errors}
(oldest)".html_safe