diff --git a/src/taskgraph/config.py b/src/taskgraph/config.py index b914b98f0..1f4eca909 100644 --- a/src/taskgraph/config.py +++ b/src/taskgraph/config.py @@ -112,6 +112,11 @@ class GraphConfig: _PATH_MODIFIED = False + def __post_init__(self): + # ensure we have an absolute path; this is required for assumptions + # made later, such as the `vcs_root` being a directory above `root_dir` + object.__setattr__(self, "root_dir", os.path.abspath(self.root_dir)) + def __getitem__(self, name): return self._config[name] diff --git a/test/test_config.py b/test/test_config.py index 596036f34..84e459f85 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -2,6 +2,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +import os.path + import pytest from taskgraph.config import GraphConfig @@ -10,6 +12,8 @@ def test_graph_config_basic(): graph_config = GraphConfig({"foo": "bar"}, "root") + assert os.path.isabs(graph_config.root_dir) + assert "foo" in graph_config assert graph_config["foo"] == "bar" assert graph_config.get("foo") == "bar"