-
Notifications
You must be signed in to change notification settings - Fork 291
Added an option to deploy all files in the test source location #391
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
Changes from 6 commits
5aa11a3
b9f6f65
3321a73
5e1a563
9a6f307
a43a940
4bec349
10f5b68
8425a55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,81 +1,17 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices | ||
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Globalization; | ||
| using System.IO; | ||
| using System.Xml; | ||
|
|
||
| using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
| using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; | ||
|
|
||
| using ISettingsProvider = Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.ISettingsProvider; | ||
|
|
||
| #pragma warning disable SA1649 // File name must match first type name | ||
|
|
||
| /// <summary> | ||
| /// Class to read settings from the runsettings xml for the desktop. | ||
| /// </summary> | ||
| public class MSTestSettingsProvider : ISettingsProvider | ||
| #pragma warning restore SA1649 // File name must match first type name | ||
| { | ||
| /// <summary> | ||
| /// Member variable for Adapter settings | ||
| /// </summary> | ||
| private static MSTestAdapterSettings settings; | ||
|
|
||
| /// <summary> | ||
| /// Gets settings provided to the adapter. | ||
| /// </summary> | ||
| public static MSTestAdapterSettings Settings | ||
| { | ||
| get | ||
| { | ||
| if (settings == null) | ||
| { | ||
| settings = new MSTestAdapterSettings(); | ||
| } | ||
|
|
||
| return settings; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Load the settings from the reader. | ||
| /// </summary> | ||
| /// <param name="reader">Reader to load the settings from.</param> | ||
| public void Load(XmlReader reader) | ||
| { | ||
| ValidateArg.NotNull<XmlReader>(reader, "reader"); | ||
|
|
||
| settings = MSTestAdapterSettings.ToSettings(reader); | ||
| } | ||
|
|
||
| public IDictionary<string, object> GetProperties(string source) | ||
| { | ||
| return TestDeployment.GetDeploymentInformation(source); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Reset the settings to its default. | ||
| /// Used for testing purposes. | ||
| /// </summary> | ||
| internal static void Reset() | ||
| { | ||
| settings = null; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Adapter Settings for the run | ||
| /// </summary> | ||
| #pragma warning disable SA1402 | ||
| public class MSTestAdapterSettings | ||
| #pragma warning restore SA1402 | ||
| { | ||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="MSTestAdapterSettings"/> class. | ||
|
|
@@ -84,6 +20,7 @@ public MSTestAdapterSettings() | |
| { | ||
| this.DeleteDeploymentDirectoryAfterTestRunIsComplete = true; | ||
| this.DeploymentEnabled = true; | ||
| this.DeployTestSourceDependencies = true; | ||
| this.SearchDirectories = new List<RecursiveDirectoryPath>(); | ||
| } | ||
|
|
||
|
|
@@ -97,6 +34,11 @@ public MSTestAdapterSettings() | |
| /// </summary> | ||
| public bool DeleteDeploymentDirectoryAfterTestRunIsComplete { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets a value indicating whether the test source references are to deployed | ||
cltshivash marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// </summary> | ||
| public bool DeployTestSourceDependencies { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets list of paths recursive or non recursive paths. | ||
| /// </summary> | ||
|
|
@@ -107,7 +49,6 @@ public MSTestAdapterSettings() | |
| /// </summary> | ||
| /// <param name="reader">Reader to load the settings from.</param> | ||
| /// <returns>An instance of the <see cref="MSTestAdapterSettings"/> class</returns> | ||
| [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "Reviewed. Suppression is OK here.")] | ||
| public static MSTestAdapterSettings ToSettings(XmlReader reader) | ||
| { | ||
| ValidateArg.NotNull<XmlReader>(reader, "reader"); | ||
|
|
@@ -116,6 +57,7 @@ public static MSTestAdapterSettings ToSettings(XmlReader reader) | |
| // | ||
| // <MSTestV2> | ||
| // <DeploymentEnabled>true</DeploymentEnabled> | ||
| // <DeployTestSourceDependencies>true</DeployTestSourceDependencies> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice 👍 |
||
| // <DeleteDeploymentDirectoryAfterTestRunIsComplete>true</DeleteDeploymentDirectoryAfterTestRunIsComplete> | ||
| // <AssemblyResolution> | ||
| // <Directory path= "% HOMEDRIVE %\direvtory "includeSubDirectories = "true" /> | ||
|
|
@@ -151,6 +93,16 @@ public static MSTestAdapterSettings ToSettings(XmlReader reader) | |
| break; | ||
| } | ||
|
|
||
| case "DEPLOYTESTSOURCEDEPENDENCIES": | ||
| { | ||
| if (bool.TryParse(reader.ReadInnerXml(), out result)) | ||
| { | ||
| settings.DeployTestSourceDependencies = result; | ||
| } | ||
|
|
||
| break; | ||
| } | ||
|
|
||
| case "DELETEDEPLOYMENTDIRECTORYAFTERTESTRUNISCOMPLETE": | ||
| { | ||
| if (bool.TryParse(reader.ReadInnerXml(), out result)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices | ||
| { | ||
| using System.Collections.Generic; | ||
| using System.Xml; | ||
| using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
|
|
||
| using ISettingsProvider = Interface.ISettingsProvider; | ||
|
|
||
| /// <summary> | ||
| /// Class to read settings from the runsettings xml for the desktop. | ||
| /// </summary> | ||
| public class MSTestSettingsProvider : ISettingsProvider | ||
| { | ||
| /// <summary> | ||
| /// Member variable for Adapter settings | ||
| /// </summary> | ||
| private static MSTestAdapterSettings settings; | ||
|
|
||
| /// <summary> | ||
| /// Gets settings provided to the adapter. | ||
| /// </summary> | ||
| public static MSTestAdapterSettings Settings | ||
| { | ||
| get | ||
| { | ||
| if (settings == null) | ||
| { | ||
| settings = new MSTestAdapterSettings(); | ||
| } | ||
|
|
||
| return settings; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Reset the settings to its default. | ||
| /// </summary> | ||
| public static void Reset() | ||
| { | ||
| settings = null; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Load the settings from the reader. | ||
| /// </summary> | ||
| /// <param name="reader">Reader to load the settings from.</param> | ||
| public void Load(XmlReader reader) | ||
| { | ||
| ValidateArg.NotNull(reader, "reader"); | ||
| settings = MSTestAdapterSettings.ToSettings(reader); | ||
| } | ||
|
|
||
| public IDictionary<string, object> GetProperties(string source) | ||
| { | ||
| return TestDeployment.GetDeploymentInformation(source); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Uti | |
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.Globalization; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Reflection; | ||
|
|
||
|
|
@@ -91,14 +92,14 @@ internal bool IsValidDeploymentItem(string sourcePath, string relativeOutputDire | |
| return false; | ||
| } | ||
|
|
||
| if (sourcePath.IndexOfAny(System.IO.Path.GetInvalidPathChars()) != -1 || | ||
| relativeOutputDirectory.IndexOfAny(System.IO.Path.GetInvalidPathChars()) != -1) | ||
| if (sourcePath.IndexOfAny(Path.GetInvalidPathChars()) != -1 || | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| relativeOutputDirectory.IndexOfAny(Path.GetInvalidPathChars()) != -1) | ||
| { | ||
| warning = string.Format(CultureInfo.CurrentCulture, Resource.DeploymentItemContainsInvalidCharacters, sourcePath, relativeOutputDirectory); | ||
| return false; | ||
| } | ||
|
|
||
| if (System.IO.Path.IsPathRooted(relativeOutputDirectory)) | ||
| if (Path.IsPathRooted(relativeOutputDirectory)) | ||
| { | ||
| warning = string.Format(CultureInfo.CurrentCulture, Resource.DeploymentItemOutputDirectoryMustBeRelative, relativeOutputDirectory); | ||
| return false; | ||
|
|
@@ -123,18 +124,15 @@ internal bool HasDeploymentItems(TestCase testCase) | |
| internal IList<DeploymentItem> GetDeploymentItems(IEnumerable<TestCase> tests) | ||
| { | ||
| List<DeploymentItem> allDeploymentItems = new List<DeploymentItem>(); | ||
|
|
||
| foreach (var test in tests) | ||
| { | ||
| KeyValuePair<string, string>[] items = this.GetDeploymentItems(test); | ||
|
|
||
| if (items == null || items.Length == 0) | ||
| { | ||
| continue; | ||
| } | ||
|
|
||
| IList<DeploymentItem> deploymentItemsToBeAdded = this.FromKeyValuePairs(items); | ||
|
|
||
| foreach (var deploymentItemToBeAdded in deploymentItemsToBeAdded) | ||
| { | ||
| this.AddDeploymentItem(allDeploymentItems, deploymentItemToBeAdded); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices | ||
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment; | ||
|
|
||
| internal class DeploymentResult | ||
|
||
| { | ||
| public DeploymentResult(bool success, TestRunDirectories directories) | ||
| { | ||
| this.Success = success; | ||
| this.RunDirectories = directories; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets a value indicating whether the deployment was successful | ||
| /// </summary> | ||
| public bool Success { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets a value for the RunDirectories created for the deployment | ||
| /// </summary> | ||
| public TestRunDirectories RunDirectories { get; private set; } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.