From e50a442d883a6d671ed94b983c15c21a8a7b4a80 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 8 Nov 2012 12:06:05 -0500 Subject: [PATCH] Only try to generate html and xml coverage reports if the source .cover file exists --- rakefile | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/rakefile b/rakefile index 8bdc859a2e..f06b9c3633 100644 --- a/rakefile +++ b/rakefile @@ -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