From 9d6321685ec40d4cfdfd9a1047fd1b425b25710e Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 27 Jan 2026 22:50:34 -0500 Subject: [PATCH] Clean up simplecov reporting --- Gemfile | 2 +- Gemfile.lock | 15 ++++++++------- Rakefile.rb | 13 ++++++++++++- build_tests/build_tests.rb | 13 +++++++------ spec/spec_helper.rb | 5 +++++ 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Gemfile b/Gemfile index ec1cbe1..71c476d 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gem "base64" gem "rspec" gem "rake" -gem "simplecov", "~> 0.15.0" +gem "simplecov" gem "openssl" if RbConfig::CONFIG["host"]["msys"] gem "json", "2.1.0" diff --git a/Gemfile.lock b/Gemfile.lock index 77a4b8f..6f1d01f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,7 +4,7 @@ GEM base64 (0.3.0) date (3.5.1) diff-lcs (1.6.2) - docile (1.1.5) + docile (1.4.1) erb (6.0.1) json (2.18.0) openssl (4.0.0) @@ -30,11 +30,12 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.6) - simplecov (0.15.1) - docile (~> 1.1.0) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.2) + simplecov_json_formatter (0.1.4) stringio (3.2.0) syntax (1.2.2) tsort (0.2.0) @@ -52,7 +53,7 @@ DEPENDENCIES rdoc redcarpet rspec - simplecov (~> 0.15.0) + simplecov syntax yard diff --git a/Rakefile.rb b/Rakefile.rb index 2e95728..701b941 100644 --- a/Rakefile.rb +++ b/Rakefile.rb @@ -8,6 +8,8 @@ end require "rspec/core/rake_task" require "rake/clean" require "fileutils" +require "simplecov" +require "stringio" CLEAN.include %w[build_test_run .yardoc yard coverage test_run] CLOBBER.include %w[dist gen large_project pkg] @@ -22,11 +24,20 @@ RSpec::Core::RakeTask.new(:spec, :example_string) do |task, args| task.rspec_opts = %W[-e "#{args.example_string}" -f documentation] end end -task :spec => :build_dist task :spec do ENV.delete("specs") end task :spec => :build_tests +task :spec do + original_stdout = $stdout + sio = StringIO.new + $stdout = sio + SimpleCov.collate Dir["coverage/.resultset.json", "coverage/bt*/.resultset.json"] + $stdout = original_stdout + sio.string.lines.each do |line| + $stdout.write(line) unless line =~ /Coverage report generated for/ + end +end task :build_tests do |task, args| ENV["specs"] = "1" diff --git a/build_tests/build_tests.rb b/build_tests/build_tests.rb index 89e9895..ef1c193 100644 --- a/build_tests/build_tests.rb +++ b/build_tests/build_tests.rb @@ -18,12 +18,13 @@ class Test attr_reader :name attr_accessor :output - def initialize(name, id, block) - @name = name + def initialize(desc, id, block) + @desc = desc @id = id - @run_dir = "#{BASE_DIR}/bt#{@id}" + @name = "bt#{sprintf("%03d", @id)}" + @run_dir = "#{BASE_DIR}/#{@name}" @block = block - @coverage_dir = "#{OWD}/coverage/bt#{@id}" + @coverage_dir = "#{OWD}/coverage/#{@name}" @output = "" end @@ -103,7 +104,7 @@ end SimpleCov.start do root(#{OWD.inspect}) coverage_dir(#{@coverage_dir.inspect}) - command_name "build_tests" + command_name "#{@name}" filters.clear add_filter do |src| !(src.filename[SimpleCov.root]) @@ -133,7 +134,7 @@ EOF end # Remove output lines generated as a result of the test environment stderr = stderr.lines.find_all do |line| - not (line =~ /Warning: coverage data provided by Coverage.*exceeds number of lines/) + not (line =~ /Warning: coverage data provided by Coverage.*exceeds number of lines|Stopped processing SimpleCov/) end.join RunResults.new(stdout, stderr, status) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b2ef5fe..fa7a941 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,6 +3,10 @@ if ENV["rscons_dist_specs"] else require "simplecov" + class MyFormatter + def format(*args) + end + end SimpleCov.start do add_filter "/spec/" add_filter "/.bundle/" @@ -14,6 +18,7 @@ else add_filter "test/rscons.rb" project_name "Rscons" merge_timeout 3600 + formatter(MyFormatter) end require "rscons"