summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-10-21 11:14:34 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-04-11 14:14:52 +0200
commit64eaa35c2de99581e522608e841defffb4b2923b (patch)
treee78c7a9ef6c0bf17a5c8a047b34912b15084748a
parentd69305b4bdc66e0592af45d4243f483ca446d7a3 (diff)
downloadcppunit-64eaa35c2de99581e522608e841defffb4b2923b.tar.gz
Run tests in deterministic order
LibreOffice already benefits from this (see <https://git.libreoffice.org/core/+/2f2246d22e2a8ccbc1dc3e6f5243734a61edf270%5E!> "external/cppunit: Run tests in deterministic order", especially as otherwise the order in which tests happened to get run differed between --disable-lto and --enable-lto builds. Change-Id: I87d6d7cb0f4c2f6a0ea1ac3ba3d48b4e089eb5c7 Reviewed-on: https://gerrit.libreoffice.org/c/cppunit/+/123963 Tested-by: Stephan Bergmann <sbergman@redhat.com> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--src/cppunit/TestFactoryRegistry.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/cppunit/TestFactoryRegistry.cpp b/src/cppunit/TestFactoryRegistry.cpp
index 35448a6..3b68d58 100644
--- a/src/cppunit/TestFactoryRegistry.cpp
+++ b/src/cppunit/TestFactoryRegistry.cpp
@@ -143,12 +143,20 @@ TestFactoryRegistry::makeTest()
void
TestFactoryRegistry::addTestToSuite( TestSuite *suite )
{
+ std::multimap<std::string, Test *> sorted;
for ( Factories::iterator it = m_factories.begin();
it != m_factories.end();
++it )
{
TestFactory *factory = *it;
- suite->addTest( factory->makeTest() );
+ Test *test = factory->makeTest();
+ sorted.insert({test->getName(), test});
+ }
+ // In the unlikely case of multiple Tests with identical names, those will
+ // still be added in random order:
+ for (auto const &i: sorted)
+ {
+ suite->addTest( i.second );
}
}