Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recurse upward looking for .simplecov #423

Merged
merged 1 commit into from
Nov 29, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions lib/simplecov/defaults.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Load default formatter gem
require "simplecov-html"
require "pathname"

SimpleCov.profiles.define "root_filter" do
# Exclude all files outside of simplecov root
Expand Down Expand Up @@ -97,5 +98,20 @@
end

# Autoload config from .simplecov if present
config_path = File.join(SimpleCov.root, ".simplecov")
load config_path if File.exist?(config_path)
# Recurse upwards until we find .simplecov or reach the root directory

config_path = Pathname.new(SimpleCov.root)
loop do
filename = config_path.join(".simplecov")
if filename.exist?
begin
load filename
rescue LoadError, StandardError
$stderr.puts "Warning: Error occurred while trying to load #{filename}. " \
"Error message: #{$!.message}"
end
break
end
config_path, = config_path.split
break if config_path.root?
end