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

Test execution bugs in specific TFMs addressed. #1071

Merged
merged 13 commits into from
Apr 22, 2022
Merged
16 changes: 11 additions & 5 deletions TestFx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Package", "Package", "{E374A3A6-C364-4890-B315-D60F5C682B6E}"
ProjectSection(SolutionItems) = preProject
src\Package\MSTest.Internal.TestFx.Documentation.nuspec = src\Package\MSTest.Internal.TestFx.Documentation.nuspec
src\Package\MSTest.TestAdapter.Enu.nuspec = src\Package\MSTest.TestAdapter.Enu.nuspec
src\Package\MSTest.TestAdapter.nuspec = src\Package\MSTest.TestAdapter.nuspec
src\Package\MSTest.TestAdapter.symbols.nuspec = src\Package\MSTest.TestAdapter.symbols.nuspec
src\Package\MSTest.TestFramework.enu.nuspec = src\Package\MSTest.TestFramework.enu.nuspec
src\Package\MSTest.TestFramework.nuspec = src\Package\MSTest.TestFramework.nuspec
src\Package\MSTest.TestFramework.symbols.nuspec = src\Package\MSTest.TestFramework.symbols.nuspec
EndProjectSection
Expand Down Expand Up @@ -210,10 +208,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetCore", "NetCore", "{D11C
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlatformServices.WinUI", "src\Adapter\PlatformServices.WinUI\PlatformServices.WinUI.csproj", "{F4E2876F-6E42-4DCF-B629-041A9DF7C579}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WinUI", "WinUI", "{35D010CC-CDF2-4115-BCFB-E2E3D21C1055}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Net5", "Net5", "{35D010CC-CDF2-4115-BCFB-E2E3D21C1055}"
ProjectSection(SolutionItems) = preProject
src\Adapter\Build\WinUI\MSTest.TestAdapter.props = src\Adapter\Build\WinUI\MSTest.TestAdapter.props
src\Adapter\Build\WinUI\MSTest.TestAdapter.targets = src\Adapter\Build\WinUI\MSTest.TestAdapter.targets
src\Adapter\Build\Net5\MSTest.TestAdapter.props = src\Adapter\Build\Net5\MSTest.TestAdapter.props
src\Adapter\Build\Net5\MSTest.TestAdapter.targets = src\Adapter\Build\Net5\MSTest.TestAdapter.targets
src\Adapter\Build\Net5\MSTest.TestFramework.targets = src\Adapter\Build\Net5\MSTest.TestFramework.targets
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReferencedProjectFromDataSourceTest", "test\E2ETests\TestAssets\ReferencedProjectFromDataSourceTest\ReferencedProjectFromDataSourceTest.csproj", "{6B4DE65C-4162-4C52-836A-8F9FA901814A}"
Expand All @@ -224,6 +223,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlatformServices.Desktop.Le
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OutputTestProject", "test\E2ETests\TestAssets\OutputTestProject\OutputTestProject.csproj", "{66608D86-416A-49AF-A937-C47F7E4586AE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Desktop.Legacy", "Desktop.Legacy", "{DE6887A6-D4B8-4D77-98D3-CC87A8F21C2E}"
ProjectSection(SolutionItems) = preProject
src\Adapter\Build\Desktop.Legacy\MSTest.TestAdapter.props = src\Adapter\Build\Desktop.Legacy\MSTest.TestAdapter.props
src\Adapter\Build\Desktop.Legacy\MSTest.TestAdapter.targets = src\Adapter\Build\Desktop.Legacy\MSTest.TestAdapter.targets
EndProjectSection
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Adapter\PlatformServices.Shared\PlatformServices.Shared.projitems*{2177c273-ae07-43b3-b87a-443e47a23c5a}*SharedItemsImports = 13
Expand Down Expand Up @@ -1447,6 +1452,7 @@ Global
{44A504D9-A0D6-427D-BFB2-DB144A74F0D5} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
{F64A748C-DDBA-4B57-99F4-D9E55684A7A4} = {24088844-2107-4DB2-8F3F-CBCA94FC4B28}
{66608D86-416A-49AF-A937-C47F7E4586AE} = {D53BD452-F69F-4FB3-8B98-386EDA28A4C8}
{DE6887A6-D4B8-4D77-98D3-CC87A8F21C2E} = {CA01DAF5-8D9D-496E-9AD3-94BB7FBB2D34}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {31E0F4D5-975A-41CC-933E-545B2201FAF9}
Expand Down
12 changes: 6 additions & 6 deletions scripts/common.lib.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -270,22 +270,22 @@ function Install-DotNetCli {
New-Item -ItemType directory -Path $dotnetInstallPath -Force | Out-Null
& $dotnetInstallScript -Channel "master" -InstallDir $dotnetInstallPath -Version $env:DOTNET_CLI_VERSION

& $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '2.1.0' -Channel '2.1.0' -Architecture x64 -NoPath
& $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '2.1.30' -Channel '2.1.30' -Architecture x64 -NoPath
$env:DOTNET_ROOT = $dotnetInstallPath

& $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '2.1.0' -Channel '2.1.0' -Architecture x86 -NoPath
& $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '2.1.30' -Channel '2.1.30' -Architecture x86 -NoPath
${env:DOTNET_ROOT(x86)} = "${dotnetInstallPath}_x86"

& $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '3.1.0' -Channel '3.1.0' -Architecture x64 -NoPath
& $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '3.1.24' -Channel '3.1.24' -Architecture x64 -NoPath
$env:DOTNET_ROOT = $dotnetInstallPath

& $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '3.1.0' -Channel '3.1.0' -Architecture x86 -NoPath
& $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '3.1.24' -Channel '3.1.24' -Architecture x86 -NoPath
${env:DOTNET_ROOT(x86)} = "${dotnetInstallPath}_x86"

& $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '5.0.1' -Channel '5.0.1' -Architecture x64 -NoPath
& $dotnetInstallScript -InstallDir "$dotnetInstallPath" -Runtime 'dotnet' -Version '5.0.16' -Channel '5.0.16' -Architecture x64 -NoPath
$env:DOTNET_ROOT = $dotnetInstallPath

& $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '5.0.1' -Channel '5.0.1' -Architecture x86 -NoPath
& $dotnetInstallScript -InstallDir "${dotnetInstallPath}_x86" -Runtime 'dotnet' -Version '5.0.16' -Channel '5.0.16' -Architecture x86 -NoPath
${env:DOTNET_ROOT(x86)} = "${dotnetInstallPath}_x86"

$env:DOTNET_MULTILEVEL_LOOKUP = 0
Expand Down
7 changes: 7 additions & 0 deletions src/Adapter/Build/Net5/MSTest.TestAdapter.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<!--
Directives here are moved to MSTest.TestAdapter.targets file to make sure they are
included after WinUI properties are specified.
-->
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,43 @@
<PropertyGroup>
<EnableMSTestV2CopyResources Condition=" '$(EnableMSTestV2CopyResources)' == '' ">true</EnableMSTestV2CopyResources>
</PropertyGroup>
<PropertyGroup Condition=" '$(UseWinUI)' == 'true' ">
<__TestAdapterPlatformServicesRoot>$(MSBuildThisFileDirectory)winui/</__TestAdapterPlatformServicesRoot>
</PropertyGroup>
<PropertyGroup Condition=" '$(UseWinUI)' != 'true' ">
<__TestAdapterPlatformServicesRoot>$(MSBuildThisFileDirectory)</__TestAdapterPlatformServicesRoot>
</PropertyGroup>

<ItemGroup>
<TestAdapterContent Include="$(MSBuildThisFileDirectory)..\_common\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll">
<Link>Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</TestAdapterContent>
<TestAdapterContent Include="$(MSBuildThisFileDirectory)..\_common\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll">
<Link>Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</TestAdapterContent>
<TestAdapterContent Include="$(__TestAdapterPlatformServicesRoot)Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll">
<Link>Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</TestAdapterContent>
<TestAdapterContent Include="$(MSBuildThisFileDirectory)\Microsoft.TestPlatform.AdapterUtilities.dll">
<Link>Microsoft.TestPlatform.AdapterUtilities.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</TestAdapterContent>
</ItemGroup>

<ItemGroup>
<!-- Including `@(TestAdapterContent)` in the `None` ItemGroup to get the `CopyToOutputDirectory`
behavior be default, package consumers can opt-out of this behavior
by removing `@(TestAdapterContent)` from the `None` ItemGroup
i.e. `<None Remove="@(TestAdapterContent)" />` -->
<None Include="@(TestAdapterContent)" />
</ItemGroup>

<Target Name="GetMSTestV2CultureHierarchy">
<!-- Only traversing 5 levels in the culture hierarchy. This is the maximum lenght for all cultures and should be sufficient to get to a culture name that maps to a resource folder we package.
Expand All @@ -19,7 +56,6 @@

<!-- Copy resources over to $(TargetDir) if this is a localized build. -->
<Target Name="CopyMSTestV2Resources" BeforeTargets="PrepareForBuild" Condition=" '$(EnableMSTestV2CopyResources)' == 'true' " DependsOnTargets="GetMSTestV2CultureHierarchy">

<PropertyGroup>
<CurrentUICultureHierarchy>%(CurrentUICultureHierarchy.Identity)</CurrentUICultureHierarchy>
</PropertyGroup>
Expand All @@ -28,7 +64,7 @@
<MSTestV2Files Include="$(MSBuildThisFileDirectory)..\_common\*.dll" />
</ItemGroup>

<ItemGroup>
<ItemGroup>
<Content Include="@(MSTestV2Files->'%(RootDir)%(Directory)$(CurrentUICultureHierarchy)\%(FileName).resources.dll')"
Condition="Exists('%(RootDir)%(Directory)$(CurrentUICultureHierarchy)\%(FileName).resources.dll')">
<Link>$(CurrentUICultureHierarchy)\%(FileName).resources.dll</Link>
Expand All @@ -38,5 +74,4 @@
</Content>
</ItemGroup>
</Target>

</Project>
17 changes: 17 additions & 0 deletions src/Adapter/Build/Net5/MSTest.TestFramework.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(UseWinUI)' == 'true' ">
<_TestFrameworkExtensionsRoot>$(MSBuildThisFileDirectory)winui/</_TestFrameworkExtensionsRoot>
</PropertyGroup>
<PropertyGroup Condition=" '$(UseWinUI)' != 'true' ">
<_TestFrameworkExtensionsRoot>$(MSBuildThisFileDirectory)</_TestFrameworkExtensionsRoot>
</PropertyGroup>

<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions">
<HintPath>$(_TestFrameworkExtensionsRoot)Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Visible>False</Visible>
</Reference>
</ItemGroup>
</Project>
33 changes: 0 additions & 33 deletions src/Adapter/Build/WinUI/MSTest.TestAdapter.props

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<Compile Include="$(RepoRoot)src\Adapter\PlatformServices.Shared\netstandard1.3\Utilities\ns13DeploymentItemUtility.cs" Link="Utilities\ns13DeploymentItemUtility.cs" />
<Compile Include="$(RepoRoot)src\Adapter\PlatformServices.Shared\netstandard1.3\Utilities\ns13DeploymentUtilityBase.cs" Link="Utilities\ns13DeploymentUtilityBase.cs" />
<Compile Include="$(RepoRoot)src\Adapter\PlatformServices.Shared\netstandard1.3\Utilities\ns13FileUtility.cs" Link="Utilities\ns13FileUtility.cs" />
<Compile Include="..\PlatformServices.Shared\netstandard1.3\Services\ns13ThreadSafeStringWriter.cs" Link="ns13ThreadSafeStringWriter.cs" />
<Compile Include="$(RepoRoot)src\Adapter\PlatformServices.Shared\netstandard1.3\Services\ns13ThreadSafeStringWriter.cs" Link="Services\ns13ThreadSafeStringWriter.cs" />
<Compile Include="Deployment\NetCoreTestRunDirectories.cs" />
<Compile Include="Friends.cs" />
<Compile Include="Services\NetCoreTestContextImplementation.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class TestContextImplementation : UTF.TestContext, ITestContext
/// </summary>
private ITestMethod testMethod;

private StringWriter stringWriter;
private ThreadSafeStringWriter threadSafeStringWriter;
private bool stringWriterDisposed;

/// <summary>
Expand All @@ -62,7 +62,7 @@ public TestContextImplementation(ITestMethod testMethod, StringWriter writer, ID

this.testMethod = testMethod;
this.properties = new Dictionary<string, object>(properties);
this.stringWriter = writer;
this.threadSafeStringWriter = (ThreadSafeStringWriter)writer;
this.CancellationTokenSource = new CancellationTokenSource();
this.InitializeProperties();
}
Expand Down Expand Up @@ -204,7 +204,7 @@ public override void Write(string message)
try
{
var msg = message?.Replace("\0", "\\0");
this.stringWriter.Write(msg);
this.threadSafeStringWriter.Write(msg);
}
catch (ObjectDisposedException)
{
Expand All @@ -228,7 +228,7 @@ public override void Write(string format, params object[] args)
try
{
string message = string.Format(CultureInfo.CurrentCulture, format?.Replace("\0", "\\0"), args);
this.stringWriter.Write(message);
this.threadSafeStringWriter.Write(message);
}
catch (ObjectDisposedException)
{
Expand All @@ -251,7 +251,7 @@ public override void WriteLine(string message)
try
{
var msg = message?.Replace("\0", "\\0");
this.stringWriter.WriteLine(msg);
this.threadSafeStringWriter.WriteLine(msg);
}
catch (ObjectDisposedException)
{
Expand All @@ -275,7 +275,7 @@ public override void WriteLine(string format, params object[] args)
try
{
string message = string.Format(CultureInfo.CurrentCulture, format?.Replace("\0", "\\0"), args);
this.stringWriter.WriteLine(message);
this.threadSafeStringWriter.WriteLine(message);
}
catch (ObjectDisposedException)
{
Expand All @@ -298,16 +298,15 @@ public IList<string> GetResultFiles()
/// <returns>The test context messages added so far.</returns>
public string GetDiagnosticMessages()
{
return this.stringWriter.ToString();
return this.threadSafeStringWriter.ToString();
}

/// <summary>
/// Clears the previous testContext writeline messages.
/// </summary>
public void ClearDiagnosticMessages()
{
var sb = this.stringWriter.GetStringBuilder();
sb?.Remove(0, sb.Length);
this.threadSafeStringWriter.ToStringAndClear();
}

public void SetDataRow(object dataRow)
Expand Down
Loading