diff --git a/src/libs/solutions/tasking/tasktree.cpp b/src/libs/solutions/tasking/tasktree.cpp index 3a4f76f1469..b9355d07b18 100644 --- a/src/libs/solutions/tasking/tasktree.cpp +++ b/src/libs/solutions/tasking/tasktree.cpp @@ -498,8 +498,8 @@ private: afterwards, even when some other tasks in the group finished with an error. If all child tasks finish with an error, the group finishes with an error. If a group is empty, it finishes with an error. - \value StopOnFinished - Corresponds to the stopOnFinished global element. + \value StopOnSuccessOrError + Corresponds to the stopOnSuccessOrError global element. The group starts as many tasks as it can. When any task finishes, the group stops and reports the task's result. Useful only in parallel mode. @@ -518,7 +518,7 @@ private: If a group is empty, it finishes with an error. Whenever a child task's result causes the Group to stop, - i.e. in case of StopOnError, StopOnSuccess, or StopOnFinished policies, + i.e. in case of StopOnError, StopOnSuccess, or StopOnSuccessOrError policies, the Group stops the other running child tasks (if any - for example in parallel mode), and skips executing tasks it has not started yet (for example, in the sequential mode - those, that are placed after the failed task). Both stopping and skipping child tasks @@ -553,7 +553,7 @@ private: \li Success when at least one child task succeeded, an error otherwise \li An error \row - \li StopOnFinished + \li StopOnSuccessOrError \li Stops when any child task finished and reports child task's result \li Success or an error, depending on the finished child task's result \li An error @@ -571,8 +571,9 @@ private: If a child of a group is also a group, the child group runs its tasks according to its own workflow policy. When a parent group stops the running child group because - of parent group's workflow policy, i.e. when the StopOnError, StopOnSuccess, or StopOnFinished - policy was used for the parent, the child group's result is reported according to the + of parent group's workflow policy, i.e. when the StopOnError, StopOnSuccess, + or StopOnSuccessOrError policy was used for the parent, + the child group's result is reported according to the \b Result column and to the \b {child group's workflow policy} row in the table above. */ @@ -625,8 +626,8 @@ private: */ /*! - \variable stopOnFinished - A convenient global group's element describing the StopOnFinished workflow policy. + \variable stopOnSuccessOrError + A convenient global group's element describing the StopOnSuccessOrError workflow policy. */ /*! @@ -815,7 +816,7 @@ GroupItem parallelLimit(int limit) For convenience, global elements may be used instead. - \sa stopOnError, continueOnError, stopOnSuccess, continueOnSuccess, stopOnFinished, + \sa stopOnError, continueOnError, stopOnSuccess, continueOnSuccess, stopOnSuccessOrError, finishAllAndSuccess, finishAllAndError, WorkflowPolicy */ GroupItem workflowPolicy(WorkflowPolicy policy) @@ -830,7 +831,7 @@ const GroupItem stopOnError = workflowPolicy(WorkflowPolicy::StopOnError); const GroupItem continueOnError = workflowPolicy(WorkflowPolicy::ContinueOnError); const GroupItem stopOnSuccess = workflowPolicy(WorkflowPolicy::StopOnSuccess); const GroupItem continueOnSuccess = workflowPolicy(WorkflowPolicy::ContinueOnSuccess); -const GroupItem stopOnFinished = workflowPolicy(WorkflowPolicy::StopOnFinished); +const GroupItem stopOnSuccessOrError = workflowPolicy(WorkflowPolicy::StopOnSuccessOrError); const GroupItem finishAllAndSuccess = workflowPolicy(WorkflowPolicy::FinishAllAndSuccess); const GroupItem finishAllAndError = workflowPolicy(WorkflowPolicy::FinishAllAndError); @@ -1040,7 +1041,7 @@ GroupItem GroupItem::withTimeout(const GroupItem &item, milliseconds timeout, const auto onSetup = [timeout](milliseconds &timeoutData) { timeoutData = timeout; }; return Group { parallel, - stopOnFinished, + stopOnSuccessOrError, Group { finishAllAndError, handler ? TimeoutTask(onSetup, [handler] { handler(); }, CallDoneIf::Success) @@ -1321,7 +1322,7 @@ static bool initialSuccessBit(WorkflowPolicy workflowPolicy) return true; case WorkflowPolicy::StopOnSuccess: case WorkflowPolicy::ContinueOnSuccess: - case WorkflowPolicy::StopOnFinished: + case WorkflowPolicy::StopOnSuccessOrError: case WorkflowPolicy::FinishAllAndError: return false; } @@ -1350,8 +1351,8 @@ bool TaskContainer::RuntimeData::updateSuccessBit(bool success) { if (m_constData.m_workflowPolicy == WorkflowPolicy::FinishAllAndSuccess || m_constData.m_workflowPolicy == WorkflowPolicy::FinishAllAndError - || m_constData.m_workflowPolicy == WorkflowPolicy::StopOnFinished) { - if (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnFinished) + || m_constData.m_workflowPolicy == WorkflowPolicy::StopOnSuccessOrError) { + if (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnSuccessOrError) m_successBit = success; return m_successBit; } @@ -1440,7 +1441,7 @@ SetupResult TaskContainer::childDone(bool success) { QT_CHECK(isRunning()); const int limit = m_runtimeData->currentLimit(); // Read before bumping m_doneCount and stop() - const bool shouldStop = m_constData.m_workflowPolicy == WorkflowPolicy::StopOnFinished + const bool shouldStop = m_constData.m_workflowPolicy == WorkflowPolicy::StopOnSuccessOrError || (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnSuccess && success) || (m_constData.m_workflowPolicy == WorkflowPolicy::StopOnError && !success); if (shouldStop) diff --git a/src/libs/solutions/tasking/tasktree.h b/src/libs/solutions/tasking/tasktree.h index deef203daf9..ab0dd551c6e 100644 --- a/src/libs/solutions/tasking/tasktree.h +++ b/src/libs/solutions/tasking/tasktree.h @@ -103,13 +103,13 @@ private: enum class WorkflowPolicy { - StopOnError, // 1a - Reports error on first child error, otherwise success (if all children were success). - ContinueOnError, // 1b - The same, but children execution continues. Reports success when no children. - StopOnSuccess, // 2a - Reports success on first child success, otherwise error (if all children were error). - ContinueOnSuccess, // 2b - The same, but children execution continues. Reports error when no children. - StopOnFinished, // 3 - Stops on first finished child and report its result. - FinishAllAndSuccess, // 4 - Reports success after all children finished. - FinishAllAndError // 5 - Reports error after all children finished. + StopOnError, // 1a - Reports error on first child error, otherwise success (if all children were success). + ContinueOnError, // 1b - The same, but children execution continues. Reports success when no children. + StopOnSuccess, // 2a - Reports success on first child success, otherwise error (if all children were error). + ContinueOnSuccess, // 2b - The same, but children execution continues. Reports error when no children. + StopOnSuccessOrError, // 3 - Stops on first finished child and report its result. + FinishAllAndSuccess, // 4 - Reports success after all children finished. + FinishAllAndError // 5 - Reports error after all children finished. }; Q_ENUM_NS(WorkflowPolicy); @@ -321,7 +321,7 @@ TASKING_EXPORT extern const GroupItem stopOnError; TASKING_EXPORT extern const GroupItem continueOnError; TASKING_EXPORT extern const GroupItem stopOnSuccess; TASKING_EXPORT extern const GroupItem continueOnSuccess; -TASKING_EXPORT extern const GroupItem stopOnFinished; +TASKING_EXPORT extern const GroupItem stopOnSuccessOrError; TASKING_EXPORT extern const GroupItem finishAllAndSuccess; TASKING_EXPORT extern const GroupItem finishAllAndError; diff --git a/tests/auto/solutions/tasking/tst_tasking.cpp b/tests/auto/solutions/tasking/tst_tasking.cpp index c2116cbb940..ec90218f3a4 100644 --- a/tests/auto/solutions/tasking/tst_tasking.cpp +++ b/tests/auto/solutions/tasking/tst_tasking.cpp @@ -614,7 +614,7 @@ void tst_Tasking::testTree_data() QTest::newRow("DoneAndContinueOnError") << doneData(WorkflowPolicy::ContinueOnError); QTest::newRow("DoneAndStopOnSuccess") << doneData(WorkflowPolicy::StopOnSuccess); QTest::newRow("DoneAndContinueOnSuccess") << doneData(WorkflowPolicy::ContinueOnSuccess); - QTest::newRow("DoneAndStopOnFinished") << doneData(WorkflowPolicy::StopOnFinished); + QTest::newRow("DoneAndStopOnSuccessOrError") << doneData(WorkflowPolicy::StopOnSuccessOrError); QTest::newRow("DoneAndFinishAllAndSuccess") << doneData(WorkflowPolicy::FinishAllAndSuccess); QTest::newRow("DoneAndFinishAllAndError") << doneData(WorkflowPolicy::FinishAllAndError); @@ -622,7 +622,7 @@ void tst_Tasking::testTree_data() QTest::newRow("ErrorAndContinueOnError") << errorData(WorkflowPolicy::ContinueOnError); QTest::newRow("ErrorAndStopOnSuccess") << errorData(WorkflowPolicy::StopOnSuccess); QTest::newRow("ErrorAndContinueOnSuccess") << errorData(WorkflowPolicy::ContinueOnSuccess); - QTest::newRow("ErrorAndStopOnFinished") << errorData(WorkflowPolicy::StopOnFinished); + QTest::newRow("ErrorAndStopOnSuccessOrError") << errorData(WorkflowPolicy::StopOnSuccessOrError); QTest::newRow("ErrorAndFinishAllAndSuccess") << errorData(WorkflowPolicy::FinishAllAndSuccess); QTest::newRow("ErrorAndFinishAllAndError") << errorData(WorkflowPolicy::FinishAllAndError); } @@ -974,8 +974,8 @@ void tst_Tasking::testTree_data() QTest::newRow("EmptyContinueOnSuccess") << TestData{storage, root4, errorLog, 0, DoneWith::Error}; - const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); - QTest::newRow("EmptyStopOnFinished") << TestData{storage, root5, errorLog, 0, + const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError); + QTest::newRow("EmptyStopOnSuccessOrError") << TestData{storage, root5, errorLog, 0, DoneWith::Error}; const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); @@ -1026,8 +1026,8 @@ void tst_Tasking::testTree_data() QTest::newRow("DoneContinueOnSuccess") << TestData{storage, root4, doneLog, 1, DoneWith::Success}; - const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); - QTest::newRow("DoneStopOnFinished") << TestData{storage, root5, doneLog, 1, + const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError); + QTest::newRow("DoneStopOnSuccessOrError") << TestData{storage, root5, doneLog, 1, DoneWith::Success}; const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); @@ -1078,8 +1078,8 @@ void tst_Tasking::testTree_data() QTest::newRow("ErrorContinueOnSuccess") << TestData{storage, root4, errorLog, 1, DoneWith::Error}; - const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); - QTest::newRow("ErrorStopOnFinished") << TestData{storage, root5, errorLog, 1, + const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError); + QTest::newRow("ErrorStopOnSuccessOrError") << TestData{storage, root5, errorLog, 1, DoneWith::Error}; const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); @@ -1147,8 +1147,8 @@ void tst_Tasking::testTree_data() QTest::newRow("StopRootWithContinueOnSuccess") << TestData{storage, root4, doneLog, 2, DoneWith::Success}; - const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); - QTest::newRow("StopRootWithStopOnFinished") + const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError); + QTest::newRow("StopRootWithStopOnSuccessOrError") << TestData{storage, root5, errorErrorLog, 2, DoneWith::Error}; const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); @@ -1234,8 +1234,8 @@ void tst_Tasking::testTree_data() QTest::newRow("StopRootAfterDoneWithContinueOnSuccess") << TestData{storage, root4, doneDoneLog, 3, DoneWith::Success}; - const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); - QTest::newRow("StopRootAfterDoneWithStopOnFinished") + const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError); + QTest::newRow("StopRootAfterDoneWithStopOnSuccessOrError") << TestData{storage, root5, doneErrorLog, 3, DoneWith::Success}; const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); @@ -1291,8 +1291,8 @@ void tst_Tasking::testTree_data() QTest::newRow("StopGroupWithContinueOnSuccess") << TestData{storage, root4, log, 2, DoneWith::Error}; - const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); - QTest::newRow("StopGroupWithStopOnFinished") + const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError); + QTest::newRow("StopGroupWithStopOnSuccessOrError") << TestData{storage, root5, log, 2, DoneWith::Error}; // TODO: Behavioral change! Fix Docs! @@ -1363,8 +1363,8 @@ void tst_Tasking::testTree_data() QTest::newRow("StopGroupAfterDoneWithContinueOnSuccess") << TestData{storage, root4, errorLog, 3, DoneWith::Error}; - const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); - QTest::newRow("StopGroupAfterDoneWithStopOnFinished") + const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError); + QTest::newRow("StopGroupAfterDoneWithStopOnSuccessOrError") << TestData{storage, root5, doneLog, 3, DoneWith::Error}; // TODO: Behavioral change! @@ -1433,8 +1433,8 @@ void tst_Tasking::testTree_data() QTest::newRow("StopGroupAfterErrorWithContinueOnSuccess") << TestData{storage, root4, longLog, 3, DoneWith::Error}; - const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); - QTest::newRow("StopGroupAfterErrorWithStopOnFinished") + const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError); + QTest::newRow("StopGroupAfterErrorWithStopOnSuccessOrError") << TestData{storage, root5, shortLog, 3, DoneWith::Error}; // TODO: Behavioral change! @@ -1502,13 +1502,13 @@ void tst_Tasking::testTree_data() }; QTest::newRow("ContinueOnSuccess") << TestData{storage, root4, doneLog, 3, DoneWith::Success}; - const Group root5 = createRoot(WorkflowPolicy::StopOnFinished); + const Group root5 = createRoot(WorkflowPolicy::StopOnSuccessOrError); const Log log5 { {1, Handler::Setup}, {1, Handler::Success}, {0, Handler::GroupSuccess} }; - QTest::newRow("StopOnFinished") << TestData{storage, root5, log5, 3, DoneWith::Success}; + QTest::newRow("StopOnSuccessOrError") << TestData{storage, root5, log5, 3, DoneWith::Success}; const Group root6 = createRoot(WorkflowPolicy::FinishAllAndSuccess); QTest::newRow("FinishAllAndSuccess") << TestData{storage, root6, doneLog, 3, DoneWith::Success}; @@ -1522,7 +1522,7 @@ void tst_Tasking::testTree_data() DoneResult secondResult) { return Group { parallel, - stopOnFinished, + stopOnSuccessOrError, Storage(storage), createTask(1, firstResult, 1000ms), createTask(2, secondResult, 1ms), @@ -1550,10 +1550,14 @@ void tst_Tasking::testTree_data() {0, Handler::GroupError} }; - QTest::newRow("StopOnFinished1") << TestData{storage, root1, success, 2, DoneWith::Success}; - QTest::newRow("StopOnFinished2") << TestData{storage, root2, failure, 2, DoneWith::Error}; - QTest::newRow("StopOnFinished3") << TestData{storage, root3, success, 2, DoneWith::Success}; - QTest::newRow("StopOnFinished4") << TestData{storage, root4, failure, 2, DoneWith::Error}; + QTest::newRow("StopOnSuccessOrError1") + << TestData{storage, root1, success, 2, DoneWith::Success}; + QTest::newRow("StopOnSuccessOrError2") + << TestData{storage, root2, failure, 2, DoneWith::Error}; + QTest::newRow("StopOnSuccessOrError3") + << TestData{storage, root3, success, 2, DoneWith::Success}; + QTest::newRow("StopOnSuccessOrError4") + << TestData{storage, root4, failure, 2, DoneWith::Error}; } {