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

Attempt to fix tests failure for MEF #9454

Merged
merged 1 commit into from Aug 9, 2021

Conversation

gerhardol
Copy link
Member

Proposed changes

A few test changes to fix flaky tests

Integration tests fail after a clean, for instance ToggleBetweenArtificialAndHeadCommits_no_index_change.

In AppVeyor the tests time out.
Locally you get a popup

GitExtUtils.ExternalOperationException: fatal: not a git repository (or any of the parent directories): .git
 ---> System.Exception: fatal: not a git repository (or any of the parent directories): .git
   --- End of inner exception stack trace ---
   at void Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
   at T Microsoft.VisualStudio.Threading.JoinableTask<T>.CompleteOnCurrentThread()
   at T Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run<T>(Func<Task<T>> asyncMethod, JoinableTaskCreationOptions creationOptions) x 2
   at int GitCommands.Executable+ProcessWrapper.WaitForExit() in C:/dev/gc/gitextensions_4/GitCommands/Git/Executable.cs:line 238
   at IEnumerable<string> GitCommands.ExecutableExtensions.GetOutputLines(IExecutable executable, ArgumentString arguments, byte[] input, Encoding outputEncoding, bool stripAnsiEscapeCodes, bool throwOnErrorOutput, bool includeErrorOutput)+MoveNext() in C:/dev/gc/gitextensions_4/GitCommands/Git/ExecutableExtensions.cs:line 288
   at List<TSource> System.Linq.Enumerable+WhereEnumerableIterator<TSource>.ToList()
   at List<TSource> System.Linq.Enumerable.ToList<TSource>(IEnumerable<TSource> source)
   at IReadOnlyList<string> GitCommands.GitModule.GetRemoteNames() in C:/dev/gc/gitextensions_4/GitCommands/Git/GitModule.cs:line 2137
   at IReadOnlyList<string> GitCommands.Remotes.ConfigFileRemoteSettingsManager.GetEnabledRemoteNames() in C:/dev/gc/gitextensions_4/GitCommands/Remotes/ConfigFileRemoteSettingsManager.cs:line 198
   at IReadOnlyList<string> GitCommands.Remotes.ConfigFileRemoteSettingsManager.GetEnabledRemoteNamesWithoutBranches() in C:/dev/gc/gitextensions_4/GitCommands/Remotes/ConfigFileRemoteSettingsManager.cs:line 210
   at async Task<Nodes> GitUI.BranchTreePanel.RepoObjectsTree+RemoteBranchTree.FillBranchTreeAsync(IReadOnlyList<IGitRef> branches, CancellationToken token) in C:/dev/gc/gitextensions_4/GitUI/BranchTreePanel/RepoObjectsTree.RemoteBranchTree.cs:line 105
   at async Task<Nodes> GitUI.BranchTreePanel.RepoObjectsTree+RemoteBranchTree.LoadNodesAsync(CancellationToken token) in C:/dev/gc/gitextensions_4/GitUI/BranchTreePanel/RepoObjectsTree.RemoteBranchTree.cs:line 58
   at async Task GitUI.BranchTreePanel.RepoObjectsTree+Tree.ReloadNodesAsync(Func<CancellationToken, Task<Nodes>> loadNodesTask) in C:/dev/gc/gitextensions_4/GitUI/BranchTreePanel/RepoObjectsTree.Nodes.cs:line 287
   at async void GitUI.BranchTreePanel.RepoObjectsTree.AddTree(Tree tree)+(?) => { } [1] in C:/dev/gc/gitextensions_4/GitUI/BranchTreePanel/RepoObjectsTree.cs:line 399
   at async void GitUI.ThreadHelper.FileAndForget(Task task, Func<Exception, bool> fileOnlyIf)+(?) => { } in C:/dev/gc/gitextensions_4/GitExtUtils/GitUI/ThreadHelper.cs:line 100

If you debug, you see the exception in ManagedExtenisibility.cs CreateExportProvider as _aggregateCatalog is null.

This occurs after MEF in Program.cs RunApplication() ab9ba80
MEF are not init in tests.

Not sure if this is the best solution.

Test methodology

Manual


✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned gerhardol Aug 7, 2021
@gerhardol
Copy link
Member Author

https://ci.appveyor.com/project/gitextensions/gitextensions/builds/40289794#L62

Cannot see why it fails, works locally...

@RussKie RussKie self-requested a review August 7, 2021 12:08
@RussKie
Copy link
Member

RussKie commented Aug 7, 2021

The master branch is building successfully... In which branch are you seeing the issues?

@gerhardol
Copy link
Member Author

The master branch is building successfully... In which branch are you seeing the issues?

All.
I cannot run the tests after a clean.

@RussKie
Copy link
Member

RussKie commented Aug 7, 2021

I can run all unit tests locally after git clean -xdf. I have five integration tests failures, though none appears to be related to MEF (at least on the surface):

  Failed ToggleBetweenArtificialAndHeadCommits_no_change(False) [452 ms]                                                                                                                                                                                               
  Error Message:                                                                                                                                                                                                                                                       
   GitExtUtils.ExternalOperationException : fatal: unknown write failure on standard output                                                                                                                                                                            
  ----> System.Exception : fatal: unknown write failure on standard output                                                                                                                                                                                             
  Stack Trace:                                                                                                                                                                                                                                                         
     at GitCommands.ExecutableExtensions.RunCommandAsync(IExecutable executable, ArgumentString arguments, Byte[] input, Boolean createWindow) in D:\Development\gitextensions2\GitCommands\Git\ExecutableExtensions.cs:line 231                                       
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()                                                                                                                                                                                          
   at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()                                                                                                                                                                                        
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)                                                                                                                                     
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod)                                                                                                                                                                                  
   at GitCommands.ExecutableExtensions.RunCommand(IExecutable executable, ArgumentString arguments, Byte[] input, Boolean createWindow) in D:\Development\gitextensions2\GitCommands\Git\ExecutableExtensions.cs:line 170                                              
   at GitCommands.GitModule.Reset(ResetMode mode, String file) in D:\Development\gitextensions2\GitCommands\Git\GitModule.cs:line 1284                                                                                                                                 
   at GitExtensions.UITests.UserControls.RevisionGrid.RevisionGridControlTests.ToggleBetweenArtificialAndHeadCommits_no_change(Boolean showGitStatusForArtificialCommits) in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\UserControls\RevisionGr
id\RevisionGridControlTests.cs:line 273                                                                                                                                                                                                                                
--Exception                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                       
  Failed ToggleBetweenArtificialAndHeadCommits_no_change(True) [391 ms]                                                                                                                                                                                                
  Error Message:                                                                                                                                                                                                                                                       
   GitExtUtils.ExternalOperationException : fatal: unknown write failure on standard output                                                                                                                                                                            
  ----> System.Exception : fatal: unknown write failure on standard output                                                                                                                                                                                             
  Stack Trace:                                                                                                                                                                                                                                                         
     at GitCommands.ExecutableExtensions.RunCommandAsync(IExecutable executable, ArgumentString arguments, Byte[] input, Boolean createWindow) in D:\Development\gitextensions2\GitCommands\Git\ExecutableExtensions.cs:line 231                                       
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()                                                                                                                                                                                          
   at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()                                                                                                                                                                                        
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)                                                                                                                                     
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod)                                                                                                                                                                                  
   at GitCommands.ExecutableExtensions.RunCommand(IExecutable executable, ArgumentString arguments, Byte[] input, Boolean createWindow) in D:\Development\gitextensions2\GitCommands\Git\ExecutableExtensions.cs:line 170                                              
   at GitCommands.GitModule.Reset(ResetMode mode, String file) in D:\Development\gitextensions2\GitCommands\Git\GitModule.cs:line 1284                                                                                                                                 
   at GitExtensions.UITests.UserControls.RevisionGrid.RevisionGridControlTests.ToggleBetweenArtificialAndHeadCommits_no_change(Boolean showGitStatusForArtificialCommits) in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\UserControls\RevisionGr
id\RevisionGridControlTests.cs:line 273                                                                                                                                                                                                                                
--Exception                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                       
  Failed ToggleBetweenArtificialAndHeadCommits_no_index_change(False) [392 ms]                                                                                                                                                                                         
  Error Message:                                                                                                                                                                                                                                                       
   GitExtUtils.ExternalOperationException : fatal: unknown write failure on standard output                                                                                                                                                                            
  ----> System.Exception : fatal: unknown write failure on standard output                                                                                                                                                                                             
  Stack Trace:                                                                                                                                                                                                                                                         
     at GitCommands.ExecutableExtensions.RunCommandAsync(IExecutable executable, ArgumentString arguments, Byte[] input, Boolean createWindow) in D:\Development\gitextensions2\GitCommands\Git\ExecutableExtensions.cs:line 231                                       
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()                                                                                                                                                                                          
   at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()                                                                                                                                                                                        
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)                                                                                                                                     
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod)                                                                                                                                                                                  
   at GitCommands.ExecutableExtensions.RunCommand(IExecutable executable, ArgumentString arguments, Byte[] input, Boolean createWindow) in D:\Development\gitextensions2\GitCommands\Git\ExecutableExtensions.cs:line 170                                              
   at GitCommands.GitModule.Reset(ResetMode mode, String file) in D:\Development\gitextensions2\GitCommands\Git\GitModule.cs:line 1284                                                                                                                                 
   at GitExtensions.UITests.UserControls.RevisionGrid.RevisionGridControlTests.ToggleBetweenArtificialAndHeadCommits_no_index_change(Boolean showGitStatusForArtificialCommits) in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\UserControls\Revi
sionGrid\RevisionGridControlTests.cs:line 237                                                                                                                                                                                                                          
--Exception                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                       
  Failed ToggleBetweenArtificialAndHeadCommits_no_index_change(True) [386 ms]                                                                                                                                                                                          
  Error Message:                                                                                                                                                                                                                                                       
   GitExtUtils.ExternalOperationException : fatal: unknown write failure on standard output                                                                                                                                                                            
  ----> System.Exception : fatal: unknown write failure on standard output                                                                                                                                                                                             
  Stack Trace:                                                                                                                                                                                                                                                         
     at GitCommands.ExecutableExtensions.RunCommandAsync(IExecutable executable, ArgumentString arguments, Byte[] input, Boolean createWindow) in D:\Development\gitextensions2\GitCommands\Git\ExecutableExtensions.cs:line 231                                       
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()                                                                                                                                                                                          
   at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()                                                                                                                                                                                        
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)                                                                                                                                     
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod)                                                                                                                                                                                  
   at GitCommands.ExecutableExtensions.RunCommand(IExecutable executable, ArgumentString arguments, Byte[] input, Boolean createWindow) in D:\Development\gitextensions2\GitCommands\Git\ExecutableExtensions.cs:line 170                                              
   at GitCommands.GitModule.Reset(ResetMode mode, String file) in D:\Development\gitextensions2\GitCommands\Git\GitModule.cs:line 1284                                                                                                                                 
   at GitExtensions.UITests.UserControls.RevisionGrid.RevisionGridControlTests.ToggleBetweenArtificialAndHeadCommits_no_index_change(Boolean showGitStatusForArtificialCommits) in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\UserControls\Revi
sionGrid\RevisionGridControlTests.cs:line 237                                                                                                                                                                                                                          
--Exception                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                       
  Failed RunCommandBasedOnArgument_branch [449 ms]                                                                                                                                                                                                                     
  Error Message:                                                                                                                                                                                                                                                       
   GitExtUtils.ExternalOperationException : fatal: unknown write failure on standard output                                                                                                                                                                            
  ----> System.Exception : fatal: unknown write failure on standard output                                                                                                                                                                                             
  Stack Trace:                                                                                                                                                                                                                                                         
     at GitCommands.ExecutableExtensions.RunCommandAsync(IExecutable executable, ArgumentString arguments, Byte[] input, Boolean createWindow) in D:\Development\gitextensions2\GitCommands\Git\ExecutableExtensions.cs:line 231                                       
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()                                                                                                                                                                                          
   at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()                                                                                                                                                                                        
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod, JoinableTaskCreationOptions creationOptions)                                                                                                                                     
   at Microsoft.VisualStudio.Threading.JoinableTaskFactory.Run[T](Func`1 asyncMethod)                                                                                                                                                                                  
   at GitCommands.ExecutableExtensions.RunCommand(IExecutable executable, ArgumentString arguments, Byte[] input, Boolean createWindow) in D:\Development\gitextensions2\GitCommands\Git\ExecutableExtensions.cs:line 170                                              
   at GitCommands.GitModule.CheckBranchFormat(String branchName) in D:\Development\gitextensions2\GitCommands\Git\GitModule.cs:line 3768                                                                                                                               
   at GitUI.CommandsDialogs.FormCreateBranch.OkClick(Object sender, EventArgs e) in D:\Development\gitextensions2\GitUI\CommandsDialogs\FormCreateBranch.cs:line 126                                                                                                   
   at System.Windows.Forms.Control.OnClick(EventArgs e)                                                                                                                                                                                                                
   at System.Windows.Forms.Button.OnClick(EventArgs e)                                                                                                                                                                                                                 
   at System.Windows.Forms.Button.PerformClick()                                                                                                                                                                                                                       
   at GitUITests.GitUICommandsTests.RunCommandTests.ClickButton(Form form, String buttonName) in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\GitUICommands\RunCommandTests.cs:line 362                                                          
   at GitUITests.GitUICommandsTests.RunCommandTests.<>c.<RunCommandBasedOnArgument_branch>b__13_0(FormCreateBranch form) in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\GitUICommands\RunCommandTests.cs:line 119                               
   at GitUITests.GitUICommandsTests.RunCommandTests.<>c__DisplayClass47_0`1.<RunCommandBasedOnArgument>b__1(TForm form) in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\GitUICommands\RunCommandTests.cs:line 355                                
   at GitExtensions.UITests.UITest.<>c__DisplayClass1_0`1.<<RunForm>b__0>d.MoveNext() in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\UITest.cs:line 54                                                                                          
--- End of stack trace from previous location ---                                                                                                                                                                                                                      
   at GitExtensions.UITests.UITest.<>c__DisplayClass1_0`1.<<RunForm>b__0>d.MoveNext() in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\UITest.cs:line 65                                                                                          
--- End of stack trace from previous location ---                                                                                                                                                                                                                      
   at Microsoft.VisualStudio.Threading.JoinableTask.Join(CancellationToken cancellationToken)                                                                                                                                                                          
   at GitExtensions.UITests.UITest.RunForm[T](Action showForm, Func`2 runTestAsync) in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\UITest.cs:line 71                                                                                            
   at GitUITests.GitUICommandsTests.RunCommandTests.RunCommandBasedOnArgument[TForm](String[] args, Boolean expectedResult, Action`1 runTest) in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\GitUICommands\RunCommandTests.cs:line 351          
   at GitUITests.GitUICommandsTests.RunCommandTests.RunCommandBasedOnArgument_branch() in D:\Development\gitextensions2\IntegrationTests\UI.IntegrationTests\GitUICommands\RunCommandTests.cs:line 116                                                                 
--Exception                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                       
  Skipped RunCommandBasedOnArgument_settings [< 1 ms]                                                                                                                                                                                                                  
Results File: D:\Development\gitextensions2\artifacts\Debug\TestsResults\RussKie_DESKTOP-1UHRCUU_2021-08-07_22_46_33[1].trx                                                                                                                                            
                                                                                                                                                                                                                                                                       
Failed!  - Failed:     5, Passed:   226, Skipped:     1, Total:   232, Duration: 2 m 13 s - UI.IntegrationTests.dll (net5.0)                                                                                                                                           
                                                                                                                                                                                                                                                                       

@RussKie
Copy link
Member

RussKie commented Aug 7, 2021

Are you running integration tests from VS?

Copy link
Member

@RussKie RussKie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally. 👍

@gerhardol
Copy link
Member Author

I can run all unit tests locally after git clean -xdf

Clean in VS is the same
Test run in VS

@gerhardol
Copy link
Member Author

Reverted the first change as it raises CS0234 (how did I get that working) and applied the change to tests where it mattered
Also an old SA1689 that is old but not appear before

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must remember this workaround when the next test is affected.

@gerhardol
Copy link
Member Author

Added a few more tests that cannot run in isolation after a clean

UI integration tests deadlock under VS

Co-authored-by: RussKie <russkie@gmail.com>
@gerhardol
Copy link
Member Author

I squashed RussKies fixup that added a property to the test instead
Also including a #9456 fix. Not sure if that should be included yet, so I will not squash merge myself. (Described in the commit message.)

@RussKie RussKie merged commit 6d8597c into gitextensions:master Aug 9, 2021
@ghost ghost added this to the 3.6 milestone Aug 9, 2021
@gerhardol gerhardol deleted the feature/test-fixes branch November 14, 2021 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants