Skip to content
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

Merged
merged 12 commits into from
Mar 20, 2017
Merged

Test runtime provider Interface changes #593

merged 12 commits into from
Mar 20, 2017

Conversation

mayankbansal018
Copy link
Contributor

Passing runsettings as xml

@mayankbansal018 mayankbansal018 self-assigned this Mar 10, 2017
@mayankbansal018 mayankbansal018 requested a review from codito March 10, 2017 13:18
@msftclas
Copy link

@mayankbansal018,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

@@ -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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rationale behind this change ?

Copy link
Contributor Author

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.

Copy link
Contributor

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; }
Copy link
Contributor

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);
Copy link
Contributor

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)
Copy link
Contributor

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);
Copy link
Contributor Author

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>
Copy link
Contributor

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();
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional?

Copy link
Contributor Author

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

Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be private

Copy link
Contributor Author

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);
}

Copy link
Contributor

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()
Copy link
Contributor

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.

Copy link
Contributor Author

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))
Copy link
Contributor

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@mayankbansal018
Copy link
Contributor Author

@dotnet-bot Test this please

@mayankbansal018 mayankbansal018 merged commit d189e71 into microsoft:master Mar 20, 2017
@mayankbansal018 mayankbansal018 deleted the hostextensibilty-framework branch March 20, 2017 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants