summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2021-11-23 23:48:26 +0100
committerJoel Klinghed <the_jk@spawned.biz>2021-11-23 23:48:26 +0100
commit2722431ce919d5e780d01bd14b77fbc03d007f07 (patch)
tree883e9bcdee307295d54adf4a4abf3c909228b292 /test
parent86bb5d6cf52d1bcdc854eb30e9729d7425a9971b (diff)
Make config keep the absolute root to load relative files from
This means Config::get_path will continue to work even if we change current directory in the process (when the path the config was loaded from was relative).
Diffstat (limited to 'test')
-rw-r--r--test/test_config.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/test_config.cc b/test/test_config.cc
index d9ddf3a..bcb7b59 100644
--- a/test/test_config.cc
+++ b/test/test_config.cc
@@ -165,3 +165,13 @@ TEST_F(ConfigTest, path) {
EXPECT_EQ("/file", cfg->get_path("absolute", ""));
EXPECT_EQ(path().parent_path() / "file", cfg->get_path("relative", ""));
}
+
+TEST_F(ConfigTest, path_when_load_relative) {
+ write("absolute = /file\n"
+ "relative = file\n");
+ auto cfg = Config::create(logger(), std::filesystem::relative(path()));
+ ASSERT_TRUE(cfg);
+ EXPECT_EQ("/file", cfg->get_path("absolute", ""));
+ EXPECT_EQ(path().parent_path() / "file",
+ std::filesystem::weakly_canonical(cfg->get_path("relative", "")));
+}