Add filterable sequential test groups#448
Conversation
|
@martijnbastiaan may I ask you to review this as the original author of sequential test groups? |
|
@Raveline I'd like to wait a little bit hoping for someone to come up with a more elegant solutions, but that's not too bad. Luckily If I forget about this PR, please ping me in a week from now. |
|
You're right, those two concerns did get mixed.
I think the name |
|
I wonder if this models what we want and sets us up for sensible naming? data ExecutionMode = Dependent | NonDependent ExecutionOrder
data ExecutionOrder = NoOrder | AnyOrder | InOrder
-- testGroup => NonDependent NoOrder
-- anyOrderTestGroup => NonDependent AnyOrder
-- inOrderTestGroup => NonDependent InOrder (renamed from `filterableSequentialTestGroup`)
-- dependentTestGroup => Dependent (renamed from `sequentialTestGroup`)
I'm not asking for this to happen in this PR, but I'm curious to hear your thoughts. |
|
@martijnbastiaan : I didn't think about this notion of order, but you are right, it is connected to the notion of filterable. If @Bodigrim is ok with the model you proposed, I'll be more than happy to try my hand at implementing it (minus the renaming of |
|
I'm fine with deprecating Given that there is no |
|
@martijnbastiaan wrote: data ExecutionOrder = NoOrder | AnyOrder | InOrderA priori, I would not understand the difference between data ExecutionOrder = NoSpecificOrder | SequentialOrderThis is linguistically clear. |
|
Agreed, "no order" and "any order" are linguistically the same. My 2ct would be that I'd much rather have: data ExecutionMode = Dependent | NonDependent Parallel
data Parallel = Parallel | NonParallelAs mentioned before, this leaves the door open for test order randomization. I doubt anyone really needs sequential execution for non-dependent test cases. |
|
Could "NonDependent" poissbly be "Independent"?.. Anyway, we are not going to expose these data types, so naming can be adjusted later. I'm roughly on board with the plan. |
|
One thing we need to spell out in the documentation: all the notion of sequencing / depending is just a hint to the default |
|
Where would you put the comment explaining this, @Bodigrim ? On the documentation for |
|
On the functions please. |
core/Test/Tasty/Core.hs
Outdated
| -- order, all dependencies will be run (overriding filter). | ||
| -- For parallel execution, see 'testGroup'. | ||
| -- | ||
| -- Note that this is will only work when used with a `TestManager`. If you use |
There was a problem hiding this comment.
"with the default TestManager"
(everything is a TestManager, launchTestTree is the default one)
ac2a884 to
a40a635
Compare
Bodigrim
left a comment
There was a problem hiding this comment.
@martijnbastiaan could you please review?
core/Test/Tasty/Run.hs
Outdated
| sequence trees | ||
| Sequential depType -> | ||
| snd <$> mapAccumM (goSeqGroup depType) mempty trees | ||
| (Independent Parallel) -> sequence trees |
There was a problem hiding this comment.
Redundant brackets, I think.
core/Test/Tasty/Core.hs
Outdated
| -- | ||
| -- Note that this is will only work when used with the default `TestManager`. | ||
| -- If you use another manager, like `tasty-rerun` for instance, sequentiality | ||
| -- will be ignored. |
There was a problem hiding this comment.
"might be possibly ignored", please, here and below.
core/Test/Tasty/Core.hs
Outdated
| -- | ||
| -- @since 1.5 | ||
| sequentialTestGroup :: TestName -> DependencyType -> [TestTree] -> TestTree | ||
| sequentialTestGroup nm depType = setSequential . TestGroup nm . map setParallel |
There was a problem hiding this comment.
So, are we going to deprecate this one and introduce a better name?
There was a problem hiding this comment.
Well, I didn't want to do it in advance, not knowing if there was a deprecation strategy in place. Just in case, I've added deprecation (and proper renaming in tests) in my last commit.
a40a635 to
e9c0d44
Compare
core/Test/Tasty/Core.hs
Outdated
| -- | Create a named group of test cases or other groups. Tests are executed in | ||
| -- order, all dependencies will be run (overriding filter). | ||
| -- For parallel execution, see 'testGroup'. |
There was a problem hiding this comment.
| -- | Create a named group of test cases or other groups. Tests are executed in | |
| -- order, all dependencies will be run (overriding filter). | |
| -- For parallel execution, see 'testGroup'. | |
| -- | Create a named group of test cases or other groups. Tests are executed in | |
| -- order and each test is considered a dependency of the next one. If a filter | |
| -- is applied, any dependencies are run too, even if they would otherwise not | |
| -- match the filter's criteria. | |
| -- | |
| -- For parallel execution, see 'testGroup'. For ordered test execution, but | |
| -- without dependencies, see 'inOrderTestGroup'. |
There was a problem hiding this comment.
This does not quite resolves #443, I think. What happens if one of sequential tests fails? Does it stop execution of subsequent ones?
There was a problem hiding this comment.
I thought that was covered by DependencyType, but after reading it I'm still not really sure what's going on. Do you think this PR should be blocked on that? I'm happy to open a new PR tackling the problem after merging this one -- I feel it's a problem I introduced to begin with.
There was a problem hiding this comment.
My understanding is that in a AllSucceed block, you will have the behaviour described by @Bodigrim (but not in an AllFinish one).
I'm not sure there is actually a use-case for this (but I might be lacking imagination !). I think users are more likely to need a "stop at the first failed test" (disregarding any dependency and / or order) flag for the whole runner, which I don't think Tasty offer and would be a neat addition.
There was a problem hiding this comment.
Do you think this PR should be blocked on that? I'm happy to open a new PR tackling the problem after merging this one -- I feel it's a problem I introduced to begin with.
Sure, no problem.
There was a problem hiding this comment.
I'm happy to open a new PR tackling the problem after merging this one -- I feel it's a problem I introduced to begin with.
@martijnbastiaan just a kind reminder.
There was a problem hiding this comment.
It is on my stack, but the stack is big at the moment..
Improve documentation Co-authored-by: Martijn Bastiaan <[email protected]>
Fix comment Co-authored-by: ˌbodʲɪˈɡrʲim <[email protected]>
andreasabel
left a comment
There was a problem hiding this comment.
(I just had a brief look at the API and found nothing alienating.)
|
Thanks @Raveline! |
This is an attempt to address the use case reported in #445.
Rationale
There are many scenarios where one would want sequentialTestGroups (as in: don't run these tests in parallel) and still want the ability to filter them, particularly when working on a single test at the bottom of a long sequential group.
Furthermore, as answered by @Bodigrim, the current behaviour is not obvious from documentation (it is implied by the README in "Dependencies", in a list of caveat about patterns. Adding a dedicated utility for sequential groups that can be filtered make the intent more obvious. I would hazard that the crux of the matter is that two very different concerns were mixed:
One could want to have sequential tests in the absence of actual dependencies but simply, for instance, to avoid race conditions. Currently, one has to either use "after" or renounce the ability to filter.
Constraint
Though ideally the filtering behaviour should be controlled by a specific option and not through the Sequential / Parallel nature of the tests, I couldn't find a way to do it without breaking the current API which I think should be avoided at all costs. Hence the addition of a new constructor for
ExecutionMode.I'm not 100% sold on my own proposal, because (a) "filterableSequentialTestGroup" is certainly descriptive but it's a bit too long a name (b) it doesn't clearly separate two very different concerns (c) it leads to some annoying repetition in code (see the changes in
Tast/Run.hs.However, it works, changes are little, intent is clear, and it fixes an issue that was raised several times (see also #411).
Considering this issue is rather blocking for me currently, I'm more than willing to apply any requested changes or explore any other direction to have sequential tests be filterable.