@@ -43,72 +43,65 @@ public void Flush(VstpTestRunComplete testRunComplete)
4343 // Cancel any idle consumers and let them return
4444 _queue . Cancel ( ) ;
4545
46- try
47- {
48- // Any active consumer will circle back around and batch post the remaining queue
49- _consumeTask . Wait ( TimeSpan . FromSeconds ( 60 ) ) ;
46+ // Any active consumer will circle back around and batch post the remaining queue
47+ _consumeTask . Wait ( TimeSpan . FromSeconds ( 60 ) ) ;
5048
51- // Update the run and parents to a completed state
52- SendTestsCompleted ( testRunComplete , _consumeTaskCancellationSource . Token ) . Wait ( TimeSpan . FromSeconds ( 60 ) ) ;
49+ // Update the run and parents to a completed state
50+ SendTestsCompleted ( testRunComplete , _consumeTaskCancellationSource . Token ) . Wait ( TimeSpan . FromSeconds ( 60 ) ) ;
5351
54- // Cancel any active HTTP requests if still hasn't finished flushing
55- _consumeTaskCancellationSource . Cancel ( ) ;
56- if ( ! _consumeTask . Wait ( TimeSpan . FromSeconds ( 10 ) ) )
57- {
58- throw new TimeoutException ( "Cancellation didn't happen quickly" ) ;
59- }
60- }
61- catch ( Exception ex )
52+ // Cancel any active HTTP requests if still hasn't finished flushing
53+ _consumeTaskCancellationSource . Cancel ( ) ;
54+ if ( ! _consumeTask . Wait ( TimeSpan . FromSeconds ( 10 ) ) )
6255 {
63- Console . WriteLine ( ex ) ;
56+ throw new TimeoutException ( "Cancellation didn't happen quickly" ) ;
6457 }
6558 }
6659
6760 private async Task ConsumeItemsAsync ( CancellationToken cancellationToken )
6861 {
6962 while ( true )
7063 {
71- ITestResult [ ] nextItems = await _queue . TakeAsync ( ) . ConfigureAwait ( false ) ;
72-
73- if ( nextItems == null || nextItems . Length == 0 )
64+ try
7465 {
75- // Queue is canceling and is empty
76- return ;
77- }
66+ ITestResult [ ] nextItems = await _queue . TakeAsync ( ) . ConfigureAwait ( false ) ;
67+
68+ if ( nextItems == null || nextItems . Length == 0 )
69+ {
70+ // Queue is canceling and is empty
71+ return ;
72+ }
7873
79- await SendResultsAsync ( nextItems , cancellationToken ) . ConfigureAwait ( false ) ;
74+ await SendResultsAsync ( nextItems , cancellationToken ) . ConfigureAwait ( false ) ;
8075
81- if ( cancellationToken . IsCancellationRequested )
76+ if ( cancellationToken . IsCancellationRequested )
77+ {
78+ return ;
79+ }
80+ }
81+ catch ( Exception ex )
8282 {
83- return ;
83+ Console . WriteLine ( ex ) ;
8484 }
8585 }
8686 }
8787
8888 private async Task SendResultsAsync ( ITestResult [ ] testResults , CancellationToken cancellationToken )
8989 {
90- try
90+ // Create a test run if we need it
91+ if ( RunId == 0 )
9192 {
92- // Create a test run if we need it
93- if ( RunId == 0 )
94- {
95- Source = GetSource ( testResults ) ;
96- RunId = await CreateTestRun ( cancellationToken ) . ConfigureAwait ( false ) ;
97- }
93+ Source = GetSource ( testResults ) ;
94+ RunId = await CreateTestRun ( cancellationToken ) . ConfigureAwait ( false ) ;
95+ }
9896
99- // Group results by their parent
100- IEnumerable < IGrouping < string , ITestResult > > testResultsByParent = GroupTestResultsByParent ( testResults ) ;
97+ // Group results by their parent
98+ IEnumerable < IGrouping < string , ITestResult > > testResultsByParent = GroupTestResultsByParent ( testResults ) ;
10199
102- // Create any required parent nodes
103- await CreateParents ( testResultsByParent , cancellationToken ) . ConfigureAwait ( false ) ;
100+ // Create any required parent nodes
101+ await CreateParents ( testResultsByParent , cancellationToken ) . ConfigureAwait ( false ) ;
104102
105- // Update parents with the test results
106- await SendTestResults ( testResultsByParent , cancellationToken ) . ConfigureAwait ( false ) ;
107- }
108- catch ( Exception )
109- {
110- // Eat any communications exceptions
111- }
103+ // Update parents with the test results
104+ await SendTestResults ( testResultsByParent , cancellationToken ) . ConfigureAwait ( false ) ;
112105 }
113106
114107 // Internal for testing
0 commit comments