Only try to generate html and xml coverage reports if the source .cover file exists

This commit is contained in:
Calen Pennington
2012-11-08 12:06:05 -05:00
parent 31e42a28f9
commit e50a442d88

View File

@@ -26,7 +26,7 @@ PACKAGE_REPO = "packages@gp.mitx.mit.edu:/opt/pkgrepo.incoming"
NORMALIZED_DEPLOY_NAME = DEPLOY_NAME.downcase().gsub(/[_\/]/, '-')
INSTALL_DIR_PATH = File.join(DEPLOY_DIR, NORMALIZED_DEPLOY_NAME)
# Set up the clean and clobber tasks
CLOBBER.include(BUILD_DIR, REPORT_DIR, 'cover*', '.coverage', 'test_root/*_repo', 'test_root/staticfiles')
CLOBBER.include(BUILD_DIR, REPORT_DIR, 'test_root/*_repo', 'test_root/staticfiles')
CLEAN.include("#{BUILD_DIR}/*.deb", "#{BUILD_DIR}/util")
def select_executable(*cmds)
@@ -198,20 +198,27 @@ namespace :coverage do
desc "Build the html coverage reports"
task :html => :report_dirs do
TEST_TASK_DIRS.each do |dir|
sh("coverage html --rcfile=#{dir}/.coveragerc || echo 'Unable to build coverage html for #{dir}'")
report_dir = report_dir_path(dir)
if !File.file?("#{report_dir}/.coverage")
next
end
sh("coverage html --rcfile=#{dir}/.coveragerc")
end
end
desc "Build the xml coverage reports"
task :xml => :report_dirs do
TEST_TASK_DIRS.each do |dir|
# Why doesn't the rcfile control the xml output file properly??
sh("coverage xml -o reports/#{dir}/coverage.xml --rcfile=#{dir}/.coveragerc || echo 'Unable to build coverage xml for #{dir}'")
end
end
report_dir = report_dir_path(dir)
TEST_TASK_DIRS.each do |dir|
CLOBBER.include("#{dir}/.coverage")
if !File.file?("#{report_dir}/.coverage")
next
end
# Why doesn't the rcfile control the xml output file properly??
sh("coverage xml -o #{report_dir}/coverage.xml --rcfile=#{dir}/.coveragerc")
end
end
end