Skip to content

Commit

Permalink
Exclude hidden files and folders (#721)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmijos authored and PragTob committed Jun 27, 2019
1 parent 5b380be commit aca64da
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@

## Enhancements

* Per default filter hidden files and folders. See [#721](https://github.com/colszowka/simplecov/pull/721) (thanks [Renuo AG](https://www.renuo.ch))
* Print the exit status explicitly when it's not a successful build so it's easier figure out SimpleCov failed the build in the output.

## Bugfixes
Expand Down
2 changes: 2 additions & 0 deletions lib/simplecov/defaults.rb
Expand Up @@ -6,12 +6,14 @@
require "simplecov/profiles/root_filter"
require "simplecov/profiles/test_frameworks"
require "simplecov/profiles/bundler_filter"
require "simplecov/profiles/hidden_filter"
require "simplecov/profiles/rails"

# Default configuration
SimpleCov.configure do
formatter SimpleCov::Formatter::HTMLFormatter
load_profile "bundler_filter"
load_profile "hidden_filter"
# Exclude files outside of SimpleCov.root
load_profile "root_filter"
end
Expand Down
5 changes: 5 additions & 0 deletions lib/simplecov/profiles/hidden_filter.rb
@@ -0,0 +1,5 @@
# frozen_string_literal: true

SimpleCov.profiles.define "hidden_filter" do
add_filter %r{^/\..*}
end
12 changes: 12 additions & 0 deletions spec/filters_spec.rb
Expand Up @@ -173,6 +173,18 @@ def a_file(path)
it "filters vendor/bundle" do
expect(SimpleCov.filtered([a_file("vendor/bundle/foo.rb")]).count).to eq(0)
end

it "filters hidden folders" do
expect(SimpleCov.filtered([a_file(".semaphore-cache/lib.rb")]).count).to eq(0)
end

it "filters hidden files" do
expect(SimpleCov.filtered([a_file(".hidden_config.rb")]).count).to eq(0)
end

it "doesn't filter hidden files further down the path" do
expect(SimpleCov.filtered([a_file("some_dir/.sneaky.rb")]).count).to eq(1)
end
end

context "outside the project" do
Expand Down

0 comments on commit aca64da

Please sign in to comment.