run gcov to produce .gcov files in a temporary directory

This commit is contained in:
Josh Holtrop 2017-01-14 11:52:48 -05:00
parent 7a34aa2c65
commit e61ec033a9
2 changed files with 19 additions and 1 deletions

View File

@ -1,12 +1,30 @@
require_relative "gcovinator/version"
require "tmpdir"
module Gcovinator
class << self
def run(build_dir, source_dirs, files, output_dir)
build_dir = File.expand_path(build_dir)
source_dirs = ["."] if source_dirs.empty?
source_dirs = source_dirs.map do |s|
File.expand_path(s)
end
files = Dir["#{build_dir}/**/*.gcda"] if files.empty?
files = files.map do |f|
File.expand_path(f)
end
output_dir = File.expand_path(output_dir)
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
files.each do |f|
IO.popen(["gcov", "-bmi", f]) do |io|
io.read
end
end
end
end
end
end

View File

@ -46,7 +46,7 @@ module Gcovinator
end.parse!(argv)
Gcovinator.run(build_dir, source_dirs, argv)
Gcovinator.run(build_dir, source_dirs, argv, output_dir)
end
end