Esempio n. 1
0
def test_path_filtering_in_objdir():
    srcdir_path = os.path.join(buildconfig.topsrcdir, "a")
    srcdir_path_2 = os.path.join(buildconfig.topsrcdir, "a/b/c")
    objdir_path = os.path.join(buildconfig.topobjdir, "x")
    objdir_path_2 = os.path.join(buildconfig.topobjdir, "x/y/z")
    other_path = "/other/path"
    args = filter_args(
        "pass",
        [
            "python",
            "-c",
            "pass",
            srcdir_path,
            srcdir_path_2,
            objdir_path,
            objdir_path_2,
            other_path,
        ],
        buildconfig.topsrcdir,
        buildconfig.topobjdir,
        cwd=buildconfig.topobjdir,
    )
    expected = [
        "$topsrcdir/a", "$topsrcdir/a/b/c", "x", "x/y/z", "<path omitted>"
    ]
    assert args == expected
Esempio n. 2
0
def test_path_filtering():
    srcdir_path = os.path.join(buildconfig.topsrcdir, "a")
    srcdir_path_2 = os.path.join(buildconfig.topsrcdir, "a/b/c")
    objdir_path = os.path.join(buildconfig.topobjdir, "x")
    objdir_path_2 = os.path.join(buildconfig.topobjdir, "x/y/z")
    home_path = os.path.join(os.path.expanduser("~"), "something_in_home")
    other_path = "/other/path"
    args = filter_args(
        "pass",
        [
            "python",
            "-c",
            "pass",
            srcdir_path,
            srcdir_path_2,
            objdir_path,
            objdir_path_2,
            home_path,
            other_path,
        ],
        buildconfig.topsrcdir,
        buildconfig.topobjdir,
        cwd=buildconfig.topsrcdir,
    )

    expected = [
        "a",
        "a/b/c",
        "$topobjdir/x",
        "$topobjdir/x/y/z",
        "$HOME/something_in_home",
        "<path omitted>",
    ]
    assert args == expected
Esempio n. 3
0
def report_invocation_metrics(telemetry, command):
    metrics = telemetry.metrics(MACH_METRICS_PATH)
    metrics.mach.command.set(command)
    metrics.mach.duration.start()

    try:
        instance = MozbuildObject.from_environment()
    except BuildEnvironmentNotFoundException:
        # Mach may be invoked with the state dir as the current working
        # directory, in which case we're not able to find the topsrcdir (so
        # we can't create a MozbuildObject instance).
        # Without this information, we're unable to filter argv paths, so
        # we skip submitting them to telemetry.
        return
    metrics.mach.argv.set(filter_args(command, sys.argv, instance))
Esempio n. 4
0
def test_path_filtering_other_cwd(tmpdir):
    srcdir_path = os.path.join(buildconfig.topsrcdir, "a")
    srcdir_path_2 = os.path.join(buildconfig.topsrcdir, "a/b/c")
    other_path = str(tmpdir.join("other"))
    args = filter_args(
        "pass",
        ["python", "-c", "pass", srcdir_path, srcdir_path_2, other_path],
        buildconfig.topsrcdir,
        buildconfig.topobjdir,
        cwd=str(tmpdir),
    )
    expected = [
        "$topsrcdir/a",
        "$topsrcdir/a/b/c",
        # cwd-relative paths should be relativized
        "other",
    ]
    assert args == expected