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

Fix Few UWP VC++ unit tests are not executing #1649

Merged
merged 6 commits into from
Jun 18, 2018

Conversation

smadala
Copy link
Contributor

@smadala smadala commented Jun 15, 2018

Description

RCA
Changing the testcase's object source for inprogress tests for clients(VS Test explorer) causing the issue in UWP C++ scenario as the adapter and testplatform share same testcase object by changing the testcase source the testcase becoming invalid in UWP C++ adapter.

Related issue

#1642

Copy link
Contributor

@singhsarab singhsarab left a comment

Choose a reason for hiding this comment

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

Tests please :)

@@ -152,6 +152,13 @@ public string SerializePayload(string messageType, object payload, int version)
return JsonConvert.SerializeObject(message);
}

/// <inheritdoc/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please write a comment on why we chose this approach, just for reference.
Also consider making it an extension method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are lot of discussion over stackoverflow, how to do deep copy.

  1. BinaryFormatter
    This very generic and easy to implement, But it is not available in NS14.
  2. ICloneable
    This required changes in all the class which are involved and difficult to maintain(complicated code).

As we are already using JsonDataSeializer to transfer the object over network. We can use the same functionality to do clone Which is well tested.

/// <inheritdoc/>
public T Clone<T>(T obj)
{
var stringObj = this.Serialize<T>(obj);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Check for ICloneable implemention and if so use it. else fallback

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see #1649 (comment)

{
tr.TestCase.Source = package;
}
tr.TestCase.Source = package;
Copy link
Contributor

Choose a reason for hiding this comment

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

tr.TestCase.Source = package; [](start = 16, length = 29)

Is this safe ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this not safe. As we discussed offline, currently there is no known scenario to which break because of not copying(better performance). However it is better to copy the test results(which adapter creates) to make sure correctness over performance.

I have made changes to copy the test results too.

Copy link
Contributor

@cltshivash cltshivash left a comment

Choose a reason for hiding this comment

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

🕐

@@ -557,6 +566,12 @@ private void SetAdapterLoggingSettings()
// Collecting Number of Adapters Used to run tests.
this.requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, this.ExecutorUrisThatRanTests.Count());

if (lastChunk.Any() && string.IsNullOrEmpty(package) == false)
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: inaddition to package being null should we also compare with source.. also depending on package being null for a business logic seems a little odd.. ideally there shold be a flag setup upstream (to indicate this behavior)

@@ -557,6 +566,12 @@ private void SetAdapterLoggingSettings()
// Collecting Number of Adapters Used to run tests.
this.requestData.MetricsCollection.Add(TelemetryDataConstants.NumberOfAdapterUsedToRunTests, this.ExecutorUrisThatRanTests.Count());

if (lastChunk.Any() && string.IsNullOrEmpty(package) == false)
{
Tuple<ICollection<TestResult>, ICollection<TestCase>> updatedTestResultsAndInProgressTestCases = this.UpdateTestCaseSourceToPackage(lastChunk, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: can use var ? (also usage of Tuple indicates a missing struct)

{
if (this.testRunEventsHandler != null)
{
UpdateTestResults(results, inProgressTests, this.package);
if (string.IsNullOrEmpty(package) == false)
Copy link
Contributor

Choose a reason for hiding this comment

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

i see this being repeated.. opportunity to have it in a meaningful method..

if (!string.IsNullOrEmpty(package))

EqtTrace.Verbose("BaseRunTests.UpdateTestCaseSourceToPackage: Update source details for testResults and testCases.");

Copy link
Contributor

Choose a reason for hiding this comment

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

remove unnecessary empty lines

Copy link
Contributor

@cltshivash cltshivash left a comment

Choose a reason for hiding this comment

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

Please address the comments

@smadala
Copy link
Contributor Author

smadala commented Jun 18, 2018

@cltshivash I have to wait for one hour for PR checks to pass if I address the PR comments. As there no behavior change comments I'm going ahead with merge. Will address the comments in separate PR.

@smadala smadala merged commit abc7599 into microsoft:master Jun 18, 2018
@smadala smadala deleted the fix-uwp-cpp-unit-tests-no-results branch June 18, 2018 17:35
@smadala smadala mentioned this pull request Jun 19, 2018
@smadala
Copy link
Contributor Author

smadala commented Jun 19, 2018

Created #1651 to fix nits.

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.

3 participants