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

Added an option to deploy all files in the test source location #391

Merged
merged 9 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion TestFx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParallelClassesTestProject"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataSourceTestProject", "test\E2ETests\TestAssets\DataSourceTestProject\DataSourceTestProject.csproj", "{5A4967CD-B527-4D43-81C2-4CA90EE10222}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DoNotParallelizeTestProject", "test\E2ETests\TestAssets\DoNotParallelizeTestProject\DoNotParallelizeTestProject.csproj", "{8080DE48-CFD9-4F33-908A-8B71108CA223}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DoNotParallelizeTestProject", "test\E2ETests\TestAssets\DoNotParallelizeTestProject\DoNotParallelizeTestProject.csproj", "{8080DE48-CFD9-4F33-908A-8B71108CA223}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeploymentTestProject", "test\E2ETests\TestAssets\DeploymentTestProject\DeploymentTestProject.csproj", "{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Expand Down Expand Up @@ -961,6 +963,30 @@ Global
{8080DE48-CFD9-4F33-908A-8B71108CA223}.Release|x64.Build.0 = Release|Any CPU
{8080DE48-CFD9-4F33-908A-8B71108CA223}.Release|x86.ActiveCfg = Release|Any CPU
{8080DE48-CFD9-4F33-908A-8B71108CA223}.Release|x86.Build.0 = Release|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Code Analysis Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Code Analysis Debug|Any CPU.Build.0 = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Code Analysis Debug|ARM.ActiveCfg = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Code Analysis Debug|ARM.Build.0 = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Code Analysis Debug|x64.ActiveCfg = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Code Analysis Debug|x64.Build.0 = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Code Analysis Debug|x86.ActiveCfg = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Code Analysis Debug|x86.Build.0 = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Debug|ARM.ActiveCfg = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Debug|ARM.Build.0 = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Debug|x64.ActiveCfg = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Debug|x64.Build.0 = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Debug|x86.ActiveCfg = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Debug|x86.Build.0 = Debug|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Release|Any CPU.Build.0 = Release|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Release|ARM.ActiveCfg = Release|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Release|ARM.Build.0 = Release|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Release|x64.ActiveCfg = Release|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Release|x64.Build.0 = Release|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Release|x86.ActiveCfg = Release|Any CPU
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1017,6 +1043,7 @@ Global
{CD0CA7CD-CED3-45FF-9F36-B1C8DF7A9220} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
{5A4967CD-B527-4D43-81C2-4CA90EE10222} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
{8080DE48-CFD9-4F33-908A-8B71108CA223} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
{3FCE3987-7C8C-4E12-B54A-C6EC2D9FC7A6} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {31E0F4D5-975A-41CC-933E-545B2201FAF9}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
<Compile Include="Deployment\TestRunDirectories.cs" />
<Compile Include="Extensions\ExceptionExtensions.cs" />
<Compile Include="Friends.cs" />
<Compile Include="Services\MSTestAdapterSettings.cs" />
<Compile Include="Utilities\AppDomainWrapper.cs" />
<Compile Include="Utilities\DeploymentResult.cs" />
<Compile Include="Utilities\IAppDomain.cs" />
<Compile Include="Utilities\SequentialIntPermutation.cs" />
<Compile Include="Resources\Resource.Designer.cs">
Expand All @@ -77,7 +79,7 @@
<Compile Include="Services\DesktopReflectionOperations.cs" />
<Compile Include="Services\DesktopThreadOperations.cs" />
<Compile Include="Services\DesktopFileOperations.cs" />
<Compile Include="Services\DesktopSettingsProvider.cs" />
<Compile Include="Services\MSTestSettingsProvider.cs" />
cltshivash marked this conversation as resolved.
Show resolved Hide resolved
<Compile Include="Services\DesktopTestDataSource.cs" />
<Compile Include="Services\DesktopTestDeployment.cs" />
<Compile Include="Services\DesktopTestSource.cs" />
Expand All @@ -93,6 +95,7 @@
<Compile Include="Utilities\IAssemblyUtility.cs" />
<Compile Include="Utilities\RandomIntPermutation.cs" />
<Compile Include="Utilities\ReflectionUtility.cs" />
<Compile Include="Utilities\Validate.cs" />
<Compile Include="Utilities\VSInstallationUtilities.cs" />
<Compile Include="Utilities\XmlUtilities.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ public bool Deploy(IEnumerable<TestCase> tests, IRunContext runContext, IFramewo
return false;
}

var isDeploymentDone = false;

using (new SuspendCodeCoverage())
{
// Group the tests by source
Expand All @@ -153,7 +151,7 @@ group test by test.Source into testGroup
foreach (var group in testsBySource)
{
// do the deployment
isDeploymentDone = this.deploymentUtility.Deploy(@group.Tests, @group.Source, runContext, frameworkHandle, ref runDirectories) || isDeploymentDone;
this.deploymentUtility.Deploy(@group.Tests, @group.Source, runContext, frameworkHandle, RunDirectories);
cltshivash marked this conversation as resolved.
Show resolved Hide resolved
}

// Update the runDirectories
Expand Down
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.
Expand All @@ -84,6 +20,7 @@ public MSTestAdapterSettings()
{
this.DeleteDeploymentDirectoryAfterTestRunIsComplete = true;
this.DeploymentEnabled = true;
this.DeployTestSourceDependencies = true;
this.SearchDirectories = new List<RecursiveDirectoryPath>();
}

Expand All @@ -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>
Expand All @@ -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");
Expand All @@ -116,6 +57,7 @@ public static MSTestAdapterSettings ToSettings(XmlReader reader)
//
// <MSTestV2>
// <DeploymentEnabled>true</DeploymentEnabled>
// <DeployTestSourceDependencies>true</DeployTestSourceDependencies>
Copy link
Member

Choose a reason for hiding this comment

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

Nice 👍

// <DeleteDeploymentDirectoryAfterTestRunIsComplete>true</DeleteDeploymentDirectoryAfterTestRunIsComplete>
// <AssemblyResolution>
// <Directory path= "% HOMEDRIVE %\direvtory "includeSubDirectories = "true" />
Expand Down Expand Up @@ -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))
Expand Down
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
Expand Up @@ -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;

Expand Down Expand Up @@ -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 ||
Copy link
Member

Choose a reason for hiding this comment

The 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;
Expand All @@ -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);
Expand Down
31 changes: 31 additions & 0 deletions src/Adapter/PlatformServices.Desktop/Utilities/DeploymentResult.cs
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
Copy link
Member

Choose a reason for hiding this comment

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

Adding comments summarizing purpose of this class would be good.

{
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; }
}
}
Loading