Пример #1
0
def upstream_revision_tests(project, revision, log=None):
    """ This function run upstream tests on all sources fonts in project.

        This mean that success (aka getting any result) should be occasional
        particular case. Because data and set of folders are changing during
        font development process.

        Args:
            project: A :class:`~bakery.models.Project` instance
            revision: Git revision

        Returns:
            A dict with serialized tests results formatted by `repr_testcase`.
    """
    param = {'login': project.login, 'id': project.id, 'revision': revision}

    _in = joinroot('%(login)s/%(id)s.in/' % project)
    _out_folder = joinroot('%(login)s/%(id)s.out/utests/' % param)
    _out_yaml = op.join(_out_folder, '%(revision)s.yaml' % param)

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

    if not op.exists(_out_folder):
        os.makedirs(_out_folder)

    result = {}
    os.chdir(_in)

    try:
        git_checkout(_in, revision)

        result[project.clone] = run_set(_in, 'upstream-repo', log=log)

        ufo_dirs, ttx_files, metadata_files = get_sources_lists(_in)

        for font in ufo_dirs:
            if op.exists(op.join(_in, font)):
                result[font] = run_set(op.join(_in, font), 'upstream', log=log)

        for metadata_path in metadata_files:
            result[metadata_path] = run_set(metadata_path, 'metadata', log=log)

        for font in ttx_files:
            if op.exists(op.join(_in, font)):
                result[font] = run_set(op.join(_in, font), 'upstream-ttx', log=log)

        l = open(_out_yaml, mode='w')
        l.write(yaml.safe_dump(result))
        l.close()

        return yaml.safe_load(open(_out_yaml, 'r'))
    except Exception, ex:
        if log:
            log.write('UPSTREAM: FAILED')
            log.write('Details: %s' % ex)
        return {}
Пример #2
0
def upstream_revision_tests(project, revision):
    """ This function run upstream tests set on
    project.config['local']['ufo_dirs'] set in selected git revision.
    This mean that success (aka getting any result) should be occasional
    particular case. Because data and
    set of folders are changing during font development process.

    :param project: Project instance
    :param revision: Git revision
    :param force: force to make tests again
    :return: dictionary with serialized tests results formatted by `repr_testcase`
    """
    param = {'login': project.login, 'id': project.id, 'revision': revision}

    _in = os.path.join(DATA_ROOT, '%(login)s/%(id)s.in/' % project)
    _out_folder = os.path.join(DATA_ROOT, '%(login)s/%(id)s.out/utests/' % param)
    _out_yaml = os.path.join(DATA_ROOT, '%(login)s/%(id)s.out/utests/%(revision)s.yaml' % param)

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

    if not os.path.exists(_out_folder):
        os.makedirs(_out_folder)

    result = {}
    os.chdir(_in)
    prun("git checkout %s" % revision, cwd=_in)

    ufo_dirs = []
    ttx_files = []
    l = len(_in)
    for root, dirs, files in os.walk(_in):
        for f in files:
            fullpath = os.path.join(root, f)
            if os.path.splitext(fullpath)[1].lower() in ['.ttx', ]:
                ttx_files.append(fullpath[l:])
        for d in dirs:
            fullpath = os.path.join(root, d)
            if os.path.splitext(fullpath)[1].lower() == '.ufo':
                ufo_dirs.append(fullpath[l:])

    for font in ufo_dirs:
        if os.path.exists(os.path.join(_in, font)):
            result[font] = run_set(os.path.join(_in, font), 'upstream')

    for font in ttx_files:
        if os.path.exists(os.path.join(_in, font)):
            result[font] = run_set(os.path.join(_in, font), 'upstream-ttx')

    l = codecs.open(_out_yaml, mode='w', encoding="utf-8")
    l.write(yaml.safe_dump(result))
    l.close()

    return yaml.safe_load(open(_out_yaml, 'r'))
Пример #3
0
def result_tests(project, build):
    from .app import app
    param = {
        'login': project.login,
        'id': project.id,
        'revision': build.revision,
        'build': build.id
    }

    _out_src = os.path.join(
        app.config['DATA_ROOT'],
        '%(login)s/%(id)s.out/%(build)s.%(revision)s/' % param)
    _out_yaml = os.path.join(
        app.config['DATA_ROOT'],
        '%(login)s/%(id)s.out/%(build)s.%(revision)s.rtests.yaml' % param)

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

    result = {}
    os.chdir(_out_src)
    for font in glob.glob("*.ttf"):
        result[font] = run_set(os.path.join(_out_src, font), 'result')

    # Comment during debug
    l = open(_out_yaml, 'w')
    l.write(yaml.safe_dump(result))
    l.close()

    d = yaml.safe_load(open(_out_yaml, 'r'))
    # os.remove(_out_yaml)
    return d
Пример #4
0
def process_description_404(project, build):
    """ Background task to check links in DESCRIPTION.en_us.html file

    This method generates yaml file `*.*.404links.yaml` inside repo out
    directory.

    Args:
        project: A :class:`~bakery.models.Project` instance
        build: A :class:`~bakery.models.ProjectBuild` instance
    """
    path_params = PathParam(project, build)
    path = op.join(path_params._out, 'DESCRIPTION.en_us.html')

    param = {'login': project.login, 'id': project.id,
             'revision': build.revision, 'build': build.id}
    _out_yaml = joinroot(('%(login)s/%(id)s.out/'
                          '%(build)s.%(revision)s.404links.yaml') % param)

    result = {}
    test_results = run_set(path, 'description')
    result = parse_test_results(test_results)
    result['updated'] = datetime.datetime.now()

    # Comment during debug
    l = open(_out_yaml, 'w')
    l.write(yaml.safe_dump(result))
    l.close()

    d = yaml.safe_load(open(_out_yaml, 'r'))
    # os.remove(_out_yaml)
    return d
Пример #5
0
    def upstream_tests(self):
        result = {}
        source_dir = op.join(self.builddir, '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()
Пример #6
0
    def execute(self, pipedata, prefix=""):
        self.stdout_pipe.write('Run tests for baked files\n', prefix='### %s ' % prefix)
        _out_yaml = op.join(self.builddir, '.tests.yaml')

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

        result = {}
        for font in pipedata['bin_files']:
            self.stdout_pipe.write('Test %s' % font, prefix="### ")
            result[font] = run_set(op.join(self.builddir, font), 'result',
                                   log=self.stdout_pipe)

        self.stdout_pipe.write('Test METADATA.json', prefix="### ")
        result['METADATA.json'] = self.run_metadata_tests()

        if not result:
            return

        self.write_lint_results(result)
Пример #7
0
def result_tests(project, build):
    param = {'login': project.login, 'id': project.id,
                'revision': build.revision, 'build': build.id}

    _out_src = os.path.join(DATA_ROOT, '%(login)s/%(id)s.out/%(build)s.%(revision)s/' % param)
    _out_yaml = os.path.join(DATA_ROOT, '%(login)s/%(id)s.out/%(build)s.%(revision)s.rtests.yaml' % param)

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

    result = {}
    os.chdir(_out_src)
    for font in glob.glob("*.ttf"):
        result[font] = run_set(os.path.join(_out_src, font), 'result')

    # Comment during debug
    l = open(_out_yaml, 'w')
    l.write(yaml.safe_dump(result))
    l.close()

    d = yaml.safe_load(open(_out_yaml, 'r'))
    # os.remove(_out_yaml)
    return d
Пример #8
0
 def test_result_each_ttf_subset_menu_truetype_success(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold.ttf')
     r = run_set(p, 'result')
     self.assertInSuccess('test_subsets_files_is_font', r)
     self.assertInSuccess('test_file_is_font', r)
     self.assertInSuccess('test_menu_file_is_font', r)
Пример #9
0
 def test_result_metadata_fonts_fields_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Regular.ttf')
     r = run_set(p, 'result')
     self.assertInFailure('test_metadata_fonts_fields', r)
     self.assertInFailure('test_metadata_font_keys_types', r)
Пример #10
0
 def test_result_space_and_nbsp_has_same_advanced_width_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold!.ttf')
     self.assertInFailure('test_nbsp_and_space_glyphs_width', run_set(p, 'result'))
Пример #11
0
 def test_result_METADATA_postScriptName_canonical_success(self):
     # TODO: create XXX_failure test
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold.ttf')
     self.assertInSuccess('test_metadata_postScriptName_canonical', run_set(p, 'result'))
Пример #12
0
 def test_results_fontname_is_equal_to_macstyle_success(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Italic.ttf')
     self.assertInSuccess('test_fontname_is_equal_to_macstyle', run_set(p, 'result'))
Пример #13
0
 def test_result_space_success(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold.ttf')
     self.assertInSuccess('test_space', run_set(p, 'result'))
Пример #14
0
 def test_result_font_gpos_table_has_kerning_info_success(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Light.ttf')
     self.assertInSuccess('test_font_gpos_table_has_kerning_info', run_set(p, 'result'))
Пример #15
0
 def test_result_font_gpos_table_has_kerning_info_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold.ttf')
     self.assertInFailure('test_font_gpos_table_has_kerning_info', run_set(p, 'result'))
Пример #16
0
 def test_result_table_gasp_type_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Italic.ttf')
     self.assertInFailure('test_table_gasp_type', run_set(p, 'result'))
Пример #17
0
 def test_result_no_kern_table_exists_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold!.ttf')
     self.assertInFailure('test_no_kern_table_exists', run_set(p, 'result'))
Пример #18
0
 def test_result_prep_magic_code_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Italic.ttf')
     self.assertInFailure('test_prep_magic_code', run_set(p, 'result'))
Пример #19
0
 def test_result_macintosh_platform_names_matches_windows_platform_success(self):
     # TODO: create XXX_failure test
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold.ttf')
     self.assertInSuccess('test_macintosh_platform_names_matches_windows_platform', run_set(p, 'result'))
Пример #20
0
 def test_result_metadata_has_unique_style_weight_pairs_success(self):
     # TODO: create XXX_failure test
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold.ttf')
     self.assertInSuccess('test_metadata_has_unique_style_weight_pairs', run_set(p, 'result'))
Пример #21
0
 def test_ttx_doesnt_contain_duplicate_glyphs_success(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/src/Font-Bold!.ttx')
     self.assertInSuccess('test_ttx_doesnt_contain_duplicate_glyphs', run_set(p, 'upstream-ttx'))
Пример #22
0
 def test_result_camelcase_in_fontname_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold.ttf')
     self.assertInFailure('test_camelcase_in_fontname', run_set(p, 'result'))
Пример #23
0
 def test_upstream(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/src/Font-Italic.ufo')
     r = run_set(p, 'upstream')
     self.assertInSuccess('test_is_A', r)
Пример #24
0
 def test_result_family_is_listed_in_gwf_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold.ttf')
     self.assertInFailure('test_family_is_listed_in_gwf', run_set(p, 'result'))
Пример #25
0
 def test_results_nbsp_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold!.ttf')
     self.assertInFailure('test_nbsp', run_set(p, 'result'))
Пример #26
0
 def test_result_em_is_1000_success(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Italic.ttf')
     self.assertInSuccess('test_em_is_1000', run_set(p, 'result'))
Пример #27
0
 def test_result_space_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Light!.ttf')
     self.assertInFailure('test_space', run_set(p, 'result'))
Пример #28
0
 def test_result_metadata_no_unknown_top_keys_success(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold.ttf')
     r = run_set(p, 'result')
     self.assertInSuccess('test_metadata_no_unknown_top_keys', r)
     self.assertInSuccess('test_metadata_fonts_no_unknown_keys', r)
Пример #29
0
 def test_result_METADATA_family_equals_to_binfont_familyname_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold!.ttf')
     self.assertInFailure('test_metadata_family', run_set(p, 'result'))
Пример #30
0
 def test_result_metrics_maximum_advanced_width_in_hhea_success(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Italic.ttf')
     self.assertInSuccess('test_metrics_maximum_advanced_width_in_hhea', run_set(p, 'result'))
Пример #31
0
def upstream_revision_tests(project, revision):
    """ This function run upstream tests set on
    project.config['local']['ufo_dirs'] set in selected git revision.
    This mean that success (aka getting any result) should be occasional
    particular case. Because data and
    set of folders are changing during font development process.

    :param project: Project instance
    :param revision: Git revision
    :param force: force to make tests again
    :return: dictionary with serialized tests results formatted by `repr_testcase`
    """
    from .app import app
    param = {'login': project.login, 'id': project.id, 'revision': revision}

    _in = os.path.join(app.config['DATA_ROOT'],
                       '%(login)s/%(id)s.in/' % project)
    _out_folder = os.path.join(app.config['DATA_ROOT'],
                               '%(login)s/%(id)s.out/utests/' % param)
    _out_yaml = os.path.join(
        app.config['DATA_ROOT'],
        '%(login)s/%(id)s.out/utests/%(revision)s.yaml' % param)

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

    if not os.path.exists(_out_folder):
        os.makedirs(_out_folder)

    result = {}
    os.chdir(_in)
    prun("git checkout %s" % revision, cwd=_in)

    ufo_dirs = []
    ttx_files = []
    metadata_files = []
    l = len(_in)
    for root, dirs, files in os.walk(_in):
        for f in files:
            fullpath = os.path.join(root, f)
            if os.path.splitext(fullpath)[1].lower() in [
                    '.ttx',
            ]:
                ttx_files.append(fullpath[l:])
            if f.lower() == 'metadata.json':
                metadata_files.append(fullpath[l:])
        for d in dirs:
            fullpath = os.path.join(root, d)
            if os.path.splitext(fullpath)[1].lower() == '.ufo':
                ufo_dirs.append(fullpath[l:])

    for font in ufo_dirs:
        if os.path.exists(os.path.join(_in, font)):
            result[font] = run_set(os.path.join(_in, font), 'upstream')

    for metadata_path in metadata_files:
        result[metadata_path] = run_set(metadata_path, 'metadata')

    for font in ttx_files:
        print(font)
        print(os.path.join(_in, font))
        if os.path.exists(os.path.join(_in, font)):
            result[font] = run_set(os.path.join(_in, font), 'upstream-ttx')

    result['Consistency fonts'] = run_set(_in, 'consistency')

    l = codecs.open(_out_yaml, mode='w', encoding="utf-8")
    l.write(yaml.safe_dump(result))
    l.close()

    return yaml.safe_load(open(_out_yaml, 'r'))
Пример #32
0
 def test_result_metrics_advance_width_in_glyphs_same_if_monospace_success(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Italic.ttf')
     self.assertInSuccess('test_metrics_advance_width_in_glyphs_same_if_monospace', run_set(p, 'result'))
Пример #33
0
 def test_result_metadata_copyright_contains_rfn_success(self):
     # TODO: create XXX_failure test
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold.ttf')
     self.assertInSuccess('test_metadata_copyright_contains_rfn', run_set(p, 'result'))
Пример #34
0
 def test_result_metadata_weight_matches_postscriptname_success(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Italic.ttf')
     self.assertInSuccess('test_metadata_weight_matches_postscriptname', run_set(p, 'result'))
Пример #35
0
 def test_result_em_is_1000_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold.ttf')
     self.assertInFailure('test_em_is_1000', run_set(p, 'result'))
Пример #36
0
 def test_result_atleast_latin_menu_subsets_exist_failure(self):
     p = op.join(app.config['ROOT'], 'tests/fixtures/ttf/Font-Bold!.ttf')
     r = run_set(p, 'result')
     self.assertInFailure('test_latin_file_exists', r)
     self.assertInFailure('test_menu_file_exists', r)
     self.assertInSuccess('test_metadata_atleast_latin_menu_subsets_exist', r)