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 subprocess
.run(cmd
, cwd
=GECKO
)
29 assert len(outdir
.listdir()) > 0
31 def inner(param_spec
):
32 outfile
= f
"{outdir}/graph_{param_spec}.json"
33 with
open(outfile
) as fh
:
36 return TaskGraph
.from_json(json
.loads(output
))[1]
43 @pytest.mark
.parametrize(
44 "param_spec", [os
.path
.splitext(p
)[0] for p
in os
.listdir(PARAMS_DIR
)]
46 def test_generate_graphs(get_graph_from_spec
, param_spec
):
47 ret
= get_graph_from_spec(param_spec
)
48 if isinstance(ret
, str):
50 pytest
.fail("An exception was raised during graph generation!")
52 assert isinstance(ret
, TaskGraph
)
53 assert len(ret
.tasks
) > 0
56 if __name__
== "__main__":