Skip to content

Commit

Permalink
PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Haplois committed Nov 9, 2020
1 parent 8faae51 commit 2035b97
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 64 deletions.
36 changes: 33 additions & 3 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ Param(

[Parameter(Mandatory=$false)]
[Alias("noloc")]
[Switch] $DisableLocalizedBuild = $false,
[Switch] $DisableLocalizedBuild,

[Parameter(Mandatory=$false)]
[Alias("ci")]
[Switch] $CIBuild = $false,
[Switch] $CIBuild,

[Parameter(Mandatory=$false)]
[Alias("pt")]
[Switch] $PublishTestArtifacts = $false,
[Switch] $PublishTestArtifacts,

# Build specific projects
[Parameter(Mandatory=$false)]
Expand Down Expand Up @@ -226,6 +226,36 @@ function Restore-Package
& $dotnetExe restore $env:TP_ROOT_DIR\src\package\external\external.csproj --packages $env:TP_PACKAGES_DIR -v:minimal -warnaserror -p:Version=$TPB_Version
Write-Log ".. .. Restore-Package: Complete."

# Fixing a problem with procdump package
# $procdumpFolder = "$env:TP_PACKAGES_DIR\procdump\0.0.1"
# if (-not (Test-Path "$procdumpFolder\bin") -and -not $CIBuild)
# {
# Add-Type -AssemblyName System.IO.Compression.FileSystem

# $zip = $null
# try {
# $zip = [System.IO.Compression.ZipFile]::Open("$procdumpFolder\procdump.0.0.1.nupkg", 0)
# $zip.Entries | Where-Object { $_.FullName.StartsWith("bin/") } | ForEach-Object {
# $file = "$procdumpFolder\$($_.FullName)"
# $fi = [System.IO.Path]::GetDirectoryName($file)
# if (-not (Test-Path $fi)) {
# New-Item -Type Directory -Path $fi -Force
# }

# if (-not (Test-Path $file)) {
# [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $file, $true)
# }
# }
# }
# finally
# {
# if ($null -ne $zip)
# {
# $zip.Dispose()
# }
# }
# }

Set-ScriptFailedOnError

Write-Log "Restore-Package: Complete. {$(Get-ElapsedTime($timer))}"
Expand Down
2 changes: 1 addition & 1 deletion scripts/verify-nupkgs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Verify-Nuget-Packages($packageDirectory)
"Microsoft.TestPlatform.Extensions.TrxLogger" = 33;
"Microsoft.TestPlatform.ObjectModel" = 178;
"Microsoft.TestPlatform.Portable" = 566;
"Microsoft.TestPlatform.TestHost" = 197;
"Microsoft.TestPlatform.TestHost" = 213;
"Microsoft.TestPlatform.TranslationLayer" = 121}

$nugetPackages = Get-ChildItem -Filter "*.nupkg" $packageDirectory | % { $_.FullName}
Expand Down
25 changes: 15 additions & 10 deletions src/Microsoft.TestPlatform.ObjectModel/TestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public string ManagedType {
/// Gets or sets the fully specified method name metadata format.
/// </summary>
/// <example>
/// <code>MethodName`2(ParamTypeA,ParamTypeB,)</code>
/// <code>MethodName`2(ParamTypeA,ParamTypeB,)</code>
/// </example>
[DataMember]
public string ManagedMethod {
Expand Down Expand Up @@ -215,12 +215,12 @@ public string DisplayName
{
if(string.IsNullOrEmpty(this.displayName))
{
if(string.IsNullOrWhiteSpace(managedType) || string.IsNullOrWhiteSpace(managedMethod))
if (this.HasManagedMethodAndType)
{
return this.FullyQualifiedName;
return $"{managedType}.{ManagedMethod}";
}

return $"{managedType}.{ManagedMethod}";
return this.FullyQualifiedName;
}

return this.displayName;
Expand Down Expand Up @@ -288,16 +288,21 @@ public override IEnumerable<TestProperty> Properties
}
}

/// <summary>
/// Returns <c>true</c> if both <see cref="ManagedType"/> and <see cref="ManagedMethod"/> are not null or whitespace.
/// </summary>
public bool HasManagedMethodAndType => !string.IsNullOrWhiteSpace(ManagedType) && !string.IsNullOrWhiteSpace(ManagedMethod);

/// <inheritdoc/>
public override string ToString()
{
if (string.IsNullOrWhiteSpace(ManagedType) || string.IsNullOrWhiteSpace(ManagedMethod))
if (this.HasManagedMethodAndType)
{
return this.FullyQualifiedName;
return $"{ManagedType}.{ManagedMethod}";
}
else
{
return $"{ManagedType}.{ManagedMethod}";
return this.FullyQualifiedName;
}
}

Expand Down Expand Up @@ -336,13 +341,13 @@ private Guid GetTestId()
var testcaseFullName = this.ExecutorUri + source;

// If ManagedType and ManagedMethod properties are filled than TestId should be based on those.
if( string.IsNullOrWhiteSpace(managedType) || string.IsNullOrWhiteSpace(managedMethod))
if (this.HasManagedMethodAndType)
{
testcaseFullName += this.FullyQualifiedName;
testcaseFullName += $"{managedType}.{managedMethod}";
}
else
{
testcaseFullName += $"{managedType}.{managedMethod}";
testcaseFullName += this.FullyQualifiedName;
}

return EqtHash.GuidFromString(testcaseFullName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TestPlatformRoot Condition="$(TestPlatformRoot) == ''">..\..\</TestPlatformRoot>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
</PropertyGroup>
<Import Project="$(TestPlatformRoot)scripts/build/TestPlatform.Settings.targets" />
<PropertyGroup>
<AssemblyName>Microsoft.TestPlatform.PlatformAbstractions</AssemblyName>
<TargetFrameworks>net45;net451;netcoreapp2.1;netstandard1.3;netstandard2.0</TargetFrameworks>
<RootNamespace>Microsoft.TestPlatform.PlatformAbstractions</RootNamespace>
<TargetFrameworks>net45;net451;netcoreapp1.0;netcoreapp2.1;netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);uap10.0;netstandard1.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(DotNetBuildFromSource)' == 'true' ">netstandard1.0;netstandard1.3;netstandard2.0;netcoreapp2.1</TargetFrameworks>
<EnableCodeAnalysis>true</EnableCodeAnalysis>
<NoWarn>NU1605</NoWarn>

<!-- This causes a build error on netcoreapp1.0 -->
<NoWarn Condition="'$(TargetFramework)' != 'netcoreapp1.0'">NU1605</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0'">
Expand All @@ -23,8 +27,8 @@
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<DefineConstants>$(DefineConstants);WINDOWS_UWP</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' OR '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="System.Threading.Thread" Version="4.0.0" />
<PackageReference Include="System.Diagnostics.Process" Version="4.1.0" />
<PackageReference Include="System.Diagnostics.TextWriterTraceListener" Version="4.0.0" />
Expand All @@ -47,9 +51,5 @@
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.3.0" />
</ItemGroup>

<PropertyGroup Label="Configuration">
<RootNamespace>Microsoft.TestPlatform.PlatformAbstractions</RootNamespace>
</PropertyGroup>

<Import Project="$(TestPlatformRoot)scripts\build\TestPlatform.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
{
using System;
using System.Diagnostics;

/// <summary>
/// Wrapper class for tracing.
Expand All @@ -22,48 +23,53 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
/// </summary>
public class PlatformEqtTrace : IPlatformEqtTrace
{
private PlatformTraceLevel traceLevel = PlatformTraceLevel.Off;

public static string ErrorOnInitialization { get; set; }

public bool DoNotInitialize
{
get => throw new NotImplementedException();
set => throw new NotImplementedException();
}
public bool DoNotInitialize { get; set; }

public void WriteLine(PlatformTraceLevel level, string message)
public void WriteLine(PlatformTraceLevel traceLevel, string message)
{
throw new NotImplementedException();
if (!this.ShouldTrace(traceLevel))
{
return;
}

var level = Enum.GetName(typeof(PlatformTraceLevel), traceLevel);
Debug.WriteLine($"[{level}] {message}");
}

public bool InitializeVerboseTrace(string customLogFile)
{
throw new NotImplementedException();
return false;
}

public bool InitializeTrace(string customLogFile, PlatformTraceLevel traceLevel)
{
throw new NotImplementedException();
this.traceLevel = traceLevel;

return false;
}

public bool ShouldTrace(PlatformTraceLevel traceLevel)
{
throw new NotImplementedException();
}
if (this.DoNotInitialize)
{
return false;
}

public string GetLogFile()
{
throw new NotImplementedException();
return (int)this.traceLevel >= (int)traceLevel;
}

public string GetLogFile() => string.Empty;

public void SetTraceLevel(PlatformTraceLevel value)
{
throw new NotImplementedException();
this.traceLevel = value;
}

public PlatformTraceLevel GetTraceLevel()
{
throw new NotImplementedException();
}
public PlatformTraceLevel GetTraceLevel() => this.traceLevel;
}
}

Expand Down
21 changes: 18 additions & 3 deletions src/package/nuspec/TestPlatform.TestHost.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
<dependency id="Newtonsoft.Json" version="$JsonNetVersion$"/>
<dependency id="System.Diagnostics.StackTrace" version="[4.3.0, )"/>
<dependency id="System.Diagnostics.TraceSource" version="[4.3.0, )"/>

<dependency id="System.Threading.Thread" version="[4.0.0, )" />
<dependency id="System.Diagnostics.Process" version="[4.1.0, )" />
<dependency id="System.Diagnostics.TextWriterTraceListener" version="[4.0.0, )" />
<dependency id="System.Runtime.InteropServices.RuntimeInformation" version="[4.0.0, )" />
<dependency id="System.Runtime.Loader" version="[4.0.0, )" />

</group>

<group targetFramework="netcoreapp2.1">
Expand Down Expand Up @@ -48,11 +55,15 @@
<file src="Microsoft.TestPlatform.TestHost\netcoreapp1.0\testhost.deps.json" target="lib\netcoreapp1.0\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp1.0\x86\msdia140.dll" target="lib\netcoreapp1.0\x86\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp1.0\x64\msdia140.dll" target="lib\netcoreapp1.0\x64\" />


<file src="Microsoft.TestPlatform.TestHost\netcoreapp1.0\win7-x64\*" target="build\netcoreapp1.0\x64" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp1.0\win7-x86\*" target="build\netcoreapp1.0\x86\" />
<!--
<file src="Microsoft.TestPlatform.TestHost\netcoreapp1.0\win7-x64\testhost.dll" target="build\netcoreapp1.0\x64" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp1.0\win7-x64\testhost.exe" target="build\netcoreapp1.0\x64" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp1.0\win7-x86\testhost.x86.dll" target="build\netcoreapp1.0\x86\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp1.0\win7-x86\testhost.x86.exe" target="build\netcoreapp1.0\x86\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp1.0\win7-x86\testhost.x86.exe" target="build\netcoreapp1.0\x86\" />
-->

<file src="Microsoft.TestPlatform.TestHost\netcoreapp1.0\Microsoft.TestPlatform.TestHost.props" target="build\netcoreapp1.0\" />

Expand All @@ -66,10 +77,14 @@
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\x86\msdia140.dll" target="lib\netcoreapp2.1\x86\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\x64\msdia140.dll" target="lib\netcoreapp2.1\x64\" />

<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x64\*" target="build\netcoreapp2.1\x64" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x86\*" target="build\netcoreapp2.1\x86\" />
<!--
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x64\testhost.dll" target="build\netcoreapp2.1\x64" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x64\testhost.exe" target="build\netcoreapp2.1\x64" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x86\testhost.x86.dll" target="build\netcoreapp2.1\x86\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x86\testhost.x86.exe" target="build\netcoreapp2.1\x86\" />
<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\win7-x86\testhost.x86.exe" target="build\netcoreapp2.1\x86\" />
-->

<file src="Microsoft.TestPlatform.TestHost\netcoreapp2.1\Microsoft.TestPlatform.TestHost.props" target="build\netcoreapp2.1\" />

Expand Down
7 changes: 5 additions & 2 deletions src/testhost.x86/TestHostTraceListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ public static void Setup()
// Debug.Assert fails. This method is internal, but the class is on purpose keeping the
// callback settable so tests can set the callback
var field = typeof(Debug).GetField("s_ShowDialog", BindingFlags.Static | BindingFlags.NonPublic);
var value = field.GetValue(null);
field.SetValue(null, (Action<string, string, string, string>)ShowDialog);
if (field != null)
{
var value = field.GetValue(null);
field.SetValue(null, (Action<string, string, string, string>)ShowDialog);
}
}
catch (Exception ex)
{
Expand Down
2 changes: 2 additions & 0 deletions src/testhost.x86/testhost.x86.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<Prefer32Bit>true</Prefer32Bit>
<OutputType>Exe</OutputType>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1' AND '$(TargetFramework)' != 'netcoreapp1.0'">
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,28 @@
<AssemblyName>Microsoft.TestPlatform.AcceptanceTests</AssemblyName>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.TestPlatform.Extensions.HtmlLogger\Microsoft.TestPlatform.Extensions.HtmlLogger.csproj" />
<ProjectReference Include="..\Microsoft.TestPlatform.TestUtilities\Microsoft.TestPlatform.TestUtilities.csproj" />
<PackageReference Include="Chutzpah">
<Version>$(ChutzpahAdapterVersion)</Version>
</PackageReference>
<PackageReference Include="Microsoft.TestPlatform.TestAsset.NativeCPP">
<Version>2.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.TestPlatform.QTools.Assets">
<Version>2.0.0</Version>
</PackageReference>
<Folder Include="TestAssets\CodeCoverageTest\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(TestPlatformRoot)src\Microsoft.TestPlatform.Extensions.HtmlLogger\Microsoft.TestPlatform.Extensions.HtmlLogger.csproj" />
<ProjectReference Include="$(TestPlatformRoot)test\Microsoft.TestPlatform.TestUtilities\Microsoft.TestPlatform.TestUtilities.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Chutzpah" Version="$(ChutzpahAdapterVersion)" />
<PackageReference Include="Microsoft.TestPlatform.TestAsset.NativeCPP" Version="2.0.0" />
<PackageReference Include="Microsoft.TestPlatform.QTools.Assets" Version="2.0.0" />
<PackageReference Include="Procdump" Version="0.0.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<PackageReference Include="Microsoft.Internal.CodeCoverage" Version="$(CodeCoverageExternalsVersion)" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0-preview2-26406-04" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System" />
<Reference Include="System.Runtime" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Reflection" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<PackageReference Include="Microsoft.Internal.CodeCoverage" Version="$(CodeCoverageExternalsVersion)" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0-preview2-26406-04" />
</ItemGroup>
<ItemGroup>
<Folder Include="TestAssets\CodeCoverageTest\" />
</ItemGroup>
<Import Project="$(TestPlatformRoot)scripts\build\TestPlatform.targets" />
</Project>

0 comments on commit 2035b97

Please sign in to comment.