Commit Graph

93 Commits

Author SHA1 Message Date
Jarek Kobus
c343e9b8f7 TaskTree: Fix For loop with empty body
Ensure the For loop iterates even when the loop's body is empty.
Simplify internals a bit.

Change-Id: I4a269d61fa324a9c36109e95e74a992e915a72b0
Reviewed-by: hjk <hjk@qt.io>
2024-07-17 14:48:03 +00:00
Jarek Kobus
779390829c TaskTree: Introduce For element
Improve code readability by requiring iteratable Group
to be named For.

The For's c'tor requires an iterator element as a first arg.

The For's c'tor allows for passing exactly one iterator element.

It's not possible to place iterators inside Group element anymore.

Change-Id: I9dfe2c0da058abac161f66c4e336da2417c383f1
Reviewed-by: hjk <hjk@qt.io>
2024-07-10 13:39:40 +00:00
Jarek Kobus
ff1125319a TaskTree: Introduce successItem and errorItem
They are useful in conditional statements to influence
the workflow of a group.

Add tests for nullItem, successItem and errorItem.

Fix some comments in tests.

Change-Id: If0faa579e256d5a943d22cf66fe5208d60a63e0d
Reviewed-by: hjk <hjk@qt.io>
2024-07-03 14:02:48 +00:00
Jarek Kobus
e5ccfeaae0 TaskTree: Add more tests for conditional API
Change-Id: I9e381d48d1ccfc86cb041e61100da6c0533c15e3
Reviewed-by: hjk <hjk@qt.io>
2024-07-03 14:02:41 +00:00
Jarek Kobus
ef71c022de TaskTree: Introduce conditional API
Change-Id: I002ea7636d12719cb1e27a4666e3869ea2254114
Reviewed-by: hjk <hjk@qt.io>
2024-07-03 14:02:34 +00:00
Jarek Kobus
0b19c83bed TaskTree: Make it possible to return bool from done handlers
Alternatively to returning DoneResult, for convenience.

Change-Id: Id845190a2a0587048ddb3a6c33019feca8cd0de7
Reviewed-by: hjk <hjk@qt.io>
2024-07-03 14:00:08 +00:00
Jarek Kobus
da218493c7 TaskTree: Introduce a bit more logic (AND and OR against DoneResult)
Introduce AND and OR operators for ExecutableItem
taking DoneResult.

The "task || DoneResult::Success" is an eqivalent to
tweaking the task's done result into success unconditionally.
The "task && DoneResult::Error" is an eqivalent to
tweaking the task's done result into error unconditionally.

Change-Id: Ib9213a786697c1434c37e99e726641baab550523
Reviewed-by: hjk <hjk@qt.io>
2024-07-03 06:53:46 +00:00
Jarek Kobus
490410e18d TaskTree: Introduce a bit of logic (AND and OR)
Introduce operator&& and operator|| taking ExecutableItem
as a second arg.

Both tasks (first and second) execute in sequence.

AND:
- If the 1st task finishes with Error, the 2nd task is skipped
  and the returned item reports Error.
- Otherwise, the 2nd task is executed
  and the returned item reports the 2nd task's result.

OR:
- If the 1st task finishes with Success, the 2nd task is skipped
  and the returned item reports Success.
- Otherwise, the 2nd task is executed
  and the returned item reports the 2nd task's result.

Change-Id: Ib7874a82bd86eeb57fa5d3691b4a9e63a158772f
Reviewed-by: hjk <hjk@qt.io>
2024-07-02 14:50:27 +00:00
Jarek Kobus
0f5882f13c TaskTree: Introduce a bit of logic (NOT)
Introduce ExecutableItem operator!(const ExecutableItem &item).

This operator returns a copy of this executable item
with DoneResult tweaked by negation.

If this item reports DoneResult::Success, the returned item reports
DoneResult::Error.
If this item reports DoneResult::Error, the returned item reports
DoneResult::Success.

Change-Id: Ie609938e92bbc38ddcc66f5bc3244f864e3e59c7
Reviewed-by: hjk <hjk@qt.io>
2024-07-02 14:50:18 +00:00
Jarek Kobus
33eb5f509c TaskTree: Make it possible to pass DoneResult as a done handler
This patch addresses the 38th point in the bugreport below.

Add tests for it.

Adapt docs and warning messages accordingly.

Task-number: QTCREATORBUG-28741
Change-Id: I276d2d4c3a514147f67252dc5073d79fed94b9ff
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2024-06-19 08:32:27 +00:00
Jarek Kobus
34044757ef TaskTree: Fix tweaking done result in group done handler
If the onGroupDone() handler returned DoneResult,
this result was ignored by the running task tree.

Fix it so that the optional DoneResult takes
priority over group's workflow policy.

Add tests for it.

Change-Id: I7ffdef2af08337d7214f2c3d4b68153cddaad425
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2024-06-19 07:41:38 +00:00
Jarek Kobus
e331329e4f TaskTree: Detect a misconfigured recipe of a nested task tree
Change-Id: I6652336023ac111cde5334e655f5dd972977b07f
Reviewed-by: hjk <hjk@qt.io>
2024-06-13 09:17:24 +00:00
Jarek Kobus
698488fc05 TaskTree: Add a test showing the parallel disorder
In parallel mode the done handlers may be invoked in a
different order than the corresponding setup handlers.

Change-Id: Ib3df668491054501d250fef9c499d127fe98626d
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2024-04-11 12:19:02 +00:00
Jarek Kobus
a583436365 TaskTree: Zero-initialize the Storage
Change-Id: I9d5ee11285b377abafe21d472481c941f49a5ae1
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2024-04-11 07:59:56 +00:00
Christian Stenger
32cad6d389 Tests: Fix build with Qt6.2
Amends d672908608.

Change-Id: Ie80c69ecb1e96a5c86800e8f431f01f6ed611e6d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2024-02-22 06:49:16 +00:00
Jarek Kobus
d672908608 TaskTree: Add info about sync/async execution into withLog()
Add tests for it.

This addresses the 35th point in the bugreport below.

Task-number: QTCREATORBUG-28741
Change-Id: Id35d51155e0bfd413c06b3a2c5bb57b8bcea8487
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-02-21 16:30:16 +00:00
Jarek Kobus
d4b5a1efda TaskTree: Check the right asyncCount() in tests
This is quite crucial test checking the right internal behavior.
The expected asyncCount numbers were added to these tests after
processing each recipe by hand and deducing the expected scenario
and the number of times each recipe should return the control to
the main event loop before the task tree finished.

Be very careful when correcting any of these numbers - this might
mean the internal change inside the task tree forcing the asyncCount
adjustment may break the task tree architecture.

Change-Id: Ia3acfbf3cb232ed95df97fe5822305df98e2271a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2024-02-21 06:51:31 +00:00
Jarek Kobus
5c8b87bf9d TaskTree: Simplify some test code
Change-Id: Id81969d00a6e183e0d7cdcfddc64fc65aab6e020
Reviewed-by: hjk <hjk@qt.io>
2024-02-21 06:48:18 +00:00
Jarek Kobus
62a203c926 TaskTree: Add tests for withLog() function
This addresses the 7th and 8th points in the bugreport below.

Task-number: QTCREATORBUG-28741
Change-Id: I5fe09227c1118e66c38bbe98ef720b21823c28ed
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-02-20 12:24:56 +00:00
Jarek Kobus
36241b4462 TaskTree: Add global nullItem
This might be useful when using conditional operator.
Might also be used in place of the default c'tor for GroupItem.

Add a test for it.

Change-Id: I622e5d3d94f7020dc294cf5bca643c53a0813d8a
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-02-16 06:21:53 +00:00
Jarek Kobus
0b3b5b892c TaskTree: Add a test for progress reporting with onGroupSetup(false)
Also for the case when parent iteration isn't progressive.

Change-Id: I831b86de68d504a1e5e189d2be2b12ffc7d97c60
Reviewed-by: hjk <hjk@qt.io>
2024-02-15 10:09:19 +00:00
Jarek Kobus
02ac5deb4a TaskTree: Fix progress reporting with nested LoopUntil(false)
Fix also a case when parent iteration isn't progressive.
Add a test for it.

Amends e059b62421

Change-Id: Ic2f8c047d413ab2e2b98af4592f7cb60185bea06
Reviewed-by: hjk <hjk@qt.io>
2024-02-15 10:08:49 +00:00
Jarek Kobus
e059b62421 TaskTree: Fix progress reporting with LoopUntil(false)
Advance the progress value by the group's children count when
LoopUntil handler returns false on the first iteration.

Add a test for it.

Change-Id: I3783dd295dfaa16c09c5eda299f365ff981b3be7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2024-02-15 06:42:07 +00:00
Jarek Kobus
05c6cffd6b TaskTree: Fix NestedParallelError test flakiness
Increase relevant timeouts.

Change-Id: I80fae036f41f3fef2c38345b86d160a2a9c62d6c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-02-01 16:28:01 +00:00
Jarek Kobus
983fc4bcf6 TaskTree: Rename stop() -> cancel()
This better corresponds to done handlers called
in this case with DoneWith::Cancel.

By the way, get rid of unused LocatorFilter::stop().

Change-Id: Ie4246b8d888fff95940a2ed41367d2817bd6339c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2024-01-25 09:26:12 +00:00
Jarek Kobus
359ab928b1 TaskTree: Add tests for Group's CallDoneIf
Change-Id: I7140c1c7e28f6f503520ad05e6dcd613dcec2df3
Reviewed-by: hjk <hjk@qt.io>
2024-01-24 11:52:40 +00:00
Jarek Kobus
14f6954026 TaskTree: Disconnect from task's done() signal on destruction
If a task or task's adapter sends done() signal directly
from the destructor (which isn't really desired),
ensure we disconnect from this signal beforehand,
otherwise this may start invoking normal handling of task done()
and interfere with the destruction.

Fix NetworkQuery d'tor.

Add a test for it.

Add some TODO items.

Fixes: QTCREATORBUG-30204
Change-Id: I56a34d0f00c961c15bd1bcffef45520a4be5bce0
Reviewed-by: hjk <hjk@qt.io>
2024-01-15 08:29:57 +00:00
Jarek Kobus
85a27b3ddd TaskTree: Implement progress reporting for LoopRepeat
When a number of repeats is known in advance,
make the progress reporting aware of it.

Add a test for it.

Change-Id: I676a4aa9eb469cfe40a2729d231c706dff3ca07c
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2024-01-13 03:02:41 +00:00
Jarek Kobus
db43e5d679 TaskTree: Introduce LoopUntil
In order to conform better with LoopRepeat and LoopForever.

Change-Id: Ic14cd072dc04951c0b142fd7379daf5541823a9a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2024-01-12 18:16:03 +00:00
Jarek Kobus
e8904041c2 TaskTree: Introduce Forever group
Rename Forever -> LoopForever, Repeat -> LoopRepeat.

Change-Id: Ic999c876762d2b092f23ae88ea6de341b68a1fc2
Reviewed-by: hjk <hjk@qt.io>
2024-01-11 11:34:43 +00:00
Jarek Kobus
3f1a381c58 TaskTree: Add tests for Loop functionality
Task-number: QTCREATORBUG-30081
Change-Id: I999a5ea1fc887a2a5de6497acc3642abb187ef74
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2024-01-10 09:46:58 +00:00
Jarek Kobus
ebaa13e277 TaskTree: Fix typo in test cases
Change-Id: Ie65e68b61643a8de8eec8d039cd4f874ec6fdd1f
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2024-01-10 07:58:15 +00:00
Jarek Kobus
24649c4980 TaskTree: Add a test for nested cancel
Change-Id: I5d4d329e6c069e744d25d6f94e1d33b53f288f13
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2024-01-08 08:42:00 +00:00
Jarek Kobus
16b40c5bb6 TaskTree: Fix stop() method
Reset internal data after a call to stop().
Add a test for restarting the task tree.

Change-Id: Iedf11d97c33c9001c818078abc816e3c483c42b8
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-01-08 08:09:25 +00:00
Jarek Kobus
23ed1977da TaskTree: Keep a stack of active storages
Make it possible to run a nested task tree containing
the common storage from the outer task tree's handler.
This means we need to manage the stack of active storages
per thread.

Add a test for it.

This addresses the 4th point in the report below.

Task-number: QTCREATORBUG-29103
Change-Id: Ib0f925048197625a0eb9f83f262c7256a5756cc8
Reviewed-by: hjk <hjk@qt.io>
2024-01-08 07:08:30 +00:00
Jarek Kobus
ce80a6dad5 TaskTree: Rename TreeStorage<> -> Storage<>
This addresses the 20th point in the master task below.

Task-number: QTCREATORBUG-28741
Change-Id: I696beda87430fbe637abba8054012fb77516e220
Reviewed-by: hjk <hjk@qt.io>
2023-11-20 08:25:50 +00:00
Jarek Kobus
767bb30b11 TaskTree: Hide more internals inside StorageBase class
Rename storage internals.

This addresses the 20th point in the master task below.

Task-number: QTCREATORBUG-28741
Change-Id: I1ed42472060de6180d4665d6504598adb57828fe
Reviewed-by: hjk <hjk@qt.io>
2023-11-20 07:48:04 +00:00
Jarek Kobus
ced3052e7f TaskTree: Get rid of Storage subclass of GroupItem
Make the c'tor of the GroupItem taking the TreeStorageBase
public instead.

This addresses the 20th point in the master task below.

Task-number: QTCREATORBUG-28741
Change-Id: I78320ec24b4e4b915ab549135fb93b45c658b9f2
Reviewed-by: hjk <hjk@qt.io>
2023-11-20 07:47:54 +00:00
Jarek Kobus
73bff6d497 TaskTree: Fix TimeoutTask ordering
Make ordering separate for each thread.
Add stress test for it.

Change-Id: Idb42ce2511b18c0e9dd4dcb216ca39b35b5c980e
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-17 17:09:19 +00:00
Jarek Kobus
659f0f000c TaskTree: Unify TaskInterface::done(DoneResult) signal
Change the argument of TaskInterface::done() signal
from bool into DoneResult. Make it consistent with
other TaskTree API.

Introduce toDoneResult(bool success) helper.

Change-Id: I7b3041d7c1ed0317c76adbc1fd37448231e85f82
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-11-17 09:44:20 +00:00
Jarek Kobus
79421fd597 TaskTree: Rename StopOnFinished into StopOnSuccessOrError
In order to conform to CallDoneIf::SuccessOrError.

Amends 2c0a59384c

Change-Id: I2704667ca8d005c63c13b62786010ce430f0b550
Reviewed-by: hjk <hjk@qt.io>
2023-11-08 13:04:36 +00:00
Jarek Kobus
1cc4e32a4b TaskTree tests: Fix testInThread test on mac
Amends a88f807e86

Change-Id: I852a8b75a634d1266c442f775ae7b8f066923ce5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-11-08 08:55:48 +00:00
Jarek Kobus
0938e6cf4d TaskTree: Use DoneWith in TaskTree::runBlocking()
Instead of using ambiguous bool.
Reuse it in place of OnDone enum in tests.

Change-Id: Ie83e82d9debb88ca19f71ecab40f8ad081293f41
Reviewed-by: hjk <hjk@qt.io>
2023-11-07 14:11:05 +00:00
Jarek Kobus
f771faf82d TaskTree: Use DoneResult in Group done handler
Instead of using ambiguous bool.

Change-Id: Icf63f0b129d4b81cc4324d7a100f5aaf2c8af44b
Reviewed-by: hjk <hjk@qt.io>
2023-11-07 14:10:57 +00:00
Jarek Kobus
0f6e6cebf7 TaskTree: Use DoneResult in Task done handler
Instead of using ambiguous bool.

Change-Id: I7eb8e97947f23161c5c2bf5e22575e49bea35d61
Reviewed-by: hjk <hjk@qt.io>
2023-11-07 14:10:50 +00:00
Jarek Kobus
7ff13f1eaa TaskTree: Introduce DoneResult, use it for Sync setup
Instead of using ambiguous bool.

Change-Id: Iec45b920a839ac3383abc2d0676e5834f282dddf
Reviewed-by: hjk <hjk@qt.io>
2023-11-07 14:10:43 +00:00
Jarek Kobus
88ac19f188 TaskTree tests: Add tests triggering runtime asserts
This addresses the 15th point in the master task below.

Task-number: QTCREATORBUG-28741
Change-Id: I9d449a6ce1538071f300b68b2929bcd437d1bb0f
Reviewed-by: hjk <hjk@qt.io>
2023-11-07 14:10:27 +00:00
Jarek Kobus
a88f807e86 TaskTree tests: Add stress test for storages
Run the same recipe concurrently. Test whether handling the same
storage concurrently works properly.

This addresses the 24th point in the master task below.

Task-number: QTCREATORBUG-28741
Change-Id: Ic3358bef335b96b7dc2b88ad8102c440db5dafbf
Reviewed-by: hjk <hjk@qt.io>
2023-11-07 14:10:20 +00:00
Jarek Kobus
e78d6bd3c4 TaskTree: Implement storage shadowing
Make it possible to have the same storage instance
placed in different groups.

When the same storage is placed in two nested groups,
implement storage shadowing so that when the inner group
is activated it activates only the innermost storage
and shadows any possible the same storages in parent groups.

Keep placing the same storage twice in one group forbidden.

This functionality is required to implement the task tree loops
(see 3rd point in the master task below).

This addresses the 23th point in the master task below.

Task-number: QTCREATORBUG-28741
Change-Id: Iba00bc32319430136a794974c14a1ab65272eaa9
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2023-11-07 14:10:04 +00:00
Jarek Kobus
c4070da464 TaskTree tests: Add tests for tweaking setup and done results
Task-number: QTCREATORBUG-29834
Change-Id: Ie1fcef1be874661aa2196566eaf98d7d6da4f678
Reviewed-by: hjk <hjk@qt.io>
2023-11-07 14:09:40 +00:00