From beaea53af79581ab031e258ae73dd5637c861932 Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Thu, 24 Aug 2023 08:51:48 +0200 Subject: [PATCH] Backport patch to run tests in deterministic order --- cppunit.spec | 4 +++ run-tests-in-deterministic-order.patch | 43 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 run-tests-in-deterministic-order.patch diff --git a/cppunit.spec b/cppunit.spec index 88c5f4a..4a994fe 100644 --- a/cppunit.spec +++ b/cppunit.spec @@ -10,6 +10,10 @@ License: LGPL-2.1-or-later Url: https://www.freedesktop.org/wiki/Software/cppunit/ Source: http://dev-www.libreoffice.org/src/%{name}-%{version}.tar.gz +# Backport patch to run tests in deterministic order +# https://gerrit.libreoffice.org/c/cppunit/+/123963 +Patch: run-tests-in-deterministic-order.patch + BuildRequires: doxygen BuildRequires: gcc-c++ BuildRequires: graphviz diff --git a/run-tests-in-deterministic-order.patch b/run-tests-in-deterministic-order.patch new file mode 100644 index 0000000..2942e42 --- /dev/null +++ b/run-tests-in-deterministic-order.patch @@ -0,0 +1,43 @@ +From 64eaa35c2de99581e522608e841defffb4b2923b Mon Sep 17 00:00:00 2001 +From: Stephan Bergmann +Date: Thu, 21 Oct 2021 11:14:34 +0200 +Subject: [PATCH] Run tests in deterministic order + +LibreOffice already benefits from this (see + +"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 +Reviewed-by: Stephan Bergmann +--- + +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 @@ + void + TestFactoryRegistry::addTestToSuite( TestSuite *suite ) + { ++ std::multimap 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 ); + } + } +