Skip to content

Commit

Permalink
use just the first part instead of trying to merge it
Browse files Browse the repository at this point in the history
  • Loading branch information
evsasse committed Dec 13, 2024
1 parent 0a3dcb4 commit 4729d21
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,27 @@ def generate_bundled_html
end

def simplecov_generate_bundled_html
with_folder_with_unzipped_parts do |tempdir|
# `File::FNM_DOTMATCH` to also include hidden files
resultset_json_filepaths = Dir.glob(File.join(tempdir, "**", "*resultset.json"), File::FNM_DOTMATCH)

# SimpleCov needs access to the code to merge the results
some_part_routes_file = Dir.glob(File.join(tempdir, "**", "code/config/routes.rb")).first
code_path = some_part_routes_file.split("/config/routes.rb").first
FileUtils.copy_entry code_path, tempdir

merged_folder_path = File.join(tempdir, "SIMPLECOV-MERGED-COVERAGE")
SimpleCov.collate(resultset_json_filepaths, "rails") do
coverage_dir(merged_folder_path)
end
bundled_html = parts.first.blob

merged_zip_path = "#{merged_folder_path}.zip"
Files::ZipFileGenerator.new(merged_folder_path, merged_zip_path).call
# with_folder_with_unzipped_parts do |tempdir|
# # `File::FNM_DOTMATCH` to also include hidden files
# resultset_json_filepaths = Dir.glob(File.join(tempdir, "**", "*resultset.json"), File::FNM_DOTMATCH)

bundled_html.attach(io: File.open(merged_zip_path), filename: "bundled_html.zip", content_type: "application/zip")
end
# # SimpleCov needs access to the code to merge the results
# some_part_routes_file = Dir.glob(File.join(tempdir, "**", "code/config/routes.rb")).first
# code_path = some_part_routes_file.split("/config/routes.rb").first
# FileUtils.copy_entry code_path, tempdir

# merged_folder_path = File.join(tempdir, "SIMPLECOV-MERGED-COVERAGE")
# SimpleCov.collate(resultset_json_filepaths, "rails") do
# coverage_dir(merged_folder_path)
# end

# merged_zip_path = "#{merged_folder_path}.zip"
# Files::ZipFileGenerator.new(merged_folder_path, merged_zip_path).call

# bundled_html.attach(io: File.open(merged_zip_path), filename: "bundled_html.zip", content_type: "application/zip")
# end
end

def simplecov_generate_results
Expand Down

0 comments on commit 4729d21

Please sign in to comment.