summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-04-30 20:51:29 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-04-30 19:11:28 +0000
commit9ce371fa1626bb845e702ceef66a730547b313a8 (patch)
tree4fe08a5c8363c307f0c0fc32e3deb8d611e8840d /sal
parenta229089527b64e2e7a929cf980ff7a0eef293787 (diff)
provide a way to execute single test case from test suite
CPPUNIT_TEST_NAME is the environment variable that needs to be set and contain the name of the tests. The test names need to be fully qualified to be recognized. Examples: CPPUNIT_TEST_NAME="ScFiltersTest::testOutlineODS ScFiltersTest::testRangeNameXLS" make CppunitTest_sc_subsequent_filters_test CPPUNIT_TEST_NAME="ScFiltersTest" make CppunitTest_sc_subsequent_filters_test Change-Id: I78a8a076638e19c918ca1c411086bb353f5100a2 Reviewed-on: https://gerrit.libreoffice.org/15579 Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/cppunittester/cppunittester.cxx33
1 files changed, 31 insertions, 2 deletions
diff --git a/sal/cppunittester/cppunittester.cxx b/sal/cppunittester/cppunittester.cxx
index ffad4d402b70..6c1541733ad5 100644
--- a/sal/cppunittester/cppunittester.cxx
+++ b/sal/cppunittester/cppunittester.cxx
@@ -49,6 +49,9 @@
#include "boost/noncopyable.hpp"
#include <boost/scoped_array.hpp>
+#include <boost/algorithm/string.hpp>
+
+#include <algorithm>
namespace {
@@ -161,6 +164,21 @@ private:
}
};
+namespace {
+
+void addRecursiveTests(const std::vector<std::string>& test_names, CppUnit::Test* pTest, CppUnit::TestRunner& rRunner)
+{
+ for (int i = 0; i < pTest->getChildTestCount(); ++i)
+ {
+ CppUnit::Test* pNewTest = pTest->getChildTestAt(i);
+ addRecursiveTests(test_names, pNewTest, rRunner);
+ if (std::find(test_names.begin(), test_names.end(), pNewTest->getName()) != test_names.end())
+ rRunner.addTest(pNewTest);
+ }
+}
+
+}
+
//Allow the whole uniting testing framework to be run inside a "Protector"
//which knows about uno exceptions, so it can print the content of the
//exception before falling over and dying
@@ -241,9 +259,20 @@ public:
setenv("LO_TESTNAME", lib.c_str(), true);
#endif
+ const char* pVal = getenv("CPPUNIT_TEST_NAME");
+
CppUnit::TestRunner runner;
- runner.addTest(
- CppUnit::TestFactoryRegistry::getRegistry().makeTest());
+ if (pVal)
+ {
+ std::vector<std::string> test_names;
+ boost::split(test_names, pVal, boost::is_any_of("\t "));
+ CppUnit::Test* pTest = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+ addRecursiveTests(test_names, pTest, runner);
+ }
+ else
+ {
+ runner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest());
+ }
runner.run(result);
CppUnit::CompilerOutputter outputter(&collector, CppUnit::stdCErr());