diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cf1b27..79350ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- Add support for including and exluding files by glob patterns, supplied through CLI args and the configuration file (#146) + +### Fixed +- Files that were changed but don't appear in the coverage report at all will now be reported as uncovered, as expected. +- Fixed an issue where top-level methods were not being considered (#135). This was caused by a bug in the tree traversal logic. # [0.5.0] - 2024-01-09 ### Changed diff --git a/spec/changeset_spec.rb b/spec/changeset_spec.rb index 5a4c7f3..49f3be4 100644 --- a/spec/changeset_spec.rb +++ b/spec/changeset_spec.rb @@ -12,7 +12,7 @@ ).update expect(changeset.files.keys).to match_array( - %w[file_one file_two staged_file class.rb module.rb] + %w[file_one file_two staged_file class.rb module.rb sinatra.rb] ) expect(changeset.files['file_two']).to eq([7, 10, 11]) end @@ -24,7 +24,7 @@ ).update expect(changeset.file_paths).to match_array( - %w[file_one file_three file_two staged_file class.rb module.rb] + %w[file_one file_three file_two staged_file class.rb module.rb sinatra.rb] ) expect(changeset.files['file_two']).to eq([7, 10, 11]) expect(changeset.files['file_three']).to eq([1, 2, 3, 4, 5, 6]) diff --git a/spec/fixtures/Rakefile b/spec/fixtures/Rakefile index a561c89..e5c6128 100644 --- a/spec/fixtures/Rakefile +++ b/spec/fixtures/Rakefile @@ -4,7 +4,7 @@ require 'bundler/gem_tasks' require 'rspec/core/rake_task' require 'rubocop/rake_task' -def rakefile # TODO: fix known issue of not parsing top-level expressions! +def rakefile desc 'Run RuboCop' RuboCop::RakeTask.new(:rubocop) diff --git a/spec/fixtures/sinatra.rb b/spec/fixtures/sinatra.rb new file mode 100644 index 0000000..f5c5de2 --- /dev/null +++ b/spec/fixtures/sinatra.rb @@ -0,0 +1,4 @@ +require 'sinatra' +get '/dummy_path' do + "This line is not covered" +end diff --git a/spec/fixtures/test.git/index b/spec/fixtures/test.git/index index 0d56d92..1ea5dd2 100644 Binary files a/spec/fixtures/test.git/index and b/spec/fixtures/test.git/index differ diff --git a/spec/fixtures/test.git/objects/f5/c5de24d9a10dec82ef9f5f16ed1e89cf30ac00 b/spec/fixtures/test.git/objects/f5/c5de24d9a10dec82ef9f5f16ed1e89cf30ac00 new file mode 100644 index 0000000..8cca379 Binary files /dev/null and b/spec/fixtures/test.git/objects/f5/c5de24d9a10dec82ef9f5f16ed1e89cf30ac00 differ diff --git a/spec/report_spec.rb b/spec/report_spec.rb index 4d644d4..97ba2dc 100644 --- a/spec/report_spec.rb +++ b/spec/report_spec.rb @@ -21,7 +21,7 @@ it 'builds a report with coverage metrics' do report.build - expect(report.results.size).to eq(2) + expect(report.results.size).to eq(3) all = report.all_results expect(all[0]).to be_an(Undercover::Result) expect(all[0].coverage_f).to eq(0.8333) @@ -54,6 +54,15 @@ expect(unflagged[0].coverage_f).to eq(0.875) expect(unflagged[1].name).to eq('baz') expect(unflagged[1].coverage_f).to eq(1.0) + + # includes blocks at top-level (reproduce https://github.com/grodowski/undercover/issues/135) + top_level_results = report.results['sinatra.rb'].to_a + expect(top_level_results.size).to eq(1) + expect(top_level_results[0].name).to eq('block') + expect(top_level_results[0].coverage_f).to eq(0.0) + expect(top_level_results[0].flagged?).to eq(true) + expect(top_level_results[0].first_line).to eq(2) + expect(top_level_results[0].last_line).to eq(4) end it 'does not parse files outside of the lcov report' do @@ -67,13 +76,13 @@ it 'builds pathnames relative to --path' do report.build - expect(report.results.keys.sort).to eq(%w[class.rb module.rb]) + expect(report.results.keys.sort).to eq(%w[class.rb module.rb sinatra.rb]) end it 'builds does not mess up with result keys' do report.build - expect(report.results.keys.sort).to eq(%w[class.rb module.rb]) + expect(report.results.keys.sort).to eq(%w[class.rb module.rb sinatra.rb]) end context 'with mock changeset' do