diff --git a/lib/gcovinator.rb b/lib/gcovinator.rb index 9faf1a9..230def9 100644 --- a/lib/gcovinator.rb +++ b/lib/gcovinator.rb @@ -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 diff --git a/lib/gcovinator/cli.rb b/lib/gcovinator/cli.rb index 25880fc..b1a530c 100644 --- a/lib/gcovinator/cli.rb +++ b/lib/gcovinator/cli.rb @@ -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