-
Notifications
You must be signed in to change notification settings - Fork 746
Better user info about ParallelizableAttribute and ParallelScope #2003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@nunit/core-team @nunit/framework-team Comments requested! |
The rest sounds fine although I find |
Well, if we just rename, they will get a compiler error. If we mark as obsolete, they will get a compiler warning with a message that tells them to use
|
Few comments - sorry, I'm aware some of the below wasn't what you intended to be up for discussion, but while we're working behaviour out...
So is it right that, by default, if I make a method
Just my personal opinion from an external library user's point of view, I've never found any confusion with None. I also personally prefer
As a name, I'm not entirely sure what level of parallelization
👍 Sounds good. You said in this section that
Great idea! This stuff is hard to work out what's actually happening - I remember the first time I tried to implement it, having to dig into log files to work out what was actually running in parallel. (I blame ReSharper for this!)
I'd wonder if it's worth leaving this one until we're sure there's a need - purely for the sake of keeping the API a little cleaner. |
@ChrisMaddock To clarify defaults... Currently, if no attribute appears, we default to non-parallel. If the attribute is used without an argument we default to Self. As for NonParallel versus None, no need to change if I'm the only one who finds it confusing. Let's hear some other opinions. In the new code, ParallelScope.Default us used internally when no attribute is specified. |
That make much more sense to me. I've re-read the above and I've misinterpreted, sorry! |
Some further thoughts to put this into perspective. I'd design this differently today. So, ideally, I'd like to separate the parallel/non-parallel distinction from the scope. One way to do that has occured to me: Eliminate |
That update sounds reasonable to me. |
I'm trying a "docs first" approach. Please take a look at these... https://github.com/nunit/docs/wiki/Parallelizable-Attribute-(New) |
Seems good to me. |
I think this is much cleaner - good shout separating the two out! |
Letting this pot simmer for a bit while I work on the NUnit 3 VS Adapter release. |
This comes up as I work on issue #164 and I'll implement it in conjunction with that is.sue. However, I think it needs to have separate review, which is why I'm creating this issue.
ParallelizableAttribute
takes an optional argument of TypeParallelScope
. The values ofParallelScope
are a mix of things. Some apply to the item on which the attribute appears and others to descendants. In addition,ParallelScope.None
is used both when specified by the user and as a default. This turns out to lose info for us, since there are three, rather than two, actions the dispatcher may take in running a test:I'm proposing a number of changes to make parallel test cases work and also to clarify things for users:
I have already defined
ParallelScope.Default
which indicates that no attribute was used. This turned out to be necessary to effectively implement parallel test cases.For convenience internally I have re-defined the various scopes in two ranges, separating those flags that affect the item on which they appear from those that affect descendants. I use two masks to pick out the flags that are needed in a particular instance.
[Remaining items have to do with how this appears to users]
I'd like to deprecate
ParallelScope.None
in favor ofParallelScope.NonParallel
. The former name is confusing enough that it was confusing me in working Run test methods within a fixture in parallel #164. Its implementation has always been "run test on non-parallel queue" but it sounds as if it means "not specified" or "use default". I'm open to other names. I considered "Never" as an option.For consistency, I'd like to define
ParallelScope.Parallel
as a synonym forParallelScope.Self
. I wouldn't deprecate the latter, however, because combos likeParallelScope.Self+ParallelScope.Children
read quite well.To make it even easier for users. It may be useful to define
NonParallelizableAttribute
with no arguments. Just as[Parallelizable]
defaults to[Parallelizable(ParallelScope.Self)
, this new attribute would mean the same as[Parallelizable(ParallelScope.NonParallel)
Some values of
ParallelScope
make no sense in certain places and are currently ignored silently. For example,Parallelizable(ParallelScope.Fixtures)
has no effect if placed on a test case. Rather than silently ignoring the attribute, I propose that we mark the test as invalid so that the user knows it won't do whatever is expected and removes it. Implementation will require looking at each scope value and deciding whether to allow it on an Assembly, a class or a method. It seems to me that getting an early error is better for the user than having their intent (which we don't know of course) ignored silently.I propose adding
ParallelScope.Cases
to the set of scopes that impact descendants. Used at the assembly level without combining with other scopes, it would cause test fixtures to run sequentially but all the cases within them to run in parallel. I don't think this will get a lot of use but it's consistent with the presense ofParallelScope.Fixtures
. I would redefineChildren
asFixtures+Cases
if we do this.Please comment! For implementation details, you'll be able to review the PR of course.
The text was updated successfully, but these errors were encountered: