コード例 #1
0
ファイル: codecov.py プロジェクト: brendandahl/services
    def rewrite_jsvm_lcov(self):
        files = os.listdir('ccov-artifacts')
        for fname in files:
            if 'jsvm' not in fname or not fname.endswith('.zip'):
                continue

            zip_file_path = 'ccov-artifacts/' + fname
            out_dir = 'ccov-artifacts/' + fname[:-4]

            zip_file = zipfile.ZipFile(zip_file_path, 'r')
            zip_file.extractall(out_dir)
            zip_file.close()

            lcov_files = [
                os.path.abspath(os.path.join(out_dir, f))
                for f in os.listdir(out_dir)
            ]
            run([
                'gecko-env', './mach', 'python',
                'python/mozbuild/mozbuild/codecoverage/lcov_rewriter.py'
            ] + lcov_files,
                cwd=self.repo_dir)

            for lcov_file in lcov_files:
                os.remove(lcov_file)

            lcov_out_files = [
                os.path.abspath(os.path.join(out_dir, f))
                for f in os.listdir(out_dir)
            ]
            for lcov_out_file in lcov_out_files:
                os.rename(lcov_out_file, lcov_out_file[:-4])
コード例 #2
0
ファイル: lint.py プロジェクト: ahal/services
    def find_issues(self, path, modified_lines):
        '''
        Run mozlint through mach, without gecko-env
        '''

        # Run mozlint on a file
        command = ['./mach', 'lint', '-f', 'json', '--no-ignore', path]
        returncode, output, error = run(' '.join(command), cwd=self.repo_dir)
        if returncode == 0:
            logger.debug('No Mozlint errors', path=path)
            return

        # Load output as json
        # Only consider last line, as ./mach lint may output
        # linter setup output on stdout :/
        try:
            lines = list(filter(None, output.decode('utf-8').split('\n')))
            payload = json.loads(lines[-1])
        except json.decoder.JSONDecodeError:
            logger.warn('Invalid json output', path=path)
            return

        full_path = os.path.join(self.repo_dir, path)
        if full_path not in payload:
            logger.warn('Missing path in linter output', path=path)
            return

        return [
            MozLintIssue(self.repo_dir, path, modified_lines, **issue)
            for issue in payload[full_path]
        ]
コード例 #3
0
    def find_issues(self, path):
        '''
        Run mozlint through mach, using gecko-env
        '''

        # Run mozlint on a file
        command = [
            'gecko-env', './mach', 'lint', '-f', 'json', '--quiet', path
        ]
        returncode, output, error = run(' '.join(command),
                                        cwd=settings.repo_dir)
        if returncode == 0:
            logger.debug('No Mozlint errors', path=path)
            return

        # Load output as json
        # Only consider last line, as ./mach lint may output
        # linter setup output on stdout :/
        try:
            lines = list(filter(None, output.decode('utf-8').split('\n')))
            payload = json.loads(lines[-1])
        except json.decoder.JSONDecodeError:
            logger.warn('Invalid json output', path=path, lines=lines)
            raise

        full_path = os.path.join(settings.repo_dir, path)
        if full_path not in payload and path not in payload:
            logger.warn('Missing path in linter output', path=path)
            return

        # Mozlint uses both full & relative path to index issues
        return [
            MozLintIssue(**issue) for p in (path, full_path)
            for issue in payload.get(p, [])
        ]
コード例 #4
0
ファイル: lint.py プロジェクト: La0/mozilla-relengapi
    def find_issues(self, path, revision):
        '''
        Run mozlint through mach, using gecko-env
        '''
        # Check file exists (before mode)
        full_path = os.path.join(settings.repo_dir, path)
        if not os.path.exists(full_path):
            logger.info('Modified file not found {}'.format(full_path))
            return

        # Run mozlint on a file
        command = [
            'gecko-env',
            './mach', 'lint',
            '-f', 'json',
            '--warnings',
            '--quiet',
            path
        ]
        returncode, output, error = run(' '.join(command), cwd=settings.repo_dir)
        output = output.decode('utf-8')

        # Dump raw mozlint output as a Taskcluster artifact (for debugging)
        output_path = os.path.join(
            settings.taskcluster.results_dir,
            '{}-mozlint.txt'.format(repr(revision)),
        )
        with open(output_path, 'a') as f:
            f.write(output)

        if returncode == 0:
            logger.debug('No Mozlint errors', path=path)
            return
        assert 'error: problem with lint setup' not in output, \
            'Mach lint setup failed'

        # Load output as json
        # Only consider last line, as ./mach lint may output
        # linter setup output on stdout :/
        try:
            lines = list(filter(None, output.split('\n')))
            payload = json.loads(lines[-1])
        except json.decoder.JSONDecodeError:
            raise AnalysisException('mozlint', 'Invalid json output', path=path, lines=lines)

        if full_path not in payload and path not in payload:
            logger.warn('Missing path in linter output', path=path)
            return

        # Mozlint uses both full & relative path to index issues
        return [
            MozLintIssue(revision=revision, **issue)
            for p in (path, full_path)
            for issue in payload.get(p, [])
        ]
コード例 #5
0
    def find_issues(self, path, revision):
        '''
        Run mozlint through mach, using gecko-env
        '''
        # Check file exists (before mode)
        full_path = os.path.join(settings.repo_dir, path)
        if not os.path.exists(full_path):
            logger.info('Modified file not found {}'.format(full_path))
            return

        # Run mozlint on a file
        command = [
            'gecko-env',
            './mach', 'lint',
            '-f', 'json',
            '--quiet',
            path
        ]
        returncode, output, error = run(' '.join(command), cwd=settings.repo_dir)
        output = output.decode('utf-8')

        # Dump raw mozlint output as a Taskcluster artifact (for debugging)
        output_path = os.path.join(
            settings.taskcluster.results_dir,
            '{}-mozlint.txt'.format(repr(revision)),
        )
        with open(output_path, 'a') as f:
            f.write(output)

        if returncode == 0:
            logger.debug('No Mozlint errors', path=path)
            return
        assert 'error: problem with lint setup' not in output, \
            'Mach lint setup failed'

        # Load output as json
        # Only consider last line, as ./mach lint may output
        # linter setup output on stdout :/
        try:
            lines = list(filter(None, output.split('\n')))
            payload = json.loads(lines[-1])
        except json.decoder.JSONDecodeError:
            raise AnalysisException('mozlint', 'Invalid json output', path=path, lines=lines)

        if full_path not in payload and path not in payload:
            logger.warn('Missing path in linter output', path=path)
            return

        # Mozlint uses both full & relative path to index issues
        return [
            MozLintIssue(revision=revision, **issue)
            for p in (path, full_path)
            for issue in payload.get(p, [])
        ]