Skip to content
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

Test failure: When_there_are_subcommands_and_options_then_a_subcommand_must_be_provided #54

Closed
natemcmaster opened this issue May 16, 2018 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@natemcmaster
Copy link
Contributor

Test Name:	System.CommandLine.Tests.ParsingValidationTests.When_there_are_subcommands_and_options_then_a_subcommand_must_be_provided
Test FullName:	System.CommandLine.Tests.ParsingValidationTests.When_there_are_subcommands_and_options_then_a_subcommand_must_be_provided
Test Source:	C:\dev\dotnet\System.CommandLine\src\System.CommandLine.Tests\ParsingValidationTests.cs : line 182
Test Outcome:	Failed
Test Duration:	0:00:00.095

Result StackTrace:	
at FluentAssertions.Execution.XUnit2TestFramework.Throw(String message) in C:\projects\fluentassertions-vf06b\Src\FluentAssertions.Net45\Execution\XUnit2TestFramework.cs:line 32
   at FluentAssertions.Execution.AssertionScope.FailWith(String message, Object[] args) in C:\projects\fluentassertions-vf06b\Src\Core\Execution\AssertionScope.cs:line 197
   at FluentAssertions.Collections.SelfReferencingCollectionAssertions`2.ContainSingle(Expression`1 predicate, String because, Object[] becauseArgs) in C:\projects\fluentassertions-vf06b\Src\Core\Collections\SelfReferencingCollectionAssertions.cs:line 492
   at System.CommandLine.Tests.ParsingValidationTests.When_there_are_subcommands_and_options_then_a_subcommand_must_be_provided()
Result Message:	Expected collection to contain a single item matching ((e.Message == "Required command was not provided.") AndAlso (e.ParsedSymbol.Name == "inner")), but no such item was found.
Result StandardOutput:	
[ outer [ inner <arg> ] ]
the-message

This reproduces consistently in Debug, but not release. There appears to be some kind of race condition in the tests. The output "the-message" comes from another test, Default_validation_messages_can_be_replaced_in_order_to_add_localization_support.

cc @jonsequitur

@jonsequitur
Copy link
Contributor

Oddly, it sometimes passes: https://ci2.dot.net/job/Private/job/dotnet_System.CommandLine/job/master/job/Debug_Windows_NT_prtest/22/.

Something similar-looking was happening as well in the original repo and the mystery wasn't solved, though I had a proposal that we could try. dotnet/CliCommandLineParser#93

@jonsequitur
Copy link
Contributor

Saw that. Trying an update to FluentAssertions.

@natemcmaster
Copy link
Contributor Author

So, Jon and I found out on the way to Spokane that this is the race condition in test parallelization and ValidationMessages.Current. I think we should consider not having a static, settable property to configure validation message customization.

@jonsequitur
Copy link
Contributor

I had thought I fixed this by referencing ValidationMessages.Current to work around the race condition but it apparently still exists:

https://ci2.dot.net/job/Private/job/dotnet_System.CommandLine/job/master/job/Release_Windows_NT_prtest/56/

So no shortcut here.. We should definitely change the localization story to not use a static.

@natemcmaster
Copy link
Contributor Author

I drafted a change, but the localization is tough because much of the validation is currently done in static help methods. Will have to think about it more

@natemcmaster
Copy link
Contributor Author

Should be resolved with #85

@natemcmaster natemcmaster added bug Something isn't working cost: S labels May 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants