Created
June 24, 2016 17:03
-
-
Save fornellas/02192f5b55a063a794174753a93fdd24 to your computer and use it in GitHub Desktop.
simplecov with multiple Ruby executions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'securerandom' | |
require 'simplecov' | |
# Ensure a unique ID for each ruby process execution | |
SimpleCov.command_name("#{SecureRandom.uuid}_#{$0} #{ARGV}") | |
# Just save result, do not output anything here | |
SimpleCov.at_exit { SimpleCov.result } | |
# Ensure correct root always | |
SimpleCov.root File.dirname(__FILE__) | |
SimpleCov.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure that all ruby process instances use Simplecov | |
task :simplecov_setup do | |
ENV['RUBYLIB'] = "#{Dir.pwd}:#{ENV['RUBYLIB']}" | |
ENV['RUBYOPT'] = '-r configure_simplecov' | |
sh 'rm -rf coverage/' | |
end | |
# Generate a final report, with all merged results | |
task :simplecov_report do | |
require 'simplecov' | |
SimpleCov.command_name('rake') | |
SimpleCov.minimum_coverage 97 | |
SimpleCov.start | |
end | |
desc "Run all tests" | |
task test: [ | |
:simplecov_setup, | |
:execute_tests, | |
:simplecov_report | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment