Code for checking xvg files in testutils.
[alexxy/gromacs.git] / src / testutils / cmdlinetest.cpp
index 3a848c94548aeaf0ff8dd9e3e4624d20a3740334..64688b8d862d3d55a48b26d5c41330949538f215 100644 (file)
@@ -55,6 +55,7 @@
 #include "gromacs/commandline/cmdlineoptionsmodule.h"
 #include "gromacs/commandline/cmdlineprogramcontext.h"
 #include "gromacs/utility/arrayref.h"
+#include "gromacs/utility/filestream.h"
 #include "gromacs/utility/gmxassert.h"
 #include "gromacs/utility/stringutil.h"
 #include "gromacs/utility/textreader.h"
@@ -62,6 +63,7 @@
 
 #include "testutils/refdata.h"
 #include "testutils/testfilemanager.h"
+#include "testutils/xvgtest.h"
 
 namespace gmx
 {
@@ -241,10 +243,12 @@ class CommandLineTestHelper::Impl
             OutputFileInfo(const char *option, const std::string &path)
                 : option(option), path(path)
             {
+                xvg = endsWith(path, ".xvg");
             }
 
             std::string         option;
             std::string         path;
+            bool                xvg;
         };
 
         typedef std::vector<OutputFileInfo>        OutputFileList;
@@ -346,8 +350,18 @@ void CommandLineTestHelper::checkOutputFiles(TestReferenceChecker checker) const
              outfile != impl_->outputFiles_.end();
              ++outfile)
         {
-            std::string output = TextReader::readFileToString(outfile->path);
-            outputChecker.checkStringBlock(output, outfile->option.c_str());
+            if (outfile->xvg)
+            {
+                TestReferenceChecker testChecker = checker.checkCompound("File",
+                                                                         outfile->option.c_str());
+                TextInputFile        sis(outfile->path);
+                checkXvgFile(&sis, &testChecker);
+            }
+            else
+            {
+                std::string output = TextReader::readFileToString(outfile->path);
+                outputChecker.checkStringBlock(output, outfile->option.c_str());
+            }
         }
     }
 }