Ejemplo n.º 1
0
    def coverage(self):
        """
        Check test coverage. Print coverage if coverage information exist in frigg configuration
        """
        try:

            if self.config.get('coverage', False):
                coverage_file = os.path.join(self.directory,
                                             self.config['coverage']['path'])
                parser = self.config['coverage']['parser']
                coverage_report = None

                if os.path.exists(coverage_file):
                    with open(coverage_file, 'r') as file:
                        coverage_report = file.read()

                coverage = frigg_coverage.parse_coverage(
                    coverage_report, parser)

                click.secho('Coverage %s%s' %
                            (round(coverage, ndigits=2), '%'),
                            fg='blue')

        except (KeyError, TypeError, OSError) as exception:
            click.secho('Unable to parse the coverage report.', fg='red')
            click.secho(str(exception), fg='red')
            return exit_build(False)
Ejemplo n.º 2
0
def test_parse_coverage():
    assert parse_coverage('', '') == NotImplemented
    assert parse_coverage('', 'python') is None
    assert parse_coverage('', 'clover') is None
    assert parse_coverage('', 'cobertura') is None
    assert parse_coverage('', 'go-coverprofile') is None
    assert parse_coverage('', 'go-cover') is None
Ejemplo n.º 3
0
 def parse_coverage(self):
     if 'coverage' in self.settings:
         try:
             coverage_file = os.path.join(
                 self.working_directory,
                 self.settings['coverage']['path']
             )
             self.coverage = parse_coverage(
                 self.docker.read_file(coverage_file),
                 self.settings['coverage']['parser']
             )
         except Exception as e:
             logger.exception(e)
Ejemplo n.º 4
0
def test_parse_coverage():
    assert parse_coverage('', '') == NotImplemented
    assert parse_coverage('', 'python') is None
    assert parse_coverage('', 'clover') is None
    assert parse_coverage('', 'cobertura') is None
Ejemplo n.º 5
0
def test_parse_coverage_report():
    with open('fixtures/go_coverprofile.out') as f:
        assert parse_coverage(f.read(), 'go-coverprofile') == 98.73
Ejemplo n.º 6
0
def test_parse_coverage_report():
    with open('fixtures/cobertura.xml') as f:
        assert parse_coverage(f.read(), 'cobertura') == 88.24