コード例 #1
0
ファイル: upstreamlint.py プロジェクト: anthrotype/fontbakery
    def execute(self, pipedata):
        task = self.bakery.logging_task('Run upstream tests')
        if self.bakery.forcerun:
            return


        result = {}
        upstreamdir = op.join(self.builddir, 'sources')

        self.bakery.logging_cmd('fontbakery-check.py upstream-repo sources')
        result['Project'] = run_set(upstreamdir, 'upstream-repo',
                                    log=self.bakery.logger)
        directory = UpstreamDirectory(upstreamdir)

        for font in directory.ALL_FONTS:
            if font[-4:] in '.ttx':
                self.bakery.logging_cmd('fontbakery-check.py upstream-ttx {}'.format(font))
                result[font] = run_set(op.join(upstreamdir, font),
                                       'upstream-ttx', log=self.bakery.logger)
            else:
                self.bakery.logging_cmd('fontbakery-check.py upstream {}'.format(font))
                result[font] = run_set(op.join(upstreamdir, font),
                                       'upstream', log=self.bakery.logger)

        _out_yaml = op.join(self.builddir, 'upstream.yaml')

        l = codecs.open(_out_yaml, mode='w', encoding="utf-8")
        l.write(yaml.safe_dump(result))
        l.close()
コード例 #2
0
    def execute(self, pipedata, prefix=""):
        _out_yaml = op.join(self.builddir, '.tests.yaml')

        if op.exists(_out_yaml):
            return yaml.safe_load(open(_out_yaml, 'r'))

        task = self.bakery.logging_task('Run tests for baked files')
        if self.bakery.forcerun:
            return

        try:
            result = {}
            for font in pipedata['bin_files']:
                self.bakery.logging_raw('### Test %s\n' % font)
                result[font] = run_set(op.join(self.builddir, font), 'result',
                                       log=self.bakery.log)

            self.bakery.logging_raw('### Test METADATA.json\n')
            result['METADATA.json'] = self.run_metadata_tests()
            self.bakery.logging_task_done(task)
        except:
            self.bakery.logging_task_done(task, failed=True)

        if not result:
            return

        self.write_lint_results(result)
コード例 #3
0
    def upstream_tests(self):
        result = {}
        source_dir = op.join(self.build_dir, 'sources')
        self.stdout_pipe.write('Run upstream tests\n', prefix='### ')

        result['/'] = run_set(source_dir, 'upstream-repo')
        for font in self.config.get('process_files', []):
            if font[-4:] in '.ttx':
                result[font] = run_set(op.join(source_dir, font),
                                       'upstream-ttx', log=self.stdout_pipe)
            else:
                result[font] = run_set(op.join(source_dir, font),
                                       'upstream', log=self.stdout_pipe)

        _out_yaml = op.join(source_dir, '.upstream.yaml')

        l = codecs.open(_out_yaml, mode='w', encoding="utf-8")
        l.write(yaml.safe_dump(result))
        l.close()
コード例 #4
0
ファイル: upstreamlint.py プロジェクト: davelab6/fontbakery
    def execute(self, pipedata):
        self.bakery.logging_task('Run upstream tests')
        if self.bakery.forcerun:
            return

        result = {}
        upstreamdir = op.join(self.builddir, 'sources')

        self.bakery.logging_cmd('fontbakery-check.py upstream-repo sources')
        result['Project'] = run_set(upstreamdir, 'upstream-repo')
        directory = UpstreamDirectory(upstreamdir)

        for font in directory.ALL_FONTS:
            if font[-4:] not in '.ttx':
                self.bakery.logging_cmd('fontbakery-check.py upstream {}'.format(font))
                result[font] = run_set(op.join(upstreamdir, font), 'upstream')

        _out_yaml = op.join(self.builddir, 'upstream.yaml')

        l = codecs.open(_out_yaml, mode='w', encoding="utf-8")
        l.write(yaml.safe_dump(result))
        l.close()
コード例 #5
0
ファイル: fontlint.py プロジェクト: adrientetar/fontbakery
    def run(self, ttf_path, pipedata):
        if 'downstream' in pipedata and not pipedata['downstream']:
            return

        self.bakery.logging_raw('### Test %s\n' % ttf_path)

        self.bakery.logging_cmd('fontbakery-check.py result {}'.format(ttf_path))

        try:
            data = run_set(op.join(self.builddir, ttf_path), 'result')
            l = open(os.path.join(self.builddir, '{}.yaml'.format(ttf_path[:-4])), 'w')
            l.write(yaml.safe_dump(data))
            l.close()
        except Exception as ex:
            traceback.print_exc(ex)
            self.bakery.logging_raw('Could not store tests result: {}'.format(ex))
            raise
コード例 #6
0
ファイル: fontlint.py プロジェクト: bitforks/fontbakery
    def run(self, pipedata):
        if 'downstream' in pipedata and not pipedata['downstream']:
            return

        from bakery_cli.utils import ProcessedFile
        processedfile = ProcessedFile()

        self.bakery.logging_raw('### Test %s\n' % processedfile)

        self.bakery.logging_cmd('fontbakery-check.py result {}'.format(processedfile))

        try:
            data = run_set(op.join(self.builddir, processedfile), 'result', apply_fix=True)
            l = open(os.path.join(self.builddir, '{}.yaml'.format(processedfile[:-4])), 'w')
            l.write(yaml.safe_dump(data))
            l.close()
        except Exception as ex:
            traceback.print_exc(ex)
            self.bakery.logging_raw('Could not store tests result: {}'.format(ex))
            raise
コード例 #7
0
ファイル: fontlint.py プロジェクト: anthrotype/fontbakery
    def run(self, ttf_path, pipedata):
        if 'downstream' in pipedata and not pipedata['downstream']:
            return

        self.bakery.logging_raw('### Test %s\n' % ttf_path)

        self.bakery.logging_cmd(
            'fontbakery-check.py result {}'.format(ttf_path))

        try:
            data = run_set(op.join(self.builddir, ttf_path),
                           'result',
                           log=self.bakery.logger)
            l = open(
                os.path.join(self.builddir, '{}.yaml'.format(ttf_path[:-4])),
                'w')
            l.write(yaml.safe_dump(data))
            l.close()
        except Exception as ex:
            traceback.print_exc(ex)
            self.bakery.logging_raw(
                'Could not store tests result: {}'.format(ex))
            raise
コード例 #8
0
 def run_metadata_tests(self):
     path = op.join(self.builddir, 'METADATA.json')
     return run_set(path, 'metadata', log=self.bakery.log)
コード例 #9
0
    args = parser.parse_args()

    if args.list_checks:
        from bakery_lint.base import tests_report
        print(tests_report('upstream'))
        sys.exit()

    for x in args.file:
        if not x.lower().endswith('.otf'):
            print('ER: {} is not OTF'.format(x), file=sys.stderr)
            continue
        failures = []
        success = []
        error = []

        result = run_set('upstream', test)
        failures += [(testklass._testMethodName, testklass._err_msg)
                     for testklass in result.get('failure', [])]
        error += [(testklass._testMethodName, testklass._err_msg)
                  for testklass in result.get('error', [])]
        success += [(testklass._testMethodName, 'OK')
                    for testklass in result.get('success', [])]

        if not bool(failures + error):
            if args.verbose:
                for testmethod, dummyvar in success:
                    print('OK: {}'.format(testmethod))
        else:
            for testmethod, errormessage in error:
                print('ER: {}: {}'.format(testmethod, errormessage))
            if args.verbose:
コード例 #10
0
        sys.exit()

    if not args.file:
        print("Missing files to test", file=sys.stderr)
        sys.exit(1)

    for x in args.file:
        failures = []
        success = []
        error = []
        tests = [args.test]

        if args.test == '*':
            tests = available_tests

        for test in tests:
            result = run_set(x, test)
            failures += [(x._testMethodName, x._err_msg)
                         for x in result.get('failure', [])]
            error += [(x._testMethodName, x._err_msg)
                      for x in result.get('error', [])]
            success += [(x._testMethodName, 'OK')
                        for x in result.get('success', [])]

        if not bool(failures + error):
            print('OK')
        else:
            import pprint
            _pprint = pprint.PrettyPrinter(indent=4)
            _pprint.pprint(failures + error + success)
コード例 #11
0
    parser = argparse.ArgumentParser()
    parser.add_argument('action', help="Action or target test suite",
                        choices=['list', 'result', 'upstream',
                                 'upstream-ttx', 'metadata',
                                 'description', 'upstream-repo'],)
    parser.add_argument('file', nargs="*", help="Test files, can be a list")
    parser.add_argument('--test', help="Test files, can be a list")
    parser.add_argument('--verbose', '-v', action='count',
                        help="Verbosity level", default=1)

    args = parser.parse_args()
    if args.action == 'list':
        tests_report()
        sys.exit()

    if not args.file:
        print("Missing files to test")
        sys.exit(1)

    for x in args.file:
        result = run_set(x, args.action, test_method=args.test)
        failures = map(lambda x: (x._testMethodName, x._err_msg), result.get('failure', []))
        error = map(lambda x: (x._testMethodName, x._err_msg), result.get('error', []))
        success = map(lambda x: (x._testMethodName, 'OK'), result.get('success', []))
        if not bool(failures + error):
            print 'OK'
        else:
            import pprint
            _pprint = pprint.PrettyPrinter(indent=4)
            _pprint.pprint(failures + error + success)
コード例 #12
0
 def run_metadata_tests(self):
     path = op.join(self.builddir, 'METADATA.json')
     return run_set(path, 'metadata', log=self.bakery.logger)
コード例 #13
0
ファイル: metadatalint.py プロジェクト: anthrotype/fontbakery
 def run_metadata_tests(self):
     path = op.join(self.builddir, 'METADATA.new.json')
     if not os.path.exists(path):
         path = op.join(self.builddir, 'METADATA.json')
     return run_set(path, 'metadata', log=self.bakery.logger)
コード例 #14
0
    if not args.file:
        print("Missing files to test", file=sys.stderr)
        sys.exit(1)

    for x in args.file:
        failures = []
        success = []
        error = []
        tests = [args.test]

        if args.test == '*':
            tests = available_tests

        for test in tests:
            result = run_set(x, test)
            failures += [(testklass._testMethodName, testklass._err_msg)
                         for testklass in result.get('failure', [])]
            error += [(testklass._testMethodName, testklass._err_msg)
                      for testklass in result.get('error', [])]
            success += [(testklass._testMethodName, 'OK')
                        for testklass in result.get('success', [])]

        if not bool(failures + error):
            if args.verbose:
                for testmethod, dummyvar in success:
                    print('OK: {}'.format(testmethod))
        else:
            for testmethod, errormessage in error:
                print('ER: {}: {}'.format(testmethod, errormessage))
            if args.verbose:
コード例 #15
0
 def run_metadata_tests(self):
     path = op.join(self.builddir, 'METADATA.json.new')
     if not os.path.exists(path):
         path = op.join(self.builddir, 'METADATA.json')
     return run_set(path, 'metadata')
コード例 #16
0
    args = parser.parse_args()

    if args.list_checks:
        from bakery_lint.base import tests_report
        print(tests_report('upstream'))
        sys.exit()

    for x in args.file:
        if not x.lower().endswith('.otf'):
            print('ER: {} is not OTF'.format(x), file=sys.stderr)
            continue
        failures = []
        success = []
        error = []

        result = run_set('upstream', test)
        failures += [(testklass._testMethodName, testklass._err_msg)
                     for testklass in result.get('failure', [])]
        error += [(testklass._testMethodName, testklass._err_msg)
                  for testklass in result.get('error', [])]
        success += [(testklass._testMethodName, 'OK')
                    for testklass in result.get('success', [])]

        if not bool(failures + error):
            if args.verbose:
                for testmethod, dummyvar in success:
                    print('OK: {}'.format(testmethod))
        else:
            for testmethod, errormessage in error:
                print('ER: {}: {}'.format(testmethod, errormessage))
            if args.verbose:
コード例 #17
0
    parser.add_argument('--test', help="Test files, can be a list")
    parser.add_argument('--verbose',
                        '-v',
                        action='count',
                        help="Verbosity level",
                        default=1)

    args = parser.parse_args()
    if args.action == 'list':
        tests_report()
        sys.exit()

    if not args.file:
        print("Missing files to test")
        sys.exit(1)

    for x in args.file:
        result = run_set(x, args.action, test_method=args.test)
        failures = map(lambda x: (x._testMethodName, x._err_msg),
                       result.get('failure', []))
        error = map(lambda x: (x._testMethodName, x._err_msg),
                    result.get('error', []))
        success = map(lambda x: (x._testMethodName, 'OK'),
                      result.get('success', []))
        if not bool(failures + error):
            print 'OK'
        else:
            import pprint
            _pprint = pprint.PrettyPrinter(indent=4)
            _pprint.pprint(failures + error + success)