From 956c76abfbb951ba911bb0196c997a7c5700b06f Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Sun, 27 Jul 2025 08:59:10 -0400 Subject: [PATCH] fix: elapsed time and use milliseconds feat: add filePathLocation to extra --- Gemfile.lock | 1 + lib/ctrf/r_spec_formatter.rb | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 37fde21..b99a6de 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -67,6 +67,7 @@ GEM PLATFORMS aarch64-linux + x86_64-linux DEPENDENCIES rake (~> 13.2) diff --git a/lib/ctrf/r_spec_formatter.rb b/lib/ctrf/r_spec_formatter.rb index 51449dc..6011ff5 100644 --- a/lib/ctrf/r_spec_formatter.rb +++ b/lib/ctrf/r_spec_formatter.rb @@ -12,7 +12,7 @@ def initialize(output) def start(_notification) @tests = {} - @run_start = Time.now.to_i + @run_start = Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond) end def example_started(notification) @@ -29,7 +29,8 @@ def example_started(notification) # Otherwise, this could is the location of the `it` - even if that's in a helper file unrelated to the test filePath: notification.example.id, extra: { - hash: notification.example.hash + hash: notification.example.hash, + filePathLocation: notification.example.location } } end @@ -52,9 +53,9 @@ def retry(example) def example_finished(notification) test = @tests[notification.example.hash] - test[:duration] = notification.example.execution_result.run_time * 1000 - test[:start] = notification.example.execution_result.started_at.to_i - test[:stop] = notification.example.execution_result.finished_at.to_i + test[:duration] = notification.example.execution_result.run_time.to_i * 1000 + test[:start] = notification.example.execution_result.started_at.to_i * 1000 + test[:stop] = notification.example.execution_result.finished_at.to_i * 1000 test[:status] = notification.example.execution_result.status.to_s test[:rawStatus] = notification.example.execution_result.status @@ -90,7 +91,7 @@ def stop(_notification) skipped: @tests.values.select { |test| test[:status] == 'skipped' }.count, other: @tests.values.select { |test| test[:status] == 'other' }.count, start: @run_start, - stop: Time.now.to_i + stop: Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond) }, tests: @tests.values }