6 from gecko_taskgraph
import GECKO
7 from mozunit
import main
8 from taskgraph
.taskgraph
import TaskGraph
10 pytestmark
= pytest
.mark
.slow
11 PARAMS_DIR
= os
.path
.join(GECKO
, "taskcluster", "test", "params")
14 @pytest.fixture(scope
="module")
15 def get_graph_from_spec(tmpdir_factory
):
16 outdir
= tmpdir_factory
.mktemp("graphs")
18 # Use a mach subprocess to leverage the auto parallelization of
19 # parameters when specifying a directory.
25 f
"--parameters={PARAMS_DIR}",
26 f
"--output-file={outdir}/graph.json",
28 # unset MOZ_AUTOMATION so we don't attempt to optimize out the graph
29 # entirely as having already run
30 env
= os
.environ
.copy()
31 env
.pop("MOZ_AUTOMATION", None)
32 subprocess
.run(cmd
, cwd
=GECKO
, env
=env
)
33 assert len(outdir
.listdir()) > 0
35 def inner(param_spec
):
36 outfile
= f
"{outdir}/graph_{param_spec}.json"
37 with
open(outfile
) as fh
:
40 return TaskGraph
.from_json(json
.loads(output
))[1]
47 @pytest.mark
.parametrize(
49 [os
.path
.splitext(p
)[0] for p
in os
.listdir(PARAMS_DIR
) if p
.endswith(".yml")],
51 def test_generate_graphs(get_graph_from_spec
, param_spec
):
52 ret
= get_graph_from_spec(param_spec
)
53 if isinstance(ret
, str):
55 pytest
.fail("An exception was raised during graph generation!")
57 assert isinstance(ret
, TaskGraph
)
58 assert len(ret
.tasks
) > 0
61 if __name__
== "__main__":