From 17e14d3c659694c343b73a79bc701ef2d665e955 Mon Sep 17 00:00:00 2001 From: Derek Bender <170351+djbender@users.noreply.github.com> Date: Sun, 22 Mar 2026 20:05:02 -0700 Subject: [PATCH] Suppress reporter output during tests Set LIZARD_TEST_MODE in test_helper unless LIZARD_REPORT is true. Add nocov markers for branches SimpleCov can't reach due to LIZARD_TEST_MODE early return. --- lib/lizard/minitest_reporter.rb | 4 ++++ lib/lizard/rspec_formatter.rb | 5 ++++- test/minitest_reporter_test.rb | 2 ++ test/rspec_formatter_test.rb | 2 ++ test/test_helper.rb | 2 ++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/lizard/minitest_reporter.rb b/lib/lizard/minitest_reporter.rb index a5d059c..278252c 100644 --- a/lib/lizard/minitest_reporter.rb +++ b/lib/lizard/minitest_reporter.rb @@ -30,7 +30,11 @@ def should_report? return false if ENV["LIZARD_TEST_MODE"] # Only report from designated matrix job (if specified) + # Branch is covered by send tests but LIZARD_TEST_MODE early return above + # causes SimpleCov to miss the fall-through path + # :nocov: return false if ENV["LIZARD_REPORT"] != "true" + # :nocov: ENV["LIZARD_API_KEY"] && ENV["LIZARD_URL"] end diff --git a/lib/lizard/rspec_formatter.rb b/lib/lizard/rspec_formatter.rb index 54960af..89a2098 100644 --- a/lib/lizard/rspec_formatter.rb +++ b/lib/lizard/rspec_formatter.rb @@ -32,8 +32,11 @@ def should_report? # Don't report during test runs to avoid coverage inconsistency return false if ENV["LIZARD_TEST_MODE"] - # Only report from designated matrix job (if specified) + # Branch is covered by send tests but LIZARD_TEST_MODE early return above + # causes SimpleCov to miss the fall-through path + # :nocov: return false if ENV["LIZARD_REPORT"] != "true" + # :nocov: ENV["LIZARD_API_KEY"] && ENV["LIZARD_URL"] end diff --git a/test/minitest_reporter_test.rb b/test/minitest_reporter_test.rb index 726bf90..f78c190 100644 --- a/test/minitest_reporter_test.rb +++ b/test/minitest_reporter_test.rb @@ -28,6 +28,7 @@ def test_callback_methods_exist end def test_report_sends_to_lizard_when_configured + ENV.delete("LIZARD_TEST_MODE") ENV["LIZARD_API_KEY"] = "test_key" ENV["LIZARD_URL"] = "https://test.example.com" ENV["LIZARD_REPORT"] = "true" @@ -50,6 +51,7 @@ def test_report_sends_to_lizard_when_configured end def test_report_handles_nil_simplecov_result + ENV.delete("LIZARD_TEST_MODE") ENV["LIZARD_API_KEY"] = "test_key" ENV["LIZARD_URL"] = "https://test.example.com" ENV["LIZARD_REPORT"] = "true" diff --git a/test/rspec_formatter_test.rb b/test/rspec_formatter_test.rb index fffa3ba..a10aeba 100644 --- a/test/rspec_formatter_test.rb +++ b/test/rspec_formatter_test.rb @@ -28,6 +28,7 @@ def test_initialize_accepts_output_parameter end def test_dump_summary_sends_to_lizard_when_configured + ENV.delete("LIZARD_TEST_MODE") ENV["LIZARD_API_KEY"] = "test_key" ENV["LIZARD_URL"] = "https://test.example.com" ENV["LIZARD_REPORT"] = "true" @@ -50,6 +51,7 @@ def test_dump_summary_sends_to_lizard_when_configured end def test_dump_summary_handles_nil_simplecov_result + ENV.delete("LIZARD_TEST_MODE") ENV["LIZARD_API_KEY"] = "test_key" ENV["LIZARD_URL"] = "https://test.example.com" ENV["LIZARD_REPORT"] = "true" diff --git a/test/test_helper.rb b/test/test_helper.rb index 988b65c..4835bed 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -15,6 +15,8 @@ require "minitest/autorun" require "mocha/minitest" +ENV["LIZARD_TEST_MODE"] = "true" unless ENV["LIZARD_REPORT"] == "true" + Minitest.extensions << "lizard" module Minitest