Bug 1874684 - Part 28: Return DateDuration from DifferenceISODateTime. r=mgaudet
[gecko.git] / python / mozbuild / mozbuild / test / test_telemetry.py
blob894e32ee2d092efcd3765b7b08f48442a33ae510
1 # Any copyright is dedicated to the Public Domain.
2 # http://creativecommons.org/publicdomain/zero/1.0/
4 import os
6 import buildconfig
7 import mozunit
9 from mozbuild.telemetry import filter_args
11 TELEMETRY_LOAD_ERROR = """
12 Error loading telemetry. mach output:
13 =========================================================
15 =========================================================
16 """
19 def test_path_filtering():
20 srcdir_path = os.path.join(buildconfig.topsrcdir, "a")
21 srcdir_path_2 = os.path.join(buildconfig.topsrcdir, "a/b/c")
22 objdir_path = os.path.join(buildconfig.topobjdir, "x")
23 objdir_path_2 = os.path.join(buildconfig.topobjdir, "x/y/z")
24 home_path = os.path.join(os.path.expanduser("~"), "something_in_home")
25 other_path = "/other/path"
26 args = filter_args(
27 "pass",
29 "python",
30 "-c",
31 "pass",
32 srcdir_path,
33 srcdir_path_2,
34 objdir_path,
35 objdir_path_2,
36 home_path,
37 other_path,
39 buildconfig.topsrcdir,
40 buildconfig.topobjdir,
41 cwd=buildconfig.topsrcdir,
44 expected = [
45 "a",
46 "a/b/c",
47 "$topobjdir/x",
48 "$topobjdir/x/y/z",
49 "$HOME/something_in_home",
50 "<path omitted>",
52 assert args == expected
55 def test_path_filtering_in_objdir():
56 srcdir_path = os.path.join(buildconfig.topsrcdir, "a")
57 srcdir_path_2 = os.path.join(buildconfig.topsrcdir, "a/b/c")
58 objdir_path = os.path.join(buildconfig.topobjdir, "x")
59 objdir_path_2 = os.path.join(buildconfig.topobjdir, "x/y/z")
60 other_path = "/other/path"
61 args = filter_args(
62 "pass",
64 "python",
65 "-c",
66 "pass",
67 srcdir_path,
68 srcdir_path_2,
69 objdir_path,
70 objdir_path_2,
71 other_path,
73 buildconfig.topsrcdir,
74 buildconfig.topobjdir,
75 cwd=buildconfig.topobjdir,
77 expected = ["$topsrcdir/a", "$topsrcdir/a/b/c", "x", "x/y/z", "<path omitted>"]
78 assert args == expected
81 def test_path_filtering_other_cwd(tmpdir):
82 srcdir_path = os.path.join(buildconfig.topsrcdir, "a")
83 srcdir_path_2 = os.path.join(buildconfig.topsrcdir, "a/b/c")
84 other_path = str(tmpdir.join("other"))
85 args = filter_args(
86 "pass",
87 ["python", "-c", "pass", srcdir_path, srcdir_path_2, other_path],
88 buildconfig.topsrcdir,
89 buildconfig.topobjdir,
90 cwd=str(tmpdir),
92 expected = [
93 "$topsrcdir/a",
94 "$topsrcdir/a/b/c",
95 # cwd-relative paths should be relativized
96 "other",
98 assert args == expected
101 if __name__ == "__main__":
102 mozunit.main()