Skip to content

Commit f60a645

Browse files
committed
fix: ensure GraphConfig.root_dir is an absolute path
1 parent 20222c1 commit f60a645

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/taskgraph/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ class GraphConfig:
112112

113113
_PATH_MODIFIED = False
114114

115+
def __post_init__(self):
116+
# ensure we have an absolute path; this is required for assumptions
117+
# made later, such as the `vcs_root` being a directory above `root_dir`
118+
object.__setattr__(self, "root_dir", os.path.abspath(self.root_dir))
119+
115120
def __getitem__(self, name):
116121
return self._config[name]
117122

test/test_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# License, v. 2.0. If a copy of the MPL was not distributed with this
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

5+
import os.path
56
import pytest
67

78
from taskgraph.config import GraphConfig
@@ -10,6 +11,8 @@
1011
def test_graph_config_basic():
1112
graph_config = GraphConfig({"foo": "bar"}, "root")
1213

14+
assert os.path.isabs(graph_config.root_dir)
15+
1316
assert "foo" in graph_config
1417
assert graph_config["foo"] == "bar"
1518
assert graph_config.get("foo") == "bar"

0 commit comments

Comments
 (0)