-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
278 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
...crosoft.TestPlatform.Client/MultiTestRunsFinalization/MultiTestRunsFinalizationRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.TesthostProtocol; | ||
using System; | ||
using System.Threading; | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.Client.MultiTestRunsFinalization | ||
{ | ||
public class MultiTestRunsFinalizationRequest : IMultiTestRunsFinalizationRequest | ||
{ | ||
public event EventHandler<string> OnRawMessageReceived; | ||
|
||
public void Abort() | ||
{ | ||
if (EqtTrace.IsVerboseEnabled) | ||
{ | ||
EqtTrace.Verbose("MultiTestRunsFinalizationRequest.Abort: Aborting."); | ||
} | ||
|
||
lock (this.syncObject) | ||
{ | ||
if (this.disposed) | ||
{ | ||
throw new ObjectDisposedException("MultiTestRunsFinalizationRequest"); | ||
} | ||
|
||
if (this.finalizationInProgress) | ||
{ | ||
this.finalizationManager.Abort(); | ||
} | ||
else | ||
{ | ||
if (EqtTrace.IsInfoEnabled) | ||
{ | ||
EqtTrace.Info("MultiTestRunsFinalizationRequest.Abort: No operation to abort."); | ||
} | ||
|
||
return; | ||
} | ||
} | ||
|
||
if (EqtTrace.IsInfoEnabled) | ||
{ | ||
EqtTrace.Info("MultiTestRunsFinalizationRequest.Abort: Aborted."); | ||
} | ||
} | ||
|
||
public void FinalizeMultiTestRunsAsync() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
/// <summary> | ||
/// Wait for discovery completion | ||
/// </summary> | ||
/// <param name="timeout"> The timeout. </param> | ||
bool IRequest.WaitForCompletion(int timeout) | ||
{ | ||
if (EqtTrace.IsVerboseEnabled) | ||
{ | ||
EqtTrace.Verbose("MultiTestRunsFinalizationRequest.WaitForCompletion: Waiting with timeout {0}.", timeout); | ||
} | ||
|
||
if (this.disposed) | ||
{ | ||
throw new ObjectDisposedException("MultiTestRunsFinalizationRequest"); | ||
} | ||
|
||
// This method is not synchronized as it can lead to dead-lock | ||
// (the discoveryCompletionEvent cannot be raised unless that lock is released) | ||
if (this.finalizationCompleted != null) | ||
{ | ||
return this.finalizationCompleted.WaitOne(timeout); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
#region IDisposable implementation | ||
|
||
/// <summary> | ||
/// Performs application-defined tasks associated with freeing, releasing, or | ||
/// resetting unmanaged resources. | ||
/// </summary> | ||
public void Dispose() | ||
{ | ||
this.Dispose(true); | ||
|
||
GC.SuppressFinalize(this); | ||
} | ||
|
||
private void Dispose(bool disposing) | ||
{ | ||
if (EqtTrace.IsVerboseEnabled) | ||
{ | ||
EqtTrace.Verbose("MultiTestRunsFinalizationRequest.Dispose: Starting."); | ||
} | ||
|
||
lock (this.syncObject) | ||
{ | ||
if (!this.disposed) | ||
{ | ||
if (disposing) | ||
{ | ||
if (this.finalizationCompleted != null) | ||
{ | ||
this.finalizationCompleted.Dispose(); | ||
} | ||
} | ||
|
||
// Indicate that object has been disposed | ||
this.finalizationCompleted = null; | ||
this.disposed = true; | ||
} | ||
} | ||
|
||
if (EqtTrace.IsInfoEnabled) | ||
{ | ||
EqtTrace.Info("DiscoveryRequest.Dispose: Completed."); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region privates fields | ||
|
||
/// <summary> | ||
/// If this request has been disposed. | ||
/// </summary> | ||
private bool disposed = false; | ||
|
||
/// <summary> | ||
/// It get set when current discovery request is completed. | ||
/// </summary> | ||
private ManualResetEvent finalizationCompleted = new ManualResetEvent(false); | ||
|
||
/// <summary> | ||
/// Sync object for various operations | ||
/// </summary> | ||
private object syncObject = new Object(); | ||
|
||
/// <summary> | ||
/// Whether or not the test discovery is in progress. | ||
/// </summary> | ||
private bool finalizationInProgress; | ||
|
||
/// <summary> | ||
/// Discovery Start Time | ||
/// </summary> | ||
private DateTime finalizationStartTime; | ||
|
||
/// <summary> | ||
/// Finalization manager | ||
/// </summary> | ||
private IMultiTestRunsFinalizationManager finalizationManager; | ||
|
||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Microsoft.TestPlatform.ObjectModel/Client/Interfaces/IMultTestRunsFinalizationRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel.Client | ||
{ | ||
/// <summary> | ||
/// IMultiTestRunsFinalizationRequest | ||
/// </summary> | ||
public interface IMultiTestRunsFinalizationRequest : IRequest | ||
{ | ||
/// <summary> | ||
/// Starts tests discovery async. | ||
/// </summary> | ||
void FinalizeMultiTestRunsAsync(); | ||
|
||
/// <summary> | ||
/// Aborts the discovery request | ||
/// </summary> | ||
void Abort(); | ||
} | ||
} |
Oops, something went wrong.