src/cppunit/TestFactoryRegistry.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
New commits: commit 64eaa35c2de99581e522608e841defffb4b2923b Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Oct 21 11:14:34 2021 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Mon Apr 11 14:14:52 2022 +0200 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 <sberg...@redhat.com> Reviewed-by: Stephan Bergmann <sberg...@redhat.com> 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 ); } }