add possibility of passing command line args down to tests

This commit is contained in:
Caolán McNamara 2011-02-21 17:50:17 +00:00
parent fccef9d68d
commit d7d7e6f8d4

View file

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