spec: coverage tool tweaking for test-queue

Change-Id: I694839ec7467d64fb306a3de70b49676d32a8e9b
Reviewed-on: https://gerrit.instructure.com/69606
Tested-by: Jenkins
Reviewed-by: Jon Jensen <jon@instructure.com>
Product-Review: Jon Jensen <jon@instructure.com>
QA-Review: Jon Jensen <jon@instructure.com>
This commit is contained in:
Shawn Meredith 2015-12-31 00:28:24 -08:00
parent 46aa7c724e
commit c11d4d15b1
3 changed files with 17 additions and 17 deletions

View File

@ -1,13 +1,3 @@
if ENV['COVERAGE'] == "1"
puts "Code Coverage enabled"
begin
require 'spec/coverage_tool'
CoverageTool.start("RSpec:#{Process.pid}#{ENV['TEST_ENV_NUMBER']}")
rescue LoadError => e
puts "Error: #{e}"
end
end
environment_configuration(defined?(config) && config) do |config|
if ENV['BULLET_GEM']

View File

@ -2,14 +2,12 @@ require 'simplecov'
class CoverageTool
def self.start(command_name)
SimpleCov.use_merging
SimpleCov.merge_timeout(10000)
SimpleCov.merge_timeout(3600)
SimpleCov.command_name(command_name)
SimpleCov.start('test_frameworks') do
SimpleCov.start do
SimpleCov.coverage_dir("#{ENV['WORKSPACE']}/coverage") if ENV['WORKSPACE']
SimpleCov.at_exit {
SimpleCov.result
}
# no formatting by default, just get the json
SimpleCov.at_exit { SimpleCov.result }
end
end
end
end

View File

@ -37,6 +37,12 @@ end
ENV["RAILS_ENV"] = 'test'
if ENV['COVERAGE'] == "1"
puts "Code Coverage enabled"
require 'coverage_tool'
CoverageTool.start("RSpec:#{Process.pid}#{ENV['TEST_ENV_NUMBER']}")
end
require File.expand_path('../../config/environment', __FILE__) unless defined?(Rails)
require 'rspec/rails'
@ -419,6 +425,12 @@ RSpec.configure do |config|
if ENV['TEST_ENV_NUMBER'].present?
Rails.logger.reopen("log/test#{ENV['TEST_ENV_NUMBER']}.log")
end
if ENV['COVERAGE'] == "1"
# do this in a hook so that results aren't clobbered under test-queue
# (it forks and changes the TEST_ENV_NUMBER)
SimpleCov.command_name("rspec:#{Process.pid}:#{ENV['TEST_ENV_NUMBER']}")
end
end
# this runs on post-merge builds to capture dependencies of each spec;