impl_->outputFiles_.emplace_back(option, fullFilename, matcher.createFileMatcher());
}
+void CommandLineTestHelper::setOutputFileWithGeneratedName(const char* filename,
+ const ITextBlockMatcherSettings& matcher)
+{
+ setOutputFileWithGeneratedName(std::string(filename), TextFileMatch(matcher));
+}
+
+void CommandLineTestHelper::setOutputFileWithGeneratedName(std::string&& filename,
+ const ITextBlockMatcherSettings& matcher)
+{
+ setOutputFileWithGeneratedName(std::move(filename), TextFileMatch(matcher));
+}
+
+void CommandLineTestHelper::setOutputFileWithGeneratedName(const char* filename,
+ const IFileMatcherSettings& matcher)
+{
+ setOutputFileWithGeneratedName(std::string(filename), matcher);
+}
+
+void CommandLineTestHelper::setOutputFileWithGeneratedName(std::string&& filename,
+ const IFileMatcherSettings& matcher)
+{
+ impl_->outputFiles_.emplace_back(filename.c_str(), filename, matcher.createFileMatcher());
+ impl_->fileManager_.manageGeneratedOutputFile(std::move(filename));
+}
+
void CommandLineTestHelper::checkOutputFiles(TestReferenceChecker checker) const
{
if (!impl_->outputFiles_.empty())
impl_->helper_.setOutputFile(&impl_->cmdline_, option, filename, matcher);
}
+void CommandLineTestBase::setOutputFileWithGeneratedName(const char* filename,
+ const ITextBlockMatcherSettings& matcher)
+{
+ impl_->helper_.setOutputFileWithGeneratedName(std::string(filename), matcher);
+}
+
+void CommandLineTestBase::setOutputFileWithGeneratedName(std::string&& filename,
+ const ITextBlockMatcherSettings& matcher)
+{
+ impl_->helper_.setOutputFileWithGeneratedName(std::move(filename), matcher);
+}
+
+void CommandLineTestBase::setOutputFileWithGeneratedName(const char* filename,
+ const IFileMatcherSettings& matcher)
+{
+ impl_->helper_.setOutputFileWithGeneratedName(std::string(filename), matcher);
+}
+
+void CommandLineTestBase::setOutputFileWithGeneratedName(std::string&& filename,
+ const IFileMatcherSettings& matcher)
+{
+ impl_->helper_.setOutputFileWithGeneratedName(std::move(filename), matcher);
+}
+
void CommandLineTestBase::setInputAndOutputFile(const char* option,
const char* filename,
const ITextBlockMatcherSettings& matcher)
const char* option,
const char* filename,
const IFileMatcherSettings& matcher);
+ /*! \brief As for \c setOutputFile() but does not create an option
+ *
+ * This method is useful when a tool generates a series of output
+ * files by modifying a common base name. Call this method with
+ * every file name that is expected to be generated by the tool. */
+ void setOutputFileWithGeneratedName(const char* filename, const ITextBlockMatcherSettings& matcher);
+ //! \copydoc setOutputFileWithGeneratedName(const char *, const ITextBlockMatcherSettings &)
+ void setOutputFileWithGeneratedName(std::string&& filename, const ITextBlockMatcherSettings& matcher);
+ //! \copydoc setOutputFileWithGeneratedName(const char *, const ITextBlockMatcherSettings &)
+ void setOutputFileWithGeneratedName(const char* filename, const IFileMatcherSettings& matcher);
+ //! \copydoc setOutputFileWithGeneratedName(const char *, const ITextBlockMatcherSettings &)
+ void setOutputFileWithGeneratedName(std::string&& filename, const IFileMatcherSettings& matcher);
/*! \brief
* Checks output files added with setOutputFile() against reference
const char* extension,
const ArrayRef<const char* const>& contents);
/*! \brief
- * Sets an output file parameter and adds it to the set of tested files.
+ * Sets an output file whose name is passed via an option and adds it to the set of tested files.
*
* \see CommandLineTestHelper::setOutputFile()
*/
void setOutputFile(const char* option, const char* filename, const ITextBlockMatcherSettings& matcher);
- /*! \brief
- * Sets an output file parameter and adds it to the set of tested files.
- *
- * \see CommandLineTestHelper::setOutputFile()
- */
+ //! \copydoc setOutputFile(const char *, const ITextBlockMatcherSettings &)
void setOutputFile(const char* option, const char* filename, const IFileMatcherSettings& matcher);
+ /*! \brief
+ * Sets an output file whose name is generated by the tool and adds it to the set of tested files.
+ *
+ * This method is useful when a tool generates a series of output
+ * files by modifying a common base name. Call this method with
+ * every file name that is expected to be generated by the tool.
+ *
+ * \see CommandLineTestHelper::setOutputFileWithGeneratedName() */
+ void setOutputFileWithGeneratedName(const char* filename, const ITextBlockMatcherSettings& matcher);
+ //! \copydoc setOutputFileWithGeneratedName(const char *, const ITextBlockMatcherSettings &)
+ void setOutputFileWithGeneratedName(std::string&& filename, const ITextBlockMatcherSettings& matcher);
+ //! \copydoc setOutputFileWithGeneratedName(const char *, const ITextBlockMatcherSettings &)
+ void setOutputFileWithGeneratedName(const char* filename, const IFileMatcherSettings& matcher);
+ //! \copydoc setOutputFileWithGeneratedName(const char *, const ITextBlockMatcherSettings &)
+ void setOutputFileWithGeneratedName(std::string&& filename, const IFileMatcherSettings& matcher);
/*! \brief
* Sets a file parameter that is used for input and modified as output. The input file
* is copied to a temporary file that is used as input and can be modified.
//! \copydoc TestFileManager::getTemporaryFilePath(const char *)
std::string getTemporaryFilePath(const std::string& suffix);
+ /*! \brief
+ * Manage cleaning up this output file whose name was generated
+ *
+ * \param[in] filename Filename relative to the working directory
+ * (which is generally not the output directory)
+ *
+ * This method should only be called from within a Google Test
+ * test. It lets the TestFileManager know to attempt to clean up
+ * the named file. That file should normally be one whose name is
+ * generated by the tool under test. For an output file whose name
+ * is specified by e.g. an input command-line option, pass the
+ * return value of getTemporaryFilePath() to that option.
+ */
+ void manageGeneratedOutputFile(const char* filename);
+ //! \copydoc TestFileManager::manageGeneratedOutputFile(const char *)
+ void manageGeneratedOutputFile(std::string&& filename);
+
/*! \brief Returns the path to the output temporary directory
* for tests which use this TestFileManager object.
*
* 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.
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(), '/', '_');
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2015,2016,2017,2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016,2017,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.
{
continue;
}
+ // Ignore ampersand dataset separators (for now)
+ // Later, when we need to test code that writes multiple
+ // datasets, we might want to introduce that new concept
+ // to this testing code.
+ if (startsWith(line, "&"))
+ {
+ continue;
+ }
if (startsWith(line, "@"))
{
if (isRelevantXvgCommand(line))