You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test_frameworks profile hides source directories with names like 'spec' or 'features' #1016
I'm the author of a gem called ruby-marc-spec that for domain-nomenclature reasons, has a main module called MARC::Spec, with source in a corresponding directory lib/marc/spec.
I recently noticed that SimpleCov was only covering the root file, lib/marc/spec.rb, and ignoring all the files under lib/marc/spec.
Coverage task fails with Coverage (99.87%) is below the expected minimum coverage (100.00%).
Generated HTML report in artifacts/rcov includes all source files under lib, including lib/marc/spec/queries/query_executor.rb, which has an uncovered line 47.
Actual
Coverage task suceeds.
Generated HTML report shows only lib/marc/spec.rb, with 100% coverage.
Discussion
The issue is with the filters in test_frameworks.rb, plain strings which each produce a StringFilter that will check for the presence of the substring anywhere in the file path. A regex filter, e.g. %r{^/spec/}, would instead exclude these directories only at the root of the project, which seems to be the intent.
(I also wonder about the similar bundler_filter.rb, but that one seems less likely to produce accidental false positives.)
Workarounds
In my case, the test_frameworks profile was being pulled in by the rails profile, which I didn't need (lazy cut-and-paste from a Rails project). I dropped back to the default profile and added a custom regex filter for the /spec directory to my .simplecov:
Activity
splattael commentedon Jul 1, 2025
This issue also applies to
/test/which filters paths likeapp/services/integrations/test/project_service.rbcausing undercoverage to fail. See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/194688#note_2594865548I'll go with the @dmolesUC's workaround for now 🎉
splattael commentedon Jul 1, 2025
I believe #1062 is also related.
Prevent test_frameworks profile to hide source directories
splattael commentedon Jul 1, 2025
#1133 to fix this issue.
Prevent test_frameworks profile to hide source directories