-
Notifications
You must be signed in to change notification settings - Fork 331
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
make testplatform compatible with old testhost #971
Conversation
@@ -103,6 +105,45 @@ public static void UpdateCollectSourceInformation(XPathNavigator runSettingsNavi | |||
} | |||
|
|||
/// <summary> | |||
/// Remove the <c>RunConfiguration.DesignMode</c> value for a run settings. | |||
/// </summary> | |||
public static void RemoveDesignMode(XPathNavigator runSettingsNavigator) |
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.
DRY: Can we have generalize method here, rather than one method for each element?
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 cant, generalized method (RemoveNodeFromRunConfiguration
) is getting called from this method. We cant generalize because in that case we have to pass full path(RunSettings/RunConfiguration/DesignMode
) and name of node to delete it and we want to have those info in this class only.
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.
Fixed in next commit
document.Load(reader); | ||
|
||
var navigator = document.CreateNavigator(); | ||
|
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.
Rather than removing new ones, Can we just keep old ones?
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.
Theoretically it seems right but i think it will be little big work.
@@ -87,6 +87,11 @@ public void Initialize(IEnumerable<string> pathToAdditionalExtensions) | |||
|
|||
this.activeTestRun.RunTests(); | |||
} | |||
catch(Exception e) | |||
{ | |||
this.testRunEventsHandler.HandleLogMessage(ObjectModel.Logging.TestMessageLevel.Error, e.Message); |
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.
Pass e.ToString(), Having stacktrace helps finding RC quickly.
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.
Fixed in next commit.
} | ||
|
||
[TestMethod] | ||
public void RemoveDesignModeShouldRemoveDesignModeNode() |
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.
These tests seems to be redundant. Didn't DataTestMethod
covering the same functionality?
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.
No DataTestMethod
(RemoveNodeFromRunConfigurationShouldNotModifyXmlIfNavigatorIsNotAtRootNode
) is covering the scenario where we are sending wrong navigator, that is its a negative test. RemoveDesignModeShouldRemoveDesignModeNode
is positive test which are checking the actual functionality of function RemoveDesignMode
var listOfInValidRunConfigurationSettings = new List<string>(); | ||
|
||
// These are the list of valid RunConfiguration setting name which old testhost understand. | ||
var listOfValidRunConfigurationSettings = new List<string> |
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.
Use Set here.
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.
Fixed in next commit
string settingsName = string.Join(", ", listOfInValidRunConfigurationSettings); | ||
EqtTrace.Warning(string.Format("InferRunSettingsHelper.MakeRunsettingsCompatible: Removing the following settings: {0} from RunSettings file. To use those settings please move to latest version of Microsoft.NET.Test.Sdk", settingsName)); | ||
} | ||
|
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 additional empty lines.
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.
Fixed!!
@@ -110,6 +110,11 @@ public DotnetTestHostManager() | |||
internal virtual bool IsVersionCheckRequired => !this.hostPackageVersion.StartsWith("15.0.0"); | |||
|
|||
/// <summary> | |||
/// Gets a value indicating whether the test host supports protocol version check | |||
/// </summary> | |||
internal virtual bool TestHostCannotHandleNewRunSettingsNode => this.hostPackageVersion.StartsWith("15.0.0-preview"); |
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 this be virtual?
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.
No, no need, i will remove virtual in next commit.
{ | ||
var updatedRunSettingsXml = runsettingsXml; | ||
|
||
var property = this.testHostManager.GetType().GetRuntimeProperties().FirstOrDefault(p => string.Equals(p.Name, oldTestHostPropertyName, StringComparison.OrdinalIgnoreCase)); |
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 it okay to run this for all test host managers?
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, we have to. There is no way to know dotnetTesthostManager.
|
||
} while (runSettingsNavigator.MoveToNext()); | ||
|
||
// Delele all invalid RunConfiguration Settings |
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.
s/Delele/Delete
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.
Fixed
var listOfInValidRunConfigurationSettings = new List<string>(); | ||
|
||
// These are the list of valid RunConfiguration setting name which old testhost understand. | ||
var listOfValidRunConfigurationSettings = new HashSet<string> |
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 a constant 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.
Yes
{ | ||
if(!listOfValidRunConfigurationSettings.Contains(runSettingsNavigator.LocalName)) | ||
{ | ||
listOfInValidRunConfigurationSettings.Add(runSettingsNavigator.LocalName); |
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.
Why not remove the node here directly?
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.
Its because when we delete a node, navigator jumps to parent and we lost track of last visited child.
@@ -121,11 +122,13 @@ public virtual int StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsH | |||
isDebug: (testRunCriteria.TestHostLauncher != null && testRunCriteria.TestHostLauncher.IsDebug), | |||
testCaseFilter: testRunCriteria.TestCaseFilter); | |||
|
|||
// This is workaround for the bug https://github.com/Microsoft/vstest/issues/970 | |||
var runsettings = this.RemoveNodesFromRunsettingsIfRequired(testRunCriteria.TestRunSettings); |
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.
Do we need unit and integration tests for this?
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.
Added acceptance test for this.
@@ -87,6 +87,11 @@ public void Initialize(IEnumerable<string> pathToAdditionalExtensions) | |||
|
|||
this.activeTestRun.RunTests(); | |||
} | |||
catch(Exception e) |
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.
Do we need unit tests for this?
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 :). Added in next commit.
[TestMethod] | ||
public void StartTestRunShouldAbortTheRunIfAnyExceptionComesForTheProvidedTests() | ||
{ | ||
var testExecutionContext = new TestExecutionContext( |
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.
Can we remove DRY violation and make this an instance variable?
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.
Fixed
var mockTestRunEventsHandler = new Mock<ITestRunEventsHandler>(); | ||
|
||
// Call StartTestRun with faulty runsettings so that it will throw exception | ||
this.executionManager.StartTestRun(new Dictionary<string, IEnumerable<string>>(), @"<RunSettings><RunConfiguration><TestSessionTimeout>0</TestSessionTimeout></RunConfiguration></RunSettings>", testExecutionContext, null, mockTestRunEventsHandler.Object); |
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.
StartTestRunWithTests?
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.
Fixed
/// </summary> | ||
/// <param name="runsettingsXml">runsettings string</param> | ||
/// <returns>runsetting after removing unrequired nodes</returns> | ||
protected string RemoveNodesFromRunsettingsIfRequired(string runsettingsXml, ITestRunEventsHandler eventHandler) |
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.
RemoveNodesFromRunsettingsIfRequired(string runsettingsXml, Action<TestMessageLevel, string> logMessage)
Refactor in ProxyExecutionManager to provide this function. Exception handling in PEM can use the same function.
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.
Fixed
Issue
**Issue1: ** TestHost of version 15.0.0-preview throw exception if any unknown runsettings node (for example TestSessionTimeout is present in runsettings and it got stuck forever.
**issue2: ** If testhost throw exception before starting test run, it doesn't send any testruncomplete event or it doesn't abort process. As a result of it vstest.console keep waiting forever for testhost to send testruncomplete.
#970
Fix
Don't send these newly added runsettings (which are unknown to old testhosts ) to old test hosts.