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

TestPlugin cache refactored. #709

Merged
merged 16 commits into from
Apr 18, 2017

Conversation

harshjain2
Copy link
Contributor

  1. Refactored Test Plugin Cache to support loading for individual extensions.

@msftclas
Copy link

@harshjain2,
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

@@ -113,7 +104,7 @@ public IEnumerable<string> PathToAdditionalExtensions
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename it to PathToExtensions

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.

@@ -23,45 +23,96 @@ public class TestExtensions
internal Dictionary<string, TestDiscovererPluginInformation> TestDiscoverers { get; set; }

/// <summary>
/// Gets or sets a value indicating whether are test discoverers cached.
/// </summary>
internal bool AreTestDiscoverersCached { 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.

Where are we setting the value of variable AreTestDiscoverersCached

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resovled.

@@ -53,12 +54,12 @@ public static TestLoggerExtensionManager Create(IMessageLogger messageLogger)
IEnumerable<LazyExtension<ITestLogger, ITestLoggerCapabilities>> filteredTestExtensions;
IEnumerable<LazyExtension<ITestLogger, Dictionary<string, object>>> unfilteredTestExtensions;

TestPluginManager.Instance.GetTestExtensions<ITestLogger, ITestLoggerCapabilities, TestLoggerMetadata>(
TestPluginManager.Instance.GetSpecificTestExtensions<TestLoggerPluginInformation, ITestLogger, ITestLoggerCapabilities, TestLoggerMetadata>(
Copy link
Contributor

Choose a reason for hiding this comment

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

TestLoggerPluginInformation [](start = 65, length = 27)

Would we ever call TestLoggerPluginInformation with a different regex pattern? Maybe the regex patter should be in TestPluginInfo itself. Dont see a reason for it to be propagated everywhere when TestPluginInfo is anyway passed through.

{
extensions.AddRange(TestPluginCache.Instance.PathToAdditionalExtensions);
}
var extensions = this.testHostManager.GetTestPlatformExtensions(sourceList, TestPluginCache.Instance.PathToAdditionalExtensions).ToList();
Copy link
Contributor

Choose a reason for hiding this comment

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

.ToList(); [](start = 140, length = 10)

nit: use IEnumerable.

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.

@@ -100,7 +100,7 @@ public DotnetTestHostManager()
/// <remarks>
/// Dependency resolution for .net core projects are pivoted by the test project. Hence each test
/// project must be launched in a separate test host process.
/// </remarks>
/// </remarks>InitializeExtensions
Copy link
Contributor

Choose a reason for hiding this comment

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

InitializeExtensions [](start = 22, length = 20)

cleanup?

/// <returns>
/// The <see cref="Dictionary"/> of extensions discovered
/// </returns>
internal Dictionary<string, TPluginInfo> AddExtension<TPluginInfo>(
Copy link
Contributor

Choose a reason for hiding this comment

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

AddExtension [](start = 49, length = 12)

misleading name: It says Add but we are setting it. Is that intended?

@AbhitejJohn
Copy link
Contributor

public class TestExtensions

What exactly is the responsibility of this class?


Refers to: src/Microsoft.TestPlatform.Common/ExtensionFramework/Utilities/TestExtensions.cs:16 in b0dc0f3. [](commit_id = b0dc0f3, deletion_comment = False)

this.TestExtensions = new TestExtensions();
}

this.TestExtensions.AddExtension<TPluginInfo>(pluginInfos);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we update our central cache?

}

this.GetTestExtensions<TPluginInfo, TExtension>(new List<string>() { extensionAssembly });
return this.TestExtensions?.GetExtensionsDiscoveredFromAssembly<TPluginInfo>(this.TestExtensions.GetTestExtensionCache<TPluginInfo>(), extensionAssembly);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this line.

@@ -204,7 +214,7 @@ public ArgumentProcessorResult Execute()
/// <returns> The list of test adapter and logger assemblies. </returns>
internal virtual IEnumerable<string> GetTestAdaptersFromDirectory(string directory)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this function now? I think we can remove it and we should add logic to find extension in testplatform.UpdateTestAdapterPaths( string runSettings )

Copy link
Contributor

@Faizan2304 Faizan2304 left a comment

Choose a reason for hiding this comment

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

👍 LGTM

Please add following scenario in your test matrix:

  1. Run cpp tests
  2. Pass logger through /TestAdapterpath


try
{
// Remove leading and trailing ' " ' chars...
argument = argument.Trim().Trim(new char[] { '\"' });

customAdaptersPath = Path.GetFullPath(argument);
if (!fileHelper.DirectoryExists(customAdaptersPath))
var testadapterPaths = argument.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
Copy link
Contributor

@Faizan2304 Faizan2304 Apr 18, 2017

Choose a reason for hiding this comment

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

TestAdapterPath can not have more than one path. If we want to change the behavior then we need to set property
public override bool AllowMultiple => true; and user has to specify /Testadapterpath multiple times if he wants to use multiple Testadapterpath

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted to original behaviour.

/// Gets or sets test setting provider extensions.
/// </summary>
internal Dictionary<string, TestSettingsProviderPluginInformation> TestSettingsProviders { get; set; }

/// <summary>
/// Gets or sets a value indicating whether are test settings providers cached.
/// </summary>
internal bool AreTestSettingsProvidersCached { 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.

Are we planning to move these out to their respective plugin managers? This is becoming a God class.

@AbhitejJohn
Copy link
Contributor

Please file an issue for the two broad level issues that came out as part of this PR:

  1. The regex pattern that is passed all over which isn't needed.
  2. The God level TestExtensions.cs class that needs to transfer responsibility over to each of the plugin managers.

this.output.Warning(CommandLineResources.NoAdaptersFoundInTestAdapterPath, argument);
this.output.WriteLine(string.Empty, OutputLevel.Information);
}
this.commandLineOptions.TestAdapterPath = customAdaptersPath;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please check uses of this. earlier it were taking single path but now u are passing list of paths

@harshjain2
Copy link
Contributor Author

@dotnet-bot test this please

@codito
Copy link
Contributor

codito commented Apr 18, 2017

@dotnet-bot test this please

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