From f2d4c4a27c7bb6ffbe1120eecdebd2f983cae886 Mon Sep 17 00:00:00 2001
From: Felix Schindler <felix.schindler@wwu.de>
Date: Tue, 15 Jan 2019 16:49:04 +0100
Subject: [PATCH] [test.common] add means to obtain current test id

---
 dune/xt/common/test/common.hh | 47 +++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/dune/xt/common/test/common.hh b/dune/xt/common/test/common.hh
index 904e7f586..85e1f580b 100644
--- a/dune/xt/common/test/common.hh
+++ b/dune/xt/common/test/common.hh
@@ -76,6 +76,20 @@ void busywait(const size_t ms);
 
 namespace Dune {
 namespace XT {
+namespace Common {
+namespace Test {
+
+
+/**
+ * \sa DXTC_TEST_CONFIG_GET
+ * \sa DXTC_TEST_CONFIG_SET
+ * \sa DXTC_TEST_CONFIG_SUB
+ */
+std::string get_unique_test_name();
+
+
+} // namespace Test
+} // namespace Common
 namespace Test {
 namespace internal {
 
@@ -193,4 +207,37 @@ ostream& operator<<(ostream& out, const map<F, S>& results)
 
 } // namespace std
 
+
+/**
+ * \brief Can be used to access the configuration assosicated with the currently running test
+ * \sa get_unique_test_name
+ */
+template <typename T>
+static auto DXTC_TEST_CONFIG_GET(const std::string& key, T def) -> decltype(DXTC_CONFIG.get(key, def))
+{
+  return DXTC_CONFIG.get(Dune::XT::Common::Test::get_unique_test_name() + "." + key, def);
+}
+
+/**
+ * \brief Can be used to access the configuration assosicated with the currently running test
+ * \sa get_unique_test_name
+ */
+template <typename T>
+static void DXTC_TEST_CONFIG_SET(const std::string& key, T val)
+{
+  return DXTC_CONFIG.set(Dune::XT::Common::Test::get_unique_test_name() + "." + key, val, /*overwrite=*/true);
+}
+
+/**
+ * \brief Can be used to access the configuration assosicated with the currently running test
+ * \sa get_unique_test_name
+ */
+static Dune::XT::Common::Configuration DXTC_TEST_CONFIG_SUB(const std::string& sub_key)
+{
+  const auto key = Dune::XT::Common::Test::get_unique_test_name() + "." + sub_key;
+  EXPECT_TRUE(DXTC_CONFIG.has_sub(key));
+  return DXTC_CONFIG.sub(key);
+}
+
+
 #endif // DUNE_XT_COMMON_TEST_MAIN_COMMON_HH
-- 
GitLab