Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/taskgraph/taskgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,10 @@ def __iter__(self):

def to_json(self):
"Return a JSON-able object representing the task graph, as documented"
named_links_dict = self.graph.named_links_dict()
# this dictionary may be keyed by label or by taskid, so let's just call it 'key'
tasks = {}
for key in self.graph.visit_postorder():
tasks[key] = self.tasks[key].to_json()
# overwrite dependencies with the information in the taskgraph's edges.
tasks[key]["dependencies"] = named_links_dict.get(key, {})
return tasks

@classmethod
Expand Down
28 changes: 27 additions & 1 deletion test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,26 @@ def test_output_file(run_taskgraph, tmpdir):
},
id="no-op",
),
pytest.param(
"^a",
None,
{
"a": {
"attributes": {"kind": "task"},
"dependencies": {"dep": "b"},
"description": "",
"kind": "task",
"label": "a",
"optimization": None,
"soft_dependencies": [],
"if_dependencies": [],
"task": {
"foo": {"bar": 1},
},
},
},
id="regex-a-only",
),
pytest.param(
"^b",
None,
Expand Down Expand Up @@ -226,7 +246,13 @@ def test_output_file(run_taskgraph, tmpdir):
)
def test_get_filtered_taskgraph(regex, exclude, expected):
tasks = {
"a": Task(kind="task", label="a", attributes={}, task={"foo": {"bar": 1}}),
"a": Task(
kind="task",
label="a",
attributes={},
dependencies={"dep": "b"},
task={"foo": {"bar": 1}},
),
"b": Task(
kind="task",
label="b",
Expand Down
5 changes: 2 additions & 3 deletions test/test_taskgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ def test_taskgraph_to_json(self):
label="a",
attributes={"attr": "a-task"},
task={"taskdef": True},
dependencies={"edgelabel": "b"},
),
"b": Task(
kind="test",
label="b",
attributes={},
task={"task": "def"},
optimization={"seta": None},
# note that this dep is ignored, superseded by that
# from the taskgraph's edges
dependencies={"first": "a"},
),
}
Expand Down Expand Up @@ -56,7 +55,7 @@ def test_taskgraph_to_json(self):
"label": "b",
"attributes": {"kind": "test"},
"task": {"task": "def"},
"dependencies": {},
"dependencies": {"first": "a"},
"description": "",
"soft_dependencies": [],
"if_dependencies": [],
Expand Down
Loading