summaryrefslogtreecommitdiffstats
path: root/taskcluster/test/test_generate_params.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /taskcluster/test/test_generate_params.py
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'taskcluster/test/test_generate_params.py')
-rw-r--r--taskcluster/test/test_generate_params.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/taskcluster/test/test_generate_params.py b/taskcluster/test/test_generate_params.py
new file mode 100644
index 0000000000..87f1fe341c
--- /dev/null
+++ b/taskcluster/test/test_generate_params.py
@@ -0,0 +1,57 @@
+import json
+import os
+import subprocess
+
+import pytest
+from gecko_taskgraph import GECKO
+from mozunit import main
+from taskgraph.taskgraph import TaskGraph
+
+pytestmark = pytest.mark.slow
+PARAMS_DIR = os.path.join(GECKO, "taskcluster", "test", "params")
+
+
+@pytest.fixture(scope="module")
+def get_graph_from_spec(tmpdir_factory):
+ outdir = tmpdir_factory.mktemp("graphs")
+
+ # Use a mach subprocess to leverage the auto parallelization of
+ # parameters when specifying a directory.
+ cmd = [
+ "./mach",
+ "taskgraph",
+ "morphed",
+ "--json",
+ f"--parameters={PARAMS_DIR}",
+ f"--output-file={outdir}/graph.json",
+ ]
+ subprocess.run(cmd, cwd=GECKO)
+ assert len(outdir.listdir()) > 0
+
+ def inner(param_spec):
+ outfile = f"{outdir}/graph_{param_spec}.json"
+ with open(outfile) as fh:
+ output = fh.read()
+ try:
+ return TaskGraph.from_json(json.loads(output))[1]
+ except ValueError:
+ return output
+
+ return inner
+
+
+@pytest.mark.parametrize(
+ "param_spec", [os.path.splitext(p)[0] for p in os.listdir(PARAMS_DIR)]
+)
+def test_generate_graphs(get_graph_from_spec, param_spec):
+ ret = get_graph_from_spec(param_spec)
+ if isinstance(ret, str):
+ print(ret)
+ pytest.fail("An exception was raised during graph generation!")
+
+ assert isinstance(ret, TaskGraph)
+ assert len(ret.tasks) > 0
+
+
+if __name__ == "__main__":
+ main()