-
Notifications
You must be signed in to change notification settings - Fork 329
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
Test runtime provider Interface changes #593
Test runtime provider Interface changes #593
Conversation
to analyze settings themselves
@mayankbansal018, |
@@ -220,9 +221,10 @@ public IEnumerable<string> GetTestPlatformExtensions(IEnumerable<string> sources | |||
return Enumerable.Empty<string>(); | |||
} | |||
|
|||
public bool CanExecuteCurrentRunConfiguration(RunConfiguration runConfiguration) | |||
public bool CanExecuteCurrentRunConfiguration(string runConfiguration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Add XML comments for public methods.
Should we rename the arg to settingsXml just to make it intuitive ?
Prefer using var instead.
@@ -73,7 +73,7 @@ public ITestRuntimeProvider GetTestHostManagerByUri(string hostUri) | |||
return null; | |||
} | |||
|
|||
public ITestRuntimeProvider GetTestHostManagerByRunConfiguration(RunConfiguration runConfiguration) | |||
public ITestRuntimeProvider GetTestHostManagerByRunConfiguration(string runConfiguration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rationale behind this change ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want the implementer of ITestRuntimeProvider to have the full settings so they can decide on what ever parameters they want to, on whether or not can they Host test for this session.
This also allows them to add custom sections in runsettings, & process them here, rather than having the TP understand and process them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename parameter as runsettings
.
/// <summary> | ||
/// Callback on process exit | ||
/// </summary> | ||
public Action<Process, string> ErrorReceivedCallback { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -155,7 +155,7 @@ public void SetupChannelShouldAddExitCallbackToTestHostStartInfo() | |||
|
|||
this.testOperationManager.SetupChannel(Enumerable.Empty<string>()); | |||
|
|||
Assert.IsNotNull(startInfo.ErrorReceivedCallback); | |||
//Assert.IsNotNull(startInfo.ErrorReceivedCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this?
@@ -64,7 +65,7 @@ public class DotnetTestHostManager : ITestRuntimeProvider | |||
/// </summary> | |||
private Action<Process, string> ErrorReceivedCallback => ((process, data) => | |||
{ | |||
if (data != null) | |||
if (!string.IsNullOrEmpty(data)) | |||
{ | |||
// if incoming data stream is huge empty entire testError stream, & limit data stream to MaxCapacity | |||
if (data.Length > this.testHostProcessStdError.MaxCapacity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please avoid logging multiple times, this.messageLogger.SendMessage
in *TestHostManager.cs.
@@ -117,6 +118,8 @@ public DotnetTestHostManager() | |||
this.processHelper = processHelper; | |||
this.fileHelper = fileHelper; | |||
this.dotnetHostHelper = dotnetHostHelper; | |||
|
|||
(this.testHostLauncher as DefaultTestHostLauncher)?.SetErrorCallBack(this.ErrorReceivedCallback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this, but to break errorCallBack action from TestProcessStartInfo, this seemed one solution.
Another possible solution would have been to make it part of ITestHostLauncher, which then passes it down to IProcessHelper.
If this doesn't look good at all, let me know, will not push this in.
DotNetTestHost Code Refactor(Removed ITestHostlauncher)
/// checks if the process has exited, & returns exitcode. | ||
/// </summary> | ||
/// <param name="process">process</param> | ||
/// <returns>process exited</returns> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
False if process has not exited, True otherwise. Set exitCode only if process has exited.
private void ProcessExited(Process process, EventArgs e) | ||
{ | ||
// wait for process to flush out error, & out streams | ||
process.WaitForExit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check if this can lead to a deadlock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exited event is only raised once, so this should be safe
//// Copyright (c) Microsoft Corporation. All rights reserved. | ||
//// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
//namespace TestPlatform.CrossPlatEngine.UnitTests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, all the test in ProcessHelperTest were earlier written to verify ErrorCallBack method, since then it has been moved to individual Runtime providers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete it please in that case.
this.defaultTestProcessStartInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { defaultSourcePath }, null, this.defaultConnectionInfo); | ||
} | ||
|
||
public void ErrorCallBackTestHelper(string errorMessage, int exitCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be private
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
this.mockTestHostLauncher.Verify(thl => thl.LaunchTestHost(It.Is<TestProcessStartInfo>(x => x.Arguments.Equals(expectedArgs))), Times.Once); | ||
} | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove
} | ||
|
||
[TestMethod] | ||
public async Task DotNetCoreNoErrorMessageIfDataIsEmptyAsync() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge with above test case. Use DataTestMethod
with DataRow
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
} | ||
catch (OperationCanceledException ex) | ||
|
||
if (this.processHelper.TryGetExitCode(process, out exitCode)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing scenario: process doesn't write anything on stderr
and exits -> HostExited should be called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
@@ -108,64 +68,67 @@ internal DefaultTestHostManager(Architecture architecture, Framework framework, | |||
this.Shared = shared; | |||
} | |||
|
|||
public event EventHandler<HostProviderEventArgs> HostLaunched; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document that HostLaunched
will not be called for custom launchers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be documented as part of design doc right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to put it in code. It will be available in intellisense.
Added required test cases
@dotnet-bot Test this please |
Passing runsettings as xml