Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Avoid slow file output with JRuby/Windows #16

Merged
merged 2 commits into from
Jul 10, 2014
Merged
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
14 changes: 13 additions & 1 deletion lib/simplecov-html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,23 @@ def format(result)
FileUtils.cp_r(path, asset_output_path)
end

File.open(File.join(output_path, "index.html"), "w+") do |file|
File.open(File.join(output_path, "index.html"), file_mode_format) do |file|
file.puts template('layout').result(binding)
end
puts output_message(result)
end

def file_mode_format
format = 'w+'

# On JRuby/Windows it tries to convert all \n into \r\n in w+ mode.
# b mode is binary and outputs "as is".
if defined?(JRUBY_VERSION) && !!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/i)
format = 'wb+'
end

format
end

def output_message(result)
"Coverage report generated for #{result.command_name} to #{output_path}. #{result.covered_lines} / #{result.total_lines} LOC (#{result.covered_percent.round(2)}%) covered."
Expand Down