コード例 #1
0
def test_lp_xpi(err, xpi_package):
    'Tests a language pack for L10n completeness'

    # Don't even both with the test(s) if there's no chrome.manifest.
    if 'chrome.manifest' not in xpi_package:
        return None

    locales = _get_locales(err)

    # Get the reference packages.
    references = []
    support_references = err.get_resource('supports')
    if not support_references:
        references.append('firefox')
        err.info(('testcases_l10ncompleteness',
                  'test_lp_xpi',
                  'missing_app_support'),
                 'Supported app missing in localization completeness.',
                 'While testing in localization comleteness, a list of '
                 'supported applications for the language pack was not found. '
                 'This is likely because there are no listed '
                 '<em:targetApplication> elements in the install.rdf file.')
    else:
        for support in support_references:
            ref_xpi = XPIManager(os.path.join(os.path.dirname(__file__),
                                              'langpacks/%s.xpi' % support))
            ref_xpi.app_name = support
            reference_locales = _get_locales(None, ref_xpi)

            references.append((ref_xpi, reference_locales))

    # Iterate each supported reference package
    for (ref_xpi, ref_locales) in references:
        # Iterate each locale in each supported reference package
        ref_pack = _get_locale_manager(err,
                                       ref_xpi,
                                       {'path': 'en-US.jar',
                                        'jarred': True},
                                       no_cache=True)
        for ref_locale_name in ref_locales:
            ref_locale = ref_locales[ref_locale_name]
            ref_predicate = ref_locale['predicate']
            corresp_locales = [locales[name] for name
                               in locales
                               if locales[name]['predicate'] == ref_predicate]
            # If we found no matching locale, then it's missing from the pack
            if not corresp_locales:
                err.warning(('testcases_l10ncompleteness',
                             'test_lp_xpi',
                             'find_corresponding_locale'),
                            'Could not find corresponding locale',
                            ['A locale was found in the reference package, '
                             'however it was not found in the target package.',
                             'Missing locale: %s' % ref_predicate],
                            filename='chrome.manifest')
                continue

            target_locale = corresp_locales[0]
            target_pack = _get_locale_manager(err,
                                              xpi_package,
                                              target_locale)
            if target_pack is None:
                continue

            results = _compare_packages(reference=ref_pack,
                                        target=target_pack,
                                        ref_base=ref_locale['target'],
                                        locale_base=target_locale['target'])

            # Report the findings after each supported app's locale
            _aggregate_results(err, results, target_locale)

    # Clear the cache at the end of the test
    LOCALE_CACHE.clear()
コード例 #2
0
def test_lp_xpi(err, xpi_package):
    'Tests a language pack for L10n completeness'

    # Don't even both with the test(s) if there's no chrome.manifest.
    if 'chrome.manifest' not in xpi_package:
        return None

    locales = _get_locales(err)

    # Get the reference packages.
    references = []
    support_references = err.get_resource('supports')
    if not support_references:
        references.append('firefox')
        err.info(('testcases_l10ncompleteness', 'test_lp_xpi',
                  'missing_app_support'),
                 'Supported app missing in localization completeness.',
                 'While testing in localization comleteness, a list of '
                 'supported applications for the language pack was not found. '
                 'This is likely because there are no listed '
                 '<em:targetApplication> elements in the install.rdf file.')
    else:
        for support in support_references:
            ref_xpi = XPIManager(
                os.path.join(os.path.dirname(__file__),
                             'langpacks/%s.xpi' % support))
            ref_xpi.app_name = support
            reference_locales = _get_locales(None, ref_xpi)

            references.append((ref_xpi, reference_locales))

    # Iterate each supported reference package
    for (ref_xpi, ref_locales) in references:
        # Iterate each locale in each supported reference package
        ref_pack = _get_locale_manager(err,
                                       ref_xpi, {
                                           'path': 'en-US.jar',
                                           'jarred': True
                                       },
                                       no_cache=True)
        for ref_locale_name in ref_locales:
            ref_locale = ref_locales[ref_locale_name]
            ref_predicate = ref_locale['predicate']
            corresp_locales = [
                locales[name] for name in locales
                if locales[name]['predicate'] == ref_predicate
            ]
            # If we found no matching locale, then it's missing from the pack
            if not corresp_locales:
                err.warning(
                    ('testcases_l10ncompleteness', 'test_lp_xpi',
                     'find_corresponding_locale'),
                    'Could not find corresponding locale', [
                        'A locale was found in the reference package, '
                        'however it was not found in the target package.',
                        'Missing locale: %s' % ref_predicate
                    ],
                    filename='chrome.manifest')
                continue

            target_locale = corresp_locales[0]
            target_pack = _get_locale_manager(err, xpi_package, target_locale)
            if target_pack is None:
                continue

            results = _compare_packages(reference=ref_pack,
                                        target=target_pack,
                                        ref_base=ref_locale['target'],
                                        locale_base=target_locale['target'])

            # Report the findings after each supported app's locale
            _aggregate_results(err, results, target_locale)

    # Clear the cache at the end of the test
    LOCALE_CACHE.clear()
コード例 #3
0
def test_lp_xpi(err, xpi_package):
    "Tests a language pack for L10n completeness"

    # Don't even both with the test(s) if there's no chrome.manifest.
    if "chrome.manifest" not in xpi_package:
        return None

    locales = _get_locales(err)

    # Get the reference packages.
    references = []
    support_references = err.get_resource("supports")
    if not support_references:
        references.append("firefox")
        err.info(
            ("testcases_l10ncompleteness", "test_lp_xpi", "missing_app_support"),
            "Supported app missing in localization completeness.",
            "While testing in localization comleteness, a list of "
            "supported applications for the language pack was not found. "
            "This is likely because there are no listed "
            "<em:targetApplication> elements in the install.rdf file.",
        )
    else:
        for support in support_references:
            ref_xpi = XPIManager(os.path.join(os.path.dirname(__file__), "langpacks/%s.xpi" % support))
            ref_xpi.app_name = support
            reference_locales = _get_locales(None, ref_xpi)

            references.append((ref_xpi, reference_locales))

    # Iterate each supported reference package
    for (ref_xpi, ref_locales) in references:
        # Iterate each locale in each supported reference package
        ref_pack = _get_locale_manager(err, ref_xpi, {"path": "en-US.jar", "jarred": True}, no_cache=True)
        for ref_locale_name in ref_locales:
            ref_locale = ref_locales[ref_locale_name]
            ref_predicate = ref_locale["predicate"]
            corresp_locales = [locales[name] for name in locales if locales[name]["predicate"] == ref_predicate]
            # If we found no matching locale, then it's missing from the pack
            if not corresp_locales:
                err.warning(
                    ("testcases_l10ncompleteness", "test_lp_xpi", "find_corresponding_locale"),
                    "Could not find corresponding locale",
                    [
                        "A locale was found in the reference package, "
                        "however it was not found in the target package.",
                        "Missing locale: %s" % ref_predicate,
                    ],
                    filename="chrome.manifest",
                )
                continue

            target_locale = corresp_locales[0]
            target_pack = _get_locale_manager(err, xpi_package, target_locale)
            if target_pack is None:
                continue

            results = _compare_packages(
                reference=ref_pack,
                target=target_pack,
                ref_base=ref_locale["target"],
                locale_base=target_locale["target"],
            )

            # Report the findings after each supported app's locale
            _aggregate_results(err, results, target_locale)

    # Clear the cache at the end of the test
    LOCALE_CACHE = {}
コード例 #4
0
def test_lp_xpi(err, xpi_package):
    "Tests a language pack for L10n completeness"

    # Don't even both with the test(s) if there's no chrome.manifest.
    if "chrome.manifest" not in xpi_package:
        return None

    locales = _get_locales(err)

    # Get the reference packages.
    references = []
    support_references = err.get_resource("supports")
    if not support_references:
        references.append("firefox")
        err.info(("testcases_l10ncompleteness", "test_lp_xpi",
                  "missing_app_support"),
                 "Supported app missing in localization completeness.",
                 "While testing in localization comleteness, a list of "
                 "supported applications for the language pack was not found. "
                 "This is likely because there are no listed "
                 "<em:targetApplication> elements in the install.rdf file.")
    else:
        for support in support_references:
            ref_xpi = XPIManager(
                os.path.join(os.path.dirname(__file__),
                             "langpacks/%s.xpi" % support))
            ref_xpi.app_name = support
            reference_locales = _get_locales(None, ref_xpi)

            references.append((ref_xpi, reference_locales))

    # Iterate each supported reference package
    for (ref_xpi, ref_locales) in references:
        # Iterate each locale in each supported reference package
        ref_pack = _get_locale_manager(err,
                                       ref_xpi, {
                                           "path": "en-US.jar",
                                           "jarred": True
                                       },
                                       no_cache=True)
        for ref_locale_name in ref_locales:
            ref_locale = ref_locales[ref_locale_name]
            ref_predicate = ref_locale["predicate"]
            corresp_locales = [
                locales[name] for name in locales
                if locales[name]["predicate"] == ref_predicate
            ]
            # If we found no matching locale, then it's missing from the pack
            if not corresp_locales:
                err.warning(
                    ("testcases_l10ncompleteness", "test_lp_xpi",
                     "find_corresponding_locale"),
                    "Could not find corresponding locale", [
                        "A locale was found in the reference package, "
                        "however it was not found in the target package.",
                        "Missing locale: %s" % ref_predicate
                    ],
                    filename="chrome.manifest")
                continue

            target_locale = corresp_locales[0]
            target_pack = _get_locale_manager(err, xpi_package, target_locale)
            if target_pack is None:
                continue

            results = _compare_packages(reference=ref_pack,
                                        target=target_pack,
                                        ref_base=ref_locale["target"],
                                        locale_base=target_locale["target"])

            # Report the findings after each supported app's locale
            _aggregate_results(err, results, target_locale)

    # Clear the cache at the end of the test
    LOCALE_CACHE = {}