]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Always store configuration origin value (#928)
authorGregor Jasny <gregor.jasny@logmein.com>
Tue, 7 Sep 2021 17:22:51 +0000 (19:22 +0200)
committerGitHub <noreply@github.com>
Tue, 7 Sep 2021 17:22:51 +0000 (19:22 +0200)
src/Config.cpp
test/CMakeLists.txt
test/suites/config.bash [new file with mode: 0644]

index 9e9b593ec77ba2e34c4cee0aaea0068402f659f0..6169e61c468196b950b0d3de2d0469889b95eba4 100644 (file)
@@ -1001,7 +1001,10 @@ Config::set_item(const std::string& key,
     break;
   }
 
-  m_origins.emplace(key, origin);
+  auto result = m_origins.emplace(key, origin);
+  if (!result.second) {
+    result.first->second = origin;
+  }
 }
 
 void
index fa8feb3ff3806b7df69d439b3290617f4da0cf78..0015e4117a8206fa2d935322404aa5bacb2e1441 100644 (file)
@@ -25,6 +25,7 @@ addtest(basedir)
 addtest(cache_levels)
 addtest(cleanup)
 addtest(color_diagnostics)
+addtest(config)
 addtest(cpp1)
 addtest(debug_prefix_map)
 addtest(depend)
diff --git a/test/suites/config.bash b/test/suites/config.bash
new file mode 100644 (file)
index 0000000..aaa4747
--- /dev/null
@@ -0,0 +1,11 @@
+SUITE_config() {
+    # -------------------------------------------------------------------------
+    TEST "Environment origin"
+
+    export CCACHE_MAXSIZE="40"
+
+    $CCACHE --max-size "75"
+    $CCACHE --show-config > config.txt
+
+    expect_contains config.txt "(environment) max_size = 40"
+}