Allow runAsMainSingleModule to be called more than once
[alexxy/gromacs.git] / src / testutils / testoptions.cpp
index 0457e1ca99054114f75161f53ed30dbee1e6469e..77f49b9dd1bf8df1cb7e469f4152a02147a65d8b 100644 (file)
@@ -39,6 +39,8 @@
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \ingroup module_testutils
  */
+#include "gmxpre.h"
+
 #include "testoptions.h"
 
 #include <cstdio>
@@ -48,7 +50,7 @@
 
 #include <gmock/gmock.h>
 
-#include "gromacs/legacyheaders/thread_mpi/mutex.h"
+#include "thread_mpi/mutex.h"
 
 #include "gromacs/commandline/cmdlinehelpcontext.h"
 #include "gromacs/commandline/cmdlinehelpwriter.h"
 #include "gromacs/utility/errorcodes.h"
 #include "gromacs/utility/exceptions.h"
 #include "gromacs/utility/file.h"
+#include "gromacs/utility/programcontext.h"
 
-#include "refdata.h"
-#include "testfilemanager.h"
-#include "mpi-printer.h"
+#include "testutils/mpi-printer.h"
+#include "testutils/refdata.h"
+#include "testutils/testfilemanager.h"
 
 namespace gmx
 {
@@ -129,6 +132,7 @@ void printHelp(const Options &options)
                  "to control the behavior of the tests:\n\n");
     CommandLineHelpContext context(&File::standardError(),
                                    eHelpOutputFormat_Console, NULL);
+    context.setModuleDisplayName(getProgramContext().displayName());
     CommandLineHelpWriter(options).writeHelp(context);
 }
 
@@ -151,7 +155,7 @@ void initTestUtils(const char *dataPath, const char *tempPath, int *argc, char *
         }
         if (tempPath != NULL)
         {
-            TestFileManager::setOutputTempDirectory(tempPath);
+            TestFileManager::setGlobalOutputTempDirectory(tempPath);
         }
         bool    bHelp = false;
         Options options(NULL, NULL);
@@ -185,7 +189,7 @@ void initTestUtils(const char *dataPath, const char *tempPath, int *argc, char *
     catch (const std::exception &ex)
     {
         printFatalErrorMessage(stderr, ex);
-        std::exit(processExceptionAtExit(ex));
+        std::exit(processExceptionAtExitForCommandLine(ex));
     }
 }