Skip to content

0.19.0 change of Result.from_hash broke our coverage merging #920

@mobilutz

Description

@mobilutz

NOTE: This is NOT an issue, that breaks our implementation anymore.
This ticket is more created to talk about this topic as mentioned here as well: #913 (comment)

The behaviour change in v0.19.0 for Result.from_hash lead to some problem on the way we merge our ruby coverages.

This is the PR that for us was an unexpected change, specifically the change that the method now returns an array instead of a Result object.
#913

Maybe it is good, to describe how we use Result.from_hash.
This is the code, that broke for us:

results = []
all_results = Dir['/tmp/coverage/.resultset*.json']
all_results.each do |result_file_name|
  puts "Processing #{result_file_name}"
  results << SimpleCov::Result.from_hash(JSON.parse(File.read(result_file_name)))
end

SimpleCov::ResultMerger.merge_results(*results).format!

What exactly does this code do?

We are running our ruby suite on 8 different processes which produce 8 different .resultset.json files. After all of them are created, we combine them with the code above.
This code was written almost 2 years ago, and worked without any problems. I am not sure anymore, what other ways of merging the different results has been tried back then. Even though I worked on that, I cannot remember. The only thing I do remember is, that this code lead to a complete HTML coverage report generation, and the others did not.

Maybe there is an easier way to combine results from different runs, that do not share the same storage possibilities except S3.

PS: We now "solved" this situation by replacing the << inside the code above to +=. So it was not too hard for us to bring back our functionality - the hard part was finding what needed to be changed!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions