Improve testutils infrastructure
[alexxy/gromacs.git] / src / testutils / testfilemanager.cpp
index 99748ff77fbc39c64e18e54ffb71a357e6b16c02..29b077fa1b9abcf08309cea01c28414aa9d085de 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2012,2013,2014,2015,2017 by the GROMACS development team.
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -173,18 +173,27 @@ std::string TestFileManager::getTemporaryFilePath(const std::string& suffix)
     return getTemporaryFilePath(suffix.c_str());
 }
 
+void TestFileManager::manageGeneratedOutputFile(const char* filename)
+{
+    manageGeneratedOutputFile(std::string(filename));
+}
+void TestFileManager::manageGeneratedOutputFile(std::string&& filename)
+{
+    impl_->files_.insert(std::move(filename));
+}
+
 std::string TestFileManager::getTestSpecificFileNameRoot()
 {
     const ::testing::TestInfo* test_info = ::testing::UnitTest::GetInstance()->current_test_info();
     std::string                filenameRoot;
     if (test_info)
     {
-        filenameRoot = std::string(test_info->test_case_name()) + "_" + test_info->name();
+        filenameRoot = std::string(test_info->test_suite_name()) + "_" + test_info->name();
     }
     else
     {
-        const ::testing::TestCase* test_case_info =
-                ::testing::UnitTest::GetInstance()->current_test_case();
+        const ::testing::TestSuite* test_case_info =
+                ::testing::UnitTest::GetInstance()->current_test_suite();
         filenameRoot = std::string(test_case_info->name());
     }
     std::replace(filenameRoot.begin(), filenameRoot.end(), '/', '_');