From a205ffae3888d4ab4683d6d04104ebf6e2fdc3f6 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 20 Sep 2022 21:58:33 +0200 Subject: [PATCH] Fix adding last package of current batch already to staging repository --- librepomgr/buildactions/buildactionprivate.h | 1 + librepomgr/buildactions/conductbuild.cpp | 7 ++- .../conduct-build-test/bar/src/.PKGINFO | 3 ++ .../bar/src/bar-2-1-x86_64.pkg.tar.zst | Bin 0 -> 162 bytes .../conduct-build-test/foo/src/.PKGINFO | 3 ++ .../foo/src/foo-1-1-x86_64.pkg.tar.zst | Bin 0 -> 158 bytes librepomgr/tests/buildactions.cpp | 43 ++++++++++++------ 7 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 librepomgr/testfiles/building/build-data/conduct-build-test/bar/src/.PKGINFO create mode 100644 librepomgr/testfiles/building/build-data/conduct-build-test/bar/src/bar-2-1-x86_64.pkg.tar.zst create mode 100644 librepomgr/testfiles/building/build-data/conduct-build-test/foo/src/.PKGINFO create mode 100644 librepomgr/testfiles/building/build-data/conduct-build-test/foo/src/foo-1-1-x86_64.pkg.tar.zst diff --git a/librepomgr/buildactions/buildactionprivate.h b/librepomgr/buildactions/buildactionprivate.h index ab73409..b68893e 100644 --- a/librepomgr/buildactions/buildactionprivate.h +++ b/librepomgr/buildactions/buildactionprivate.h @@ -527,6 +527,7 @@ private: bool m_skipBatchesAfterFailure; bool m_hasFailuresInPreviousBatches; std::atomic_bool m_enableStagingInNextBatch; + std::atomic_bool m_enableStagingInThisBatch; std::atomic_bool m_stagingEnabled; }; diff --git a/librepomgr/buildactions/conductbuild.cpp b/librepomgr/buildactions/conductbuild.cpp index ba3ee6d..348e95c 100644 --- a/librepomgr/buildactions/conductbuild.cpp +++ b/librepomgr/buildactions/conductbuild.cpp @@ -81,6 +81,7 @@ BatchProcessingSession::BatchProcessingSession(const std::unordered_setbegin(); m_packageEnd = m_batchIterator->end(); m_firstPackageInBatch = true; - m_stagingEnabled = m_stagingEnabled || m_enableStagingInNextBatch; + m_enableStagingInThisBatch.store(m_enableStagingInNextBatch); } /*! diff --git a/librepomgr/testfiles/building/build-data/conduct-build-test/bar/src/.PKGINFO b/librepomgr/testfiles/building/build-data/conduct-build-test/bar/src/.PKGINFO new file mode 100644 index 0000000..34cdeea --- /dev/null +++ b/librepomgr/testfiles/building/build-data/conduct-build-test/bar/src/.PKGINFO @@ -0,0 +1,3 @@ +pkgname = bar +pkgver = 2-1 +pkgdesc = another fake package for testing diff --git a/librepomgr/testfiles/building/build-data/conduct-build-test/bar/src/bar-2-1-x86_64.pkg.tar.zst b/librepomgr/testfiles/building/build-data/conduct-build-test/bar/src/bar-2-1-x86_64.pkg.tar.zst new file mode 100644 index 0000000000000000000000000000000000000000..ffe0d3ca39fe32d5567374fde1cbe1b482b47b0b GIT binary patch literal 162 zcmV;T0A2qmwJ-euSj_|gqKF(EV2g82bgVb1?FyO(+FBxP1t5*qk{1O594JQy2YVP1 zcKm~wH{-UjdpBnOx{1)kSH8eru;z{hAXomn!J0cBE3Uj9epqu)7&S|L?5O7B2&2^J zS}IvRvQ*lHY?Ag$H>qH)YCa{Us)-mJ3IszU5Dfq(!4HN*YbbL7Wl2!6D(5sq426TB QUILH?paILSWC|y61iI%!KL7v# literal 0 HcmV?d00001 diff --git a/librepomgr/testfiles/building/build-data/conduct-build-test/foo/src/.PKGINFO b/librepomgr/testfiles/building/build-data/conduct-build-test/foo/src/.PKGINFO new file mode 100644 index 0000000..25465a5 --- /dev/null +++ b/librepomgr/testfiles/building/build-data/conduct-build-test/foo/src/.PKGINFO @@ -0,0 +1,3 @@ +pkgname = foo +pkgver = 1-1 +pkgdesc = fake package for testing diff --git a/librepomgr/testfiles/building/build-data/conduct-build-test/foo/src/foo-1-1-x86_64.pkg.tar.zst b/librepomgr/testfiles/building/build-data/conduct-build-test/foo/src/foo-1-1-x86_64.pkg.tar.zst new file mode 100644 index 0000000000000000000000000000000000000000..80c23f6bc5c950e756e91d1091249e4ad6ade045 GIT binary patch literal 158 zcmV;P0Ac?qwJ-euSgiyA5{MfeP=#0r;C>%AaoYre%pPc>iA6?#5g|`B#!Pm>$cQxn z5qA7@mN(<3uzNRNo?L;gV9lWo?32F^V9g=NS)RNZZdh|q_$-w8m{HBg5k9HURm52R zu~J%<)=>L}C_Ru>%`3H3H4%eDfnZ1o0u2Bz!4KRaH5532iXpackageNames.clear(); // don't build only "boost" runBuildAction("conduct build with staging"); CPPUNIT_ASSERT_EQUAL_MESSAGE( - "staging needed: failure (as most build results are just dummies here)", BuildActionResult::Failure, m_buildAction->result); + "staging needed: failure as build result of baz is no valid archive", BuildActionResult::Failure, m_buildAction->result); CPPUNIT_ASSERT_EQUAL_MESSAGE( - "staging needed: no result data present", "failed to build packages: foo, bar, baz"s, std::get(m_buildAction->resultData)); + "staging needed: failed packages listed", "failed to build packages: baz"s, std::get(m_buildAction->resultData)); internalData = internalBuildAction(); const auto &rebuildList = internalData->m_buildProgress.rebuildList; const auto rebuildInfoForMisc = rebuildList.find("misc"); @@ -671,16 +676,24 @@ void BuildActionsTests::testConductingBuild() readFile("building/build-data/conduct-build-test/boost/pkg/repo-add.log")); // check whether package have been added to staging repo - CPPUNIT_ASSERT_MESSAGE( - "staging needed: package added to repo (0)", std::filesystem::is_regular_file("repos/boost-staging/os/src/boost-1.73.0-1.src.tar.gz")); - CPPUNIT_ASSERT_MESSAGE("staging needed: package added to repo (1)", + CPPUNIT_ASSERT_MESSAGE("staging needed: boost package added to staging repo (0)", + std::filesystem::is_regular_file("repos/boost-staging/os/src/boost-1.73.0-1.src.tar.gz")); + CPPUNIT_ASSERT_MESSAGE("staging needed: boost package added to staging repo (1)", std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-1.73.0-1-x86_64.pkg.tar.zst")); - CPPUNIT_ASSERT_MESSAGE("staging needed: package added to repo (2)", + CPPUNIT_ASSERT_MESSAGE("staging needed: boost package added to staging repo (2)", std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-libs-1.73.0-1-x86_64.pkg.tar.zst")); - CPPUNIT_ASSERT_MESSAGE("staging needed: signature added to repo (0)", + CPPUNIT_ASSERT_MESSAGE("staging needed: boost signature added to staging repo (0)", std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-1.73.0-1-x86_64.pkg.tar.zst.sig")); - CPPUNIT_ASSERT_MESSAGE("staging needed: signature added to repo (1)", + CPPUNIT_ASSERT_MESSAGE("staging needed: boost signature added to staging repo (1)", std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/boost-libs-1.73.0-1-x86_64.pkg.tar.zst.sig")); + CPPUNIT_ASSERT_MESSAGE("staging needed: foo package from first batch still added to normal repo (0)", + std::filesystem::is_regular_file("repos/boost/os/src/foo-1-1.src.tar.gz")); + CPPUNIT_ASSERT_MESSAGE("staging needed: foo package from first batch still added to normal repo (1)", + std::filesystem::is_regular_file("repos/boost/os/x86_64/foo-1-1-x86_64.pkg.tar.zst")); + CPPUNIT_ASSERT_MESSAGE("staging needed: bar package from next batch added to staging repo as well (0)", + std::filesystem::is_regular_file("repos/boost-staging/os/src/bar-2-1.src.tar.gz")); + CPPUNIT_ASSERT_MESSAGE("staging needed: bar package from next batch added to staging repo as well (1)", + std::filesystem::is_regular_file("repos/boost-staging/os/x86_64/bar-2-1-x86_64.pkg.tar.zst")); } // define expected errors for subsequent tests