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

[Question] How can I merge two lcov files into one? #22

Open
zoras opened this issue Jan 14, 2019 · 3 comments
Open

[Question] How can I merge two lcov files into one? #22

zoras opened this issue Jan 14, 2019 · 3 comments

Comments

@zoras
Copy link

zoras commented Jan 14, 2019

No description provided.

@saimageshvar
Copy link

saimageshvar commented Jan 30, 2020

any updates on this?

@ghost
Copy link

ghost commented May 13, 2020

@zoras @saimageshvar
Looks like there is no direct ability to merge lcov files, but you can merge all simplecov resultset.*.json files into one and then generate lcov file from it:

# frozen_string_literal: true

require "simplecov"
require "simplecov-lcov"

class SimpleCovLcovGenerator
  def self.call(base_dir: "./coverage_results")
    new(base_dir: base_dir).generate
  end

  def initialize(base_dir:)
    @base_dir = base_dir
  end

  def generate
    configure_lcov_formatter
    configure_simple_cov
    collate_results
  end

  private

  attr_reader :base_dir

  def coverage_results
    Dir["#{base_dir}/.resultset.*.json"]
  end

  def collate_results
    SimpleCov.collate(coverage_results, "rails")
  end

  def configure_lcov_formatter
    SimpleCov::Formatter::LcovFormatter.config do |c|
      c.report_with_single_file = true
    end
  end

  def configure_simple_cov
    SimpleCov.configure do
      formatter SimpleCov::Formatter::LcovFormatter
    end
  end
end

SimpleCovLcovGenerator.call

@thorstenspringhart
Copy link

thorstenspringhart commented Jun 26, 2020

I use the npm package lcov-result-merger to merge two lcov files: https://github.com/mweibel/lcov-result-merger
With this i am able to merge my rails code coverage and the javascript coverage into one file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants