@@ -45,6 +45,8 @@ internal event EventHandler OnProgressStopUpdate
45
45
46
46
private readonly TestProgressStateAwareTerminal _terminalWithProgress ;
47
47
48
+ private int _handshakeFailuresCount ;
49
+
48
50
private readonly uint ? _originalConsoleMode ;
49
51
private bool _isDiscovery ;
50
52
private bool _isHelp ;
@@ -59,6 +61,8 @@ internal event EventHandler OnProgressStopUpdate
59
61
60
62
private bool ? _shouldShowPassedTests ;
61
63
64
+ public bool HasHandshakeFailure => _handshakeFailuresCount > 0 ;
65
+
62
66
#if NET7_0_OR_GREATER
63
67
// Specifying no timeout, the regex is linear. And the timeout does not measure the regex only, but measures also any
64
68
// thread suspends, so the regex gets blamed incorrectly.
@@ -168,7 +172,7 @@ public void TestExecutionStarted(DateTimeOffset testStartTime, int workerCount,
168
172
_terminalWithProgress . StartShowingProgress ( workerCount ) ;
169
173
}
170
174
171
- public void AssemblyRunStarted ( string assembly , string ? targetFramework , string ? architecture , string ? executionId )
175
+ public void AssemblyRunStarted ( string assembly , string ? targetFramework , string ? architecture , string executionId )
172
176
{
173
177
var assemblyRun = GetOrAddAssemblyRun ( assembly , targetFramework , architecture , executionId ) ;
174
178
assemblyRun . TryCount ++ ;
@@ -197,10 +201,9 @@ public void AssemblyRunStarted(string assembly, string? targetFramework, string?
197
201
}
198
202
}
199
203
200
- private TestProgressState GetOrAddAssemblyRun ( string assembly , string ? targetFramework , string ? architecture , string ? executionId )
204
+ private TestProgressState GetOrAddAssemblyRun ( string assembly , string ? targetFramework , string ? architecture , string executionId )
201
205
{
202
- string key = $ "{ assembly } |{ targetFramework } |{ architecture } |{ executionId } ";
203
- return _assemblies . GetOrAdd ( key , _ =>
206
+ return _assemblies . GetOrAdd ( executionId , _ =>
204
207
{
205
208
IStopwatch sw = CreateStopwatch ( ) ;
206
209
var assemblyRun = new TestProgressState ( Interlocked . Increment ( ref _counter ) , assembly , targetFramework , architecture , sw ) ;
@@ -280,7 +283,7 @@ private void AppendTestRunSummary(ITerminal terminal, int? exitCode)
280
283
bool notEnoughTests = totalTests < _options . MinimumExpectedTests ;
281
284
bool allTestsWereSkipped = totalTests == 0 || totalTests == totalSkippedTests ;
282
285
bool anyTestFailed = totalFailedTests > 0 ;
283
- bool anyAssemblyFailed = _assemblies . Values . Any ( a => ! a . Success ) ;
286
+ bool anyAssemblyFailed = _assemblies . Values . Any ( a => ! a . Success ) || HasHandshakeFailure ;
284
287
bool runFailed = anyAssemblyFailed || anyTestFailed || notEnoughTests || allTestsWereSkipped || _wasCancelled ;
285
288
terminal . SetColor ( runFailed ? TerminalColor . DarkRed : TerminalColor . DarkGreen ) ;
286
289
@@ -335,7 +338,7 @@ private void AppendTestRunSummary(ITerminal terminal, int? exitCode)
335
338
int passed = _assemblies . Values . Sum ( t => t . PassedTests ) ;
336
339
int skipped = _assemblies . Values . Sum ( t => t . SkippedTests ) ;
337
340
int retried = _assemblies . Values . Sum ( t => t . RetriedFailedTests ) ;
338
- int error = _assemblies . Values . Sum ( t => ! t . Success && ( t . TotalTests == 0 || t . FailedTests == 0 ) ? 1 : 0 ) ;
341
+ int error = _assemblies . Values . Sum ( t => ! t . Success && ( t . TotalTests == 0 || t . FailedTests == 0 ) ? 1 : 0 ) + _handshakeFailuresCount ;
339
342
TimeSpan runDuration = _testExecutionStartTime != null && _testExecutionEndTime != null ? ( _testExecutionEndTime - _testExecutionStartTime ) . Value : TimeSpan . Zero ;
340
343
341
344
bool colorizeFailed = failed > 0 ;
@@ -454,7 +457,7 @@ internal void TestCompleted(
454
457
string assembly ,
455
458
string ? targetFramework ,
456
459
string ? architecture ,
457
- string ? executionId ,
460
+ string executionId ,
458
461
string instanceId ,
459
462
string testNodeUid ,
460
463
string displayName ,
@@ -467,7 +470,7 @@ internal void TestCompleted(
467
470
string ? standardOutput ,
468
471
string ? errorOutput )
469
472
{
470
- TestProgressState asm = _assemblies [ $ " { assembly } | { targetFramework } | { architecture } | { executionId } " ] ;
473
+ TestProgressState asm = _assemblies [ executionId ] ;
471
474
var attempt = asm . TryCount ;
472
475
473
476
if ( _options . ShowActiveTests )
@@ -797,12 +800,12 @@ private static void AppendIndentedLine(ITerminal terminal, string? message, stri
797
800
}
798
801
}
799
802
800
- internal void AssemblyRunCompleted ( string assembly , string ? targetFramework , string ? architecture , string ? executionId ,
803
+ internal void AssemblyRunCompleted ( string executionId ,
801
804
// These parameters are useful only for "remote" runs in dotnet test, where we are reporting on multiple processes.
802
805
// In single process run, like with testing platform .exe we report these via messages, and run exit.
803
- int ? exitCode , string ? outputData , string ? errorData )
806
+ int exitCode , string ? outputData , string ? errorData )
804
807
{
805
- TestProgressState assemblyRun = GetOrAddAssemblyRun ( assembly , targetFramework , architecture , executionId ) ;
808
+ TestProgressState assemblyRun = _assemblies [ executionId ] ;
806
809
assemblyRun . ExitCode = exitCode ;
807
810
assemblyRun . Success = exitCode == 0 && assemblyRun . FailedTests == 0 ;
808
811
assemblyRun . Stopwatch . Stop ( ) ;
@@ -814,7 +817,7 @@ internal void AssemblyRunCompleted(string assembly, string? targetFramework, str
814
817
_terminalWithProgress . WriteToTerminal ( terminal => AppendAssemblySummary ( assemblyRun , terminal ) ) ;
815
818
}
816
819
817
- if ( exitCode is null or 0 )
820
+ if ( exitCode == 0 )
818
821
{
819
822
// Report nothing, we don't want to report on success, because then we will also report on test-discovery etc.
820
823
return ;
@@ -826,6 +829,22 @@ internal void AssemblyRunCompleted(string assembly, string? targetFramework, str
826
829
} ) ;
827
830
}
828
831
832
+ internal void HandshakeFailure ( string assemblyPath , string targetFramework , int exitCode , string outputData , string errorData )
833
+ {
834
+ Interlocked . Increment ( ref _handshakeFailuresCount ) ;
835
+ _terminalWithProgress . WriteToTerminal ( terminal =>
836
+ {
837
+ terminal . ResetColor ( ) ;
838
+ AppendAssemblyLinkTargetFrameworkAndArchitecture ( terminal , assemblyPath , targetFramework , architecture : null ) ;
839
+ terminal . Append ( ' ' ) ;
840
+ terminal . SetColor ( TerminalColor . DarkRed ) ;
841
+ terminal . Append ( CliCommandStrings . ZeroTestsRan ) ;
842
+ terminal . ResetColor ( ) ;
843
+ terminal . AppendLine ( ) ;
844
+ AppendExecutableSummary ( terminal , exitCode , outputData , errorData ) ;
845
+ } ) ;
846
+ }
847
+
829
848
private static void AppendExecutableSummary ( ITerminal terminal , int ? exitCode , string ? outputData , string ? errorData )
830
849
{
831
850
terminal . Append ( CliCommandStrings . ExitCode ) ;
@@ -936,11 +955,11 @@ internal void TestDiscovered(
936
955
string assembly ,
937
956
string ? targetFramework ,
938
957
string ? architecture ,
939
- string ? executionId ,
958
+ string executionId ,
940
959
string ? displayName ,
941
960
string ? uid )
942
961
{
943
- TestProgressState asm = _assemblies [ $ " { assembly } | { targetFramework } | { architecture } | { executionId } " ] ;
962
+ TestProgressState asm = _assemblies [ executionId ] ;
944
963
945
964
// TODO: add mode for discovered tests to the progress bar - jajares
946
965
asm . DiscoverTest ( displayName , uid ) ;
@@ -1028,9 +1047,9 @@ public void TestInProgress(
1028
1047
string testNodeUid ,
1029
1048
string instanceId ,
1030
1049
string displayName ,
1031
- string ? executionId )
1050
+ string executionId )
1032
1051
{
1033
- TestProgressState asm = _assemblies [ $ " { assembly } | { targetFramework } | { architecture } | { executionId } " ] ;
1052
+ TestProgressState asm = _assemblies [ executionId ] ;
1034
1053
1035
1054
if ( _options . ShowActiveTests )
1036
1055
{
0 commit comments