Skip to content

Commit

Permalink
Merge pull request #423 from alexdowad/config
Browse files Browse the repository at this point in the history
Recurse upward looking for .simplecov
  • Loading branch information
xaviershay committed Nov 29, 2015
2 parents 4383513 + 1b5736f commit 8113d50
Showing 1 changed file with 18 additions and 2 deletions.
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

0 comments on commit 8113d50

Please sign in to comment.