Terminal.Gui: Unit tests fail locally first time run, but succeed subsequent times

Describe the bug I’ve noticed this a few times in past few weeks. It happened again today after pulling the latest main down locally.

To Reproduce Steps to reproduce the behavior:

In Terminal.Gui/ root on local machine:

  1. git pull upstream main
  2. dotnet test
  3. dotnet test

As shown below the first dotnet test fails. The 2nd passes.

Oddly, this does not reproduce if I do a dotnet clean and then dotnet test.

┌[charl@TIGGER] [ main ≣]
└[~\s\gui.cs]> git pull upstream main
remote: Enumerating objects: 15, done.
remote: Counting objects: 100% (15/15), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 8 (delta 7), reused 4 (delta 4), pack-reused 0
Unpacking objects: 100% (8/8), 1.70 KiB | 36.00 KiB/s, done.
From tig:migueldeicaza/gui.cs
 * branch              main       -> FETCH_HEAD
   56c28f6d..a9a0d176  main       -> upstream/main
Updating 56c28f6d..a9a0d176
Fast-forward
 Terminal.Gui/Core/View.cs       |  15 +++---
 UnitTests/ConsoleDriverTests.cs |   8 ++--
 UnitTests/ViewTests.cs          | 101 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 110 insertions(+), 14 deletions(-)
┌[charl@TIGGER] [ main ↑1]
└[~\s\gui.cs]> git push
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To tig:tig/gui.cs
   56c28f6d..a9a0d176  main -> main
┌[charl@TIGGER] [ main ≣]
└[~\s\gui.cs]> dotnet test
  Determining projects to restore...
  Restored C:\Users\charlie\s\gui.cs\Example\Example.csproj (in 481 ms).
  Restored C:\Users\charlie\s\gui.cs\UICatalog\UICatalog.csproj (in 481 ms).
  Restored C:\Users\charlie\s\gui.cs\ReactiveExample\ReactiveExample.csproj (in 481 ms).
  Restored C:\Users\charlie\s\gui.cs\Terminal.Gui\Terminal.Gui.csproj (in 481 ms).
  Restored C:\Users\charlie\s\gui.cs\UnitTests\UnitTests.csproj (in 704 ms).
  Terminal.Gui -> C:\Users\charlie\s\gui.cs\Terminal.Gui\bin\Debug\net472\Terminal.Gui.dll
  Terminal.Gui -> C:\Users\charlie\s\gui.cs\Terminal.Gui\bin\Debug\netstandard2.0\Terminal.Gui.dll
  Terminal.Gui -> C:\Users\charlie\s\gui.cs\Terminal.Gui\bin\Debug\net6.0\Terminal.Gui.dll
  UICatalog -> C:\Users\charlie\s\gui.cs\UICatalog\bin\Debug\net6.0\UICatalog.dll
  UnitTests -> C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net6.0\UnitTests.dll
Test run for C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net6.0\UnitTests.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.1.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:14.45]     Terminal.Gui.Core.MainLoopTests.AddTimer_Duplicate_Keys_Not_Allowed [FAIL]
  Failed Terminal.Gui.Core.MainLoopTests.AddTimer_Duplicate_Keys_Not_Allowed [1 ms]
  Error Message:
   System.NullReferenceException : Object reference not set to an instance of an object.
  Stack Trace:
     at Terminal.Gui.MainLoop.RunTimers() in C:\Users\charlie\s\gui.cs\Terminal.Gui\Core\MainLoop.cs:line 180
   at Terminal.Gui.MainLoop.MainIteration() in C:\Users\charlie\s\gui.cs\Terminal.Gui\Core\MainLoop.cs:line 241
   at Terminal.Gui.MainLoop.Run() in C:\Users\charlie\s\gui.cs\Terminal.Gui\Core\MainLoop.cs:line 260
   at Terminal.Gui.Core.MainLoopTests.AddTimer_Duplicate_Keys_Not_Allowed() in C:\Users\charlie\s\gui.cs\UnitTests\MainLoopTests.cs:line 292
--- End of stack trace from previous location ---

Failed!  - Failed:     1, Passed:   636, Skipped:     0, Total:   637, Duration: 9 s - UnitTests.dll (net6.0)
┌[charl@TIGGER] [ main ≣]
└[~\s\gui.cs]> dotnet test
  Determining projects to restore...
  All projects are up-to-date for restore.
  Terminal.Gui -> C:\Users\charlie\s\gui.cs\Terminal.Gui\bin\Debug\net472\Terminal.Gui.dll
  Terminal.Gui -> C:\Users\charlie\s\gui.cs\Terminal.Gui\bin\Debug\netstandard2.0\Terminal.Gui.dll
  Terminal.Gui -> C:\Users\charlie\s\gui.cs\Terminal.Gui\bin\Debug\net6.0\Terminal.Gui.dll
  UICatalog -> C:\Users\charlie\s\gui.cs\UICatalog\bin\Debug\net6.0\UICatalog.dll
  UnitTests -> C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net6.0\UnitTests.dll
Test run for C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net6.0\UnitTests.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.1.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:   637, Skipped:     0, Total:   637, Duration: 8 s - UnitTests.dll (net6.0)
┌[charl@TIGGER] [ main ≣]
└[~\s\gui.cs]>

Note this is the same set of tests that were intermittently failing for @bdisp’s PR #1606. But in that case it was w/in the GitHub environment.

Desktop (please complete the following information):

  • OS: Win11
  • dotnet: 6.0.200
  • VS 2022 Version 17.2.0 Preview 1.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 26

Most upvoted comments

It’s in the github action.

But normally pr’s from dependabot always fails on test.

Some do. Some don’t. I can’t stand not knowing why! 😃