[Libreoffice-commits] .: sal/cppunittester

Caolán McNamara caolan at kemper.freedesktop.org
Tue Feb 22 13:16:52 PST 2011


 sal/cppunittester/cppunittester.cxx |   29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

New commits:
commit 075e9b99300ddeb2b6d33fd9ddefae07225e06d3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Feb 21 17:50:17 2011 +0000

    add possibility of passing command line args down to tests

diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx
index 47398b8..87d2501 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -36,7 +36,6 @@
 #include <windows.h>
 #endif
 
-
 #include "cppunit/CompilerOutputter.h"
 #include "cppunit/TestResult.h"
 #include "cppunit/TestResultCollector.h"
@@ -50,22 +49,38 @@
 #include "rtl/ustring.hxx"
 #include "sal/main.h"
 
-SAL_IMPLEMENT_MAIN() {
+SAL_IMPLEMENT_MAIN()
+{
 
 #ifdef WNT
+    //Disable Dr-Watson in order to crash simply without popup dialogs under
+    //windows
     DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
     SetErrorMode(SEM_NOGPFAULTERRORBOX|dwMode);
 #endif
 
-    if (rtl_getAppCommandArgCount() < 1) {
+    sal_uInt32 nCommandArgs = rtl_getAppCommandArgCount();
+    if (nCommandArgs < 1)
+    {
         std::cerr << "Usage: cppunittester <shared-library-path>" << std::endl;
         return EXIT_FAILURE;
     }
-    rtl::OUString path;
-    rtl_getAppCommandArg(0, &path.pData);
+    std::string testlib;
+    {
+        rtl::OUString path;
+        rtl_getAppCommandArg(0, &path.pData);
+        testlib = rtl::OUStringToOString(path, osl_getThreadTextEncoding()).getStr();
+    }
+    std::string args = testlib;
+    for (sal_uInt32 i = 1; i < nCommandArgs; ++i)
+    {
+        rtl::OUString arg;
+        rtl_getAppCommandArg(i, &arg.pData);
+        args += ' ';
+        args += rtl::OUStringToOString(arg, osl_getThreadTextEncoding()).getStr();
+    }
     CppUnit::PlugInManager manager;
-    manager.load(
-        rtl::OUStringToOString(path, osl_getThreadTextEncoding()).getStr());
+    manager.load(testlib, args);
     CppUnit::TestRunner runner;
     runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
     CppUnit::TestResult result;


More information about the Libreoffice-commits mailing list