From d117d974184e47ba2a5f2c8181207556f19ee5ef Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 13 Apr 2012 16:46:53 +0100 Subject: push and pop protectors around runner run, hopefully fixes windows build --- sal/cppunittester/cppunittester.cxx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'sal/cppunittester') diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx index 22ac029c4240..7886c80d1253 100644 --- a/sal/cppunittester/cppunittester.cxx +++ b/sal/cppunittester/cppunittester.cxx @@ -119,10 +119,12 @@ private: const std::string &testlib; const std::string &args; CppUnit::TestResult &result; + std::vector &protectors; public: - ProtectedFixtureFunctor(const std::string& testlib_, const std::string &args_, CppUnit::TestResult &result_) + ProtectedFixtureFunctor(const std::string& testlib_, const std::string &args_, std::vector &protectors_, CppUnit::TestResult &result_) : testlib(testlib_) , args(args_) + , protectors(protectors_) , result(result_) { } @@ -150,8 +152,14 @@ public: result.addListener(&timer); #endif + for (size_t i = 0; i < protectors.size(); ++i) + result.pushProtector(protectors[i]); + runner.run(result); + for (size_t i = 0; i < protectors.size(); ++i) + result.popProtector(); + CppUnit::CompilerOutputter(&collector, CppUnit::stdCErr()).write(); return collector.wasSuccessful(); } @@ -180,7 +188,7 @@ SAL_IMPLEMENT_MAIN() { #endif boost::ptr_vector modules; - CppUnit::Protector *throw_protector = 0; + std::vector protectors; CppUnit::TestResult result; std::string args; std::string testlib; @@ -218,20 +226,20 @@ SAL_IMPLEMENT_MAIN() { rtl::OUString sym(RTL_CONSTASCII_USTRINGPARAM("unoexceptionprotector")); oslGenericFunction fn = (oslGenericFunction) unoexceptionprotector; #endif - throw_protector = fn == 0 + CppUnit::Protector *protector = fn == 0 ? 0 : (*reinterpret_cast< cppunittester::ProtectorFactory * >(fn))(); - if (throw_protector == 0) { + if (protector == 0) { std::cerr << "Failure instantiating protector \"" << convertLazy(lib) << "\", \"" << convertLazy(sym) << '"' << std::endl; std::exit(EXIT_FAILURE); } - result.pushProtector(throw_protector); + protectors.push_back(protector); index+=3; } - ProtectedFixtureFunctor tests(testlib, args, result); + ProtectedFixtureFunctor tests(testlib, args, protectors, result); bool ok = tests.run(); return ok ? EXIT_SUCCESS : EXIT_FAILURE; -- cgit