Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Create new task to open file with results #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Rcov::RcovTask.new do |t|
t.ruby_opts << "-Ilib:ext/rcovrt" # in order to use this rcov
t.rcov_opts << "--xrefs" # comment to disable cross-references
t.verbose = true
t.display_results
end

desc "Analyze code coverage for the FileStatistics class."
Expand Down
23 changes: 23 additions & 0 deletions lib/rcov/rcovtask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,28 @@ def file_list # :nodoc:
FileList[result]
end
end

# It finds output dir with coverage results
# and opens index.html file.
# So far the task is created in case of using for MAC platform.
def display_results
path_to_output_dir = "./#{@output_dir}"
path_to_file = "#{path_to_output_dir}/index.html"
# It works only for MAC
return false if !RUBY_PLATFORM.downcase.include?("darwin")
desc "Display coverage results for #{name}"
task "#{name}:display" do
puts "Opening, please wait..."
if !File.directory?(path_to_output_dir)
puts "Rcov hasn't been run yet. Folder #{path_to_output_dir} doesn't exist."
return false
end
if File.exist?(path_to_file)
system("open #{path_to_file}")
else
puts "Couldn't find #{path_to_file}."
end
end
end
end
end