Exemplo n.º 1
0
def setup(app):
    from moztreedocs import manager

    # Import the list of metrics and ping files
    glean_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
    sys.path.append(glean_dir)
    from metrics_index import metrics_yamls, pings_yamls

    # Import the custom version expiry code.
    glean_parser_ext_dir = os.path.abspath(
        Path(glean_dir) / "build_scripts" / "glean_parser_ext"
    )
    sys.path.append(glean_parser_ext_dir)
    from run_glean_parser import get_parser_options

    firefox_version = "4.0a1"  # TODO: bug 1676416 - Get the real app version.
    parser_config = get_parser_options(firefox_version)

    input_files = [Path(os.path.join(manager.topsrcdir, x)) for x in metrics_yamls]
    input_files += [Path(os.path.join(manager.topsrcdir, x)) for x in pings_yamls]

    # Generate the autodocs.
    from glean_parser import translate

    out_path = Path(os.path.join(manager.staging_dir, "metrics"))
    translate.translate(
        input_files, "markdown", out_path, {"project_title": "Firefox"}, parser_config
    )

    # Rename the generated docfile to index so Sphinx finds it
    os.rename(os.path.join(out_path, "metrics.md"), os.path.join(out_path, "index.md"))
Exemplo n.º 2
0
def test_no_metrics_expired():
    """
    Of all the metrics included in this build, are any expired?
    If so, they must be removed or renewed.

    (This also checks other lints, as a treat.)
    """
    with open("browser/config/version.txt", "r") as version_file:
        app_version = version_file.read().strip()

    options = run_glean_parser.get_parser_options(app_version)
    metrics_paths = [Path(x) for x in metrics_yamls]
    all_objs = parser.parse_objects(metrics_paths, options)
    assert not util.report_validation_errors(all_objs)
    assert not lint.lint_metrics(all_objs.value, options)
Exemplo n.º 3
0
def test_numeric_expires():
    """What if the expires value is a number, not a string?
    This test relies on the intermediary object format output by glean_parser.
    Expect it to be fragile on glean_parser updates that change that format.
    """

    # We'll never get to checking expires values, so this app version shouldn't matter.
    options = run_glean_parser.get_parser_options("42.0a1")
    input_files = [
        Path(
            path.join(path.dirname(__file__),
                      "metrics_expires_number_test.yaml"))
    ]

    all_objs = parser.parse_objects(input_files, options)
    errors = list(all_objs)
    assert len(errors) == 1
    assert re.search("99 is not of type 'string'", str(errors[0]))
Exemplo n.º 4
0
def test_expires_version():
    """This test relies on the intermediary object format output by glean_parser.
    Expect it to be fragile on glean_parser updates that change that format.
    """

    # The test file has 41, 42, 100. Use 42.0a1 here to ensure "expires == version" means expired.
    options = run_glean_parser.get_parser_options("42.0a1")
    input_files = [
        Path(
            path.join(path.dirname(__file__),
                      "metrics_expires_versions_test.yaml"))
    ]

    all_objs, options = run_glean_parser.parse_with_options(
        input_files, options)

    assert all_objs["test"]["expired1"].disabled is True
    assert all_objs["test"]["expired2"].disabled is True
    assert all_objs["test"]["unexpired"].disabled is False