Skip to content

Commit f55f5f2

Browse files
authored
Updated TP to 16.9.0-preview-20210129-05. (#765)
- Updated the Test Platform version to 16.9.0-preview-20210129-05. - Refactored the adapter to conform to the new implementation. - Fixed some warnings.
1 parent 948113d commit f55f5f2

File tree

26 files changed

+249
-149
lines changed

26 files changed

+249
-149
lines changed

Nuget.config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
55
<clear />
66
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
7-
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
7+
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
88
<add key="test-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.json" />
9-
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
9+
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
1010
<add key="dotnet3.1" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet3.1/nuget/v3/index.json" />
1111
<add key="dotnet3.1-transport" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet3.1-transport/nuget/v3/index.json" />
1212
<add key="dotnet5" value="https://dnceng.pkgs.visualstudio.com/public/_packaging/dotnet5/nuget/v3/index.json" />
@@ -18,9 +18,9 @@
1818
</activePackageSource>
1919
<config>
2020
<!-- This path is relative as a workaround to https://github.com/NuGet/Home/issues/2831 -->
21-
<!-- <add key="globalPackagesFolder" value="packages" /> -->
21+
<add key="globalPackagesFolder" value="packages" />
2222
<add key="repositoryPath" value="packages" />
23-
23+
2424
<!-- This is a workaround for Azure Artifacts, see: https://github.com/dotnet/arcade/issues/4190, https://github.com/dotnet/core-eng/issues/9681 -->
2525
<add key='maxHttpRequestsPerSource' value='2' />
2626
</config>

scripts/Build.ps1

Lines changed: 102 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Build script for MSTest Test Framework.
55

6-
[CmdletBinding(PositionalBinding=$false)]
6+
[CmdletBinding(PositionalBinding = $false)]
77
Param(
88
[ValidateSet("Debug", "Release")]
99
[Alias("c")]
@@ -18,7 +18,7 @@ Param(
1818
[Alias("vs")]
1919
[string] $VersionSuffix = "dev",
2020

21-
[string] $BuildVersionPrefix = "14.0",
21+
[string] $BuildVersionPrefix = "14.0",
2222

2323
[string] $BuildVersionSuffix = "9999.99",
2424

@@ -47,7 +47,13 @@ Param(
4747
[Switch] $IsLocalizedBuild,
4848

4949
[Alias("tpv")]
50-
[string] $TestPlatformVersion = $null
50+
[string] $TestPlatformVersion = $null,
51+
52+
[Alias("f")]
53+
[Switch] $Force,
54+
55+
[Alias("s")]
56+
[String[]] $Steps = @("UpdateTPVersion", "Restore", "Build", "Publish")
5157
)
5258

5359
. $PSScriptRoot\common.lib.ps1
@@ -73,7 +79,7 @@ $TFB_Solutions = @(
7379
"TestFx.sln"
7480
)
7581

76-
$TFB_NetCoreProjects =@(
82+
$TFB_NetCoreProjects = @(
7783
"src\Adapter\PlatformServices.NetCore\PlatformServices.NetCore.csproj"
7884

7985
"test\ComponentTests\TestAssets\TestProjectForAssemblyResolution\TestProjectForAssemblyResolution.csproj"
@@ -132,8 +138,7 @@ function Perform-Restore {
132138

133139
Write-Log "Perform-Restore: Started."
134140

135-
if($TFB_SkipRestore)
136-
{
141+
if ($TFB_SkipRestore) {
137142
Write-Log "Perform-Restore: Skipped."
138143
return;
139144
}
@@ -159,12 +164,11 @@ function Perform-Restore {
159164
$msbuildPath = Locate-MSBuildPath
160165

161166
Write-Verbose "Starting solution restore..."
162-
foreach($solution in $TFB_Solutions)
163-
{
164-
$solutionPath = Locate-Item -relativePath $solution
167+
foreach ($solution in $TFB_Solutions) {
168+
$solutionPath = Locate-Item -relativePath $solution
165169

166-
Write-Verbose "$nuget restore -msbuildPath $msbuildPath -verbosity quiet -nonInteractive -configFile $nugetConfig $solutionPath"
167-
& $nuget restore -msbuildPath $msbuildPath -verbosity quiet -nonInteractive -configFile $nugetConfig $solutionPath
170+
Write-Verbose "$nuget restore -msbuildPath $msbuildPath -verbosity quiet -nonInteractive -configFile $nugetConfig $solutionPath"
171+
& $nuget restore -msbuildPath $msbuildPath -verbosity quiet -nonInteractive -configFile $nugetConfig $solutionPath
168172
}
169173

170174
if ($lastExitCode -ne 0) {
@@ -174,8 +178,7 @@ function Perform-Restore {
174178
$msbuild = Join-Path $msbuildPath "MSBuild.exe"
175179

176180
Write-Verbose "Starting restore for NetCore Projects"
177-
foreach($project in $TFB_NetCoreProjects)
178-
{
181+
foreach ($project in $TFB_NetCoreProjects) {
179182
$projectPath = Locate-Item -relativePath $project
180183

181184
Write-Verbose "$msbuild /t:restore -verbosity:minimal $projectPath /m"
@@ -197,16 +200,13 @@ function Perform-Build {
197200

198201
Write-Log "Perform-Build: Started."
199202

200-
if($TFB_Clean)
201-
{
203+
if ($TFB_Clean) {
202204
$foldersToDel = @( $TFB_Configuration, "TestAssets" )
203205
Write-Log " Clean build requested."
204-
foreach($folder in $foldersToDel)
205-
{
206+
foreach ($folder in $foldersToDel) {
206207
$outDir = Join-Path $env:TF_OUT_DIR -ChildPath $folder
207-
208-
if(Test-Path $outDir)
209-
{
208+
209+
if (Test-Path $outDir) {
210210
Write-Output " Deleting $outDir"
211211
Remove-Item -Recurse -Force $outDir
212212
}
@@ -218,87 +218,81 @@ function Perform-Build {
218218
Write-Log "Perform-Build: Completed. {$(Get-ElapsedTime($timer))}"
219219
}
220220

221-
function Invoke-Build([string] $solution, $hasVsixExtension = "false")
222-
{
221+
function Invoke-Build([string] $solution, $hasVsixExtension = "false") {
223222
$msbuild = Locate-MSBuild -hasVsixExtension $hasVsixExtension
224-
$solutionPath = Locate-Item -relativePath $solution
223+
$solutionPath = Locate-Item -relativePath $solution
225224
$solutionDir = [System.IO.Path]::GetDirectoryName($solutionPath)
226225
$solutionSummaryLog = Join-Path -path $solutionDir -childPath "msbuild.log"
227226
$solutionWarningLog = Join-Path -path $solutionDir -childPath "msbuild.wrn"
228227
$solutionFailureLog = Join-Path -path $solutionDir -childPath "msbuild.err"
229228

230-
Write-Log " Building $solution..."
231-
Write-Verbose "$msbuild /t:$Target /p:Configuration=$configuration /v:m /flp1:Summary`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionSummaryLog /flp2:WarningsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionWarningLog /flp3:ErrorsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionFailureLog /p:IsLocalizedBuild=$TFB_IsLocalizedBuild /p:UpdateXlf=$TFB_UpdateXlf /p:BuildVersion=$TFB_BuildVersion $solutionPath /bl /m"
232-
& $msbuild /t:$Target /p:Configuration=$configuration /v:m /flp1:Summary`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionSummaryLog /flp2:WarningsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionWarningLog /flp3:ErrorsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionFailureLog /p:IsLocalizedBuild=$TFB_IsLocalizedBuild /p:UpdateXlf=$TFB_UpdateXlf /p:BuildVersion=$TFB_BuildVersion $solutionPath /bl /m
229+
Write-Log " Building $solution..."
230+
Write-Verbose "$msbuild /t:$Target /p:Configuration=$configuration /v:m /flp1:Summary`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionSummaryLog /flp2:WarningsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionWarningLog /flp3:ErrorsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionFailureLog /p:IsLocalizedBuild=$TFB_IsLocalizedBuild /p:UpdateXlf=$TFB_UpdateXlf /p:BuildVersion=$TFB_BuildVersion $solutionPath /bl /m"
231+
& $msbuild /t:$Target /p:Configuration=$configuration /v:m /flp1:Summary`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionSummaryLog /flp2:WarningsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionWarningLog /flp3:ErrorsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$solutionFailureLog /p:IsLocalizedBuild=$TFB_IsLocalizedBuild /p:UpdateXlf=$TFB_UpdateXlf /p:BuildVersion=$TFB_BuildVersion $solutionPath /bl /m
233232

234-
if ($lastExitCode -ne 0) {
235-
throw "Build failed with an exit code of '$lastExitCode'."
236-
}
233+
if ($lastExitCode -ne 0) {
234+
throw "Build failed with an exit code of '$lastExitCode'."
235+
}
237236
}
238237

239238
#
240239
# Creates Fx & Adapter nuget packages
241240
#
242-
function Create-NugetPackages
243-
{
244-
$timer = Start-Timer
241+
function Create-NugetPackages {
242+
$timer = Start-Timer
245243

246-
Write-Log "Create-NugetPackages: Started."
244+
Write-Log "Create-NugetPackages: Started."
247245

248-
$stagingDir = Join-Path $env:TF_OUT_DIR $TFB_Configuration
249-
$packageOutDir = Join-Path $stagingDir "MSTestPackages"
250-
$tfSrcPackageDir = Join-Path $env:TF_SRC_DIR "Package"
246+
$stagingDir = Join-Path $env:TF_OUT_DIR $TFB_Configuration
247+
$packageOutDir = Join-Path $stagingDir "MSTestPackages"
248+
$tfSrcPackageDir = Join-Path $env:TF_SRC_DIR "Package"
251249

252-
# Copy over the nuspecs to the staging directory
253-
if($TFB_Official)
254-
{
255-
$nuspecFiles = @("MSTest.TestAdapter.Dotnet.nuspec", "MSTest.TestAdapter.nuspec", "MSTest.TestAdapter.symbols.nuspec", "MSTest.TestFramework.nuspec", "MSTest.TestFramework.symbols.nuspec", "MSTest.Internal.TestFx.Documentation.nuspec")
256-
}
257-
else
258-
{
259-
$nuspecFiles = @("MSTest.TestAdapter.Enu.nuspec","MSTest.TestFramework.enu.nuspec", "MSTest.TestAdapter.Dotnet.nuspec")
260-
}
250+
# Copy over the nuspecs to the staging directory
251+
if ($TFB_Official) {
252+
$nuspecFiles = @("MSTest.TestAdapter.Dotnet.nuspec", "MSTest.TestAdapter.nuspec", "MSTest.TestAdapter.symbols.nuspec", "MSTest.TestFramework.nuspec", "MSTest.TestFramework.symbols.nuspec", "MSTest.Internal.TestFx.Documentation.nuspec")
253+
}
254+
else {
255+
$nuspecFiles = @("MSTest.TestAdapter.Enu.nuspec", "MSTest.TestFramework.enu.nuspec", "MSTest.TestAdapter.Dotnet.nuspec")
256+
}
261257

262-
foreach ($file in $nuspecFiles) {
263-
Copy-Item $tfSrcPackageDir\$file $stagingDir -Force
264-
}
258+
foreach ($file in $nuspecFiles) {
259+
Copy-Item $tfSrcPackageDir\$file $stagingDir -Force
260+
}
265261

266-
# Copy over LICENSE.txt file to staging directory
267-
$licenseFilePath = Join-Path $env:TF_ROOT_DIR "LICENSE.txt"
268-
Copy-Item $licenseFilePath $stagingDir -Force
262+
# Copy over LICENSE.txt file to staging directory
263+
$licenseFilePath = Join-Path $env:TF_ROOT_DIR "LICENSE.txt"
264+
Copy-Item $licenseFilePath $stagingDir -Force
269265

270-
# Call nuget pack on these components.
271-
$nugetExe = Locate-Nuget
266+
# Call nuget pack on these components.
267+
$nugetExe = Locate-Nuget
272268

273-
foreach ($file in $nuspecFiles) {
274-
$version = $TFB_FrameworkVersion
269+
foreach ($file in $nuspecFiles) {
270+
$version = $TFB_FrameworkVersion
275271

276-
if($file.Contains("TestAdapter"))
277-
{
278-
$version = $TFB_AdapterVersion
279-
}
280-
281-
if(![string]::IsNullOrEmpty($TFB_VersionSuffix))
282-
{
283-
$versionSuffix = $TFB_VersionSuffix -replace "\.","-"
284-
$version = $version + "-" + $versionSuffix
285-
}
286-
287-
Write-Verbose "$nugetExe pack $stagingDir\$file -OutputDirectory $packageOutDir -Version=$version -Properties Version=$version"
288-
& $nugetExe pack $stagingDir\$file -OutputDirectory $packageOutDir -Version $version -Properties Version=$version`;Srcroot=$env:TF_SRC_DIR`;Packagesroot=$env:TF_PACKAGES_DIR
289-
290-
if ($lastExitCode -ne 0) {
291-
throw "Nuget pack failed with an exit code of '$lastExitCode'."
292-
}
272+
if ($file.Contains("TestAdapter")) {
273+
$version = $TFB_AdapterVersion
274+
}
275+
276+
if (![string]::IsNullOrEmpty($TFB_VersionSuffix)) {
277+
$versionSuffix = $TFB_VersionSuffix -replace "\.", "-"
278+
$version = $version + "-" + $versionSuffix
279+
}
280+
281+
Write-Verbose "$nugetExe pack $stagingDir\$file -OutputDirectory $packageOutDir -Version=$version -Properties Version=$version"
282+
& $nugetExe pack $stagingDir\$file -OutputDirectory $packageOutDir -Version $version -Properties Version=$version`;Srcroot=$env:TF_SRC_DIR`;Packagesroot=$env:TF_PACKAGES_DIR
283+
284+
if ($lastExitCode -ne 0) {
285+
throw "Nuget pack failed with an exit code of '$lastExitCode'."
293286
}
287+
}
294288

295-
Write-Log "Create-NugetPackages: Complete. {$(Get-ElapsedTime($timer))}"
289+
Write-Log "Create-NugetPackages: Complete. {$(Get-ElapsedTime($timer))}"
296290
}
297291

298292
function Replace-InFile($File, $RegEx, $ReplaceWith) {
299293
$content = Get-Content -Raw -Encoding utf8 $File
300-
$newContent = ($content -replace $RegEx,$ReplaceWith)
301-
if(-not $content.Equals($newContent)) {
294+
$newContent = ($content -replace $RegEx, $ReplaceWith)
295+
if (-not $content.Equals($newContent)) {
302296
Write-Log "Updating TestPlatform version in $File"
303297
$newContent | Set-Content -Encoding utf8 $File -NoNewline
304298
}
@@ -313,19 +307,46 @@ function Sync-PackageVersions {
313307

314308
if ([String]::IsNullOrWhiteSpace($TestPlatformVersion)) {
315309
$TestPlatformVersion = (([XML](Get-Content $versionsFile)).Project.PropertyGroup.TestPlatformVersion).InnerText
316-
} else {
310+
}
311+
else {
317312
Replace-InFile -File $versionsFile -RegEx $versionsRegex -ReplaceWith "<`$1>$TestPlatformVersion</TestPlatformVersion>"
318313
}
319314

320-
(Get-ChildItem "$PSScriptRoot\..\src\*packages.config","$PSScriptRoot\..\test\*packages.config" -Recurse) | ForEach-Object {
315+
(Get-ChildItem "$PSScriptRoot\..\src\*packages.config", "$PSScriptRoot\..\test\*packages.config" -Recurse) | ForEach-Object {
321316
Replace-InFile -File $_ -RegEx $packageRegex -ReplaceWith ('<package id="Microsoft.TestPlatform$1" version="{0}"' -f $TestPlatformVersion)
322317
}
323318

324319
Replace-InFile -File "$PSScriptRoot\..\test\E2ETests\Automation.CLI\CLITestBase.cs" -RegEx $sourceRegex -ReplaceWith ('$1Microsoft.TestPlatform.{0}";' -f $TestPlatformVersion)
325320
}
326321

322+
function ShouldRunStep([string[]]$CurrentSteps) {
323+
if ($Force) {
324+
return $true
325+
}
326+
327+
foreach ($step in $CurrentSteps) {
328+
if ($Steps -contains $step) {
329+
return $true
330+
}
331+
}
332+
333+
return $false
334+
}
335+
327336
Print-Help
328-
Sync-PackageVersions
329-
Perform-Restore
330-
Perform-Build
331-
Create-NugetPackages
337+
338+
if (ShouldRunStep @("UpdateTPVersion")) {
339+
Sync-PackageVersions
340+
}
341+
342+
if (ShouldRunStep @("UpdateTPVersion", "Restore")) {
343+
Perform-Restore
344+
}
345+
346+
if (ShouldRunStep @("Build")) {
347+
Perform-Build
348+
}
349+
350+
if (ShouldRunStep @("Publish")) {
351+
Create-NugetPackages
352+
}

scripts/build/TestFx.Versions.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<TestPlatformVersion Condition=" '$(TestPlatformVersion)' == '' ">16.9.0-preview-20201215-01</TestPlatformVersion>
4+
<TestPlatformVersion Condition=" '$(TestPlatformVersion)' == '' ">16.9.0-preview-20210129-05</TestPlatformVersion>
55
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
66
</PropertyGroup>
77
</Project>

src/Adapter/MSTest.CoreAdapter/Extensions/TestCaseExtensions.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,35 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Extensions
55
{
66
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel;
77
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
8+
89
using Constants = Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Constants;
10+
using ManagedNameUtilities = Microsoft.TestPlatform.AdapterUtilities.ManagedNameUtilities;
911

1012
/// <summary>
1113
/// Extension Methods for TestCase Class
1214
/// </summary>
1315
internal static class TestCaseExtensions
1416
{
17+
internal static readonly TestProperty ManagedTypeProperty = TestProperty.Register(
18+
id: ManagedNameUtilities.Contants.ManagedTypePropertyId,
19+
label: ManagedNameUtilities.Contants.ManagedTypeLabel,
20+
category: string.Empty,
21+
description: string.Empty,
22+
valueType: typeof(string),
23+
validateValueCallback: o => !string.IsNullOrWhiteSpace(o as string),
24+
attributes: TestPropertyAttributes.Hidden,
25+
owner: typeof(TestCase));
26+
27+
internal static readonly TestProperty ManagedMethodProperty = TestProperty.Register(
28+
id: ManagedNameUtilities.Contants.ManagedMethodPropertyId,
29+
label: ManagedNameUtilities.Contants.ManagedMethodLabel,
30+
category: string.Empty,
31+
description: string.Empty,
32+
valueType: typeof(string),
33+
validateValueCallback: o => !string.IsNullOrWhiteSpace(o as string),
34+
attributes: TestPropertyAttributes.Hidden,
35+
owner: typeof(TestCase));
36+
1537
/// <summary>
1638
/// The to unit test element.
1739
/// </summary>
@@ -48,5 +70,15 @@ internal static UnitTestElement ToUnitTestElement(this TestCase testCase, string
4870

4971
return testElement;
5072
}
73+
74+
internal static string GetManagedType(this TestCase testCase) => testCase.GetPropertyValue<string>(ManagedTypeProperty, null);
75+
76+
internal static void SetManagedType(this TestCase testCase, string value) => testCase.SetPropertyValue<string>(ManagedTypeProperty, value);
77+
78+
internal static string GetManagedMethod(this TestCase testCase) => testCase.GetPropertyValue<string>(ManagedMethodProperty, null);
79+
80+
internal static void SetManagedMethod(this TestCase testCase, string value) => testCase.SetPropertyValue<string>(ManagedMethodProperty, value);
81+
82+
internal static bool ContainsManagedMethodAndType(this TestCase testCase) => !string.IsNullOrWhiteSpace(testCase.GetManagedMethod()) && !string.IsNullOrWhiteSpace(testCase.GetManagedType());
5183
}
5284
}

src/Adapter/MSTest.CoreAdapter/MSTest.CoreAdapter.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
</EmbeddedResource>
127127
</ItemGroup>
128128
<ItemGroup>
129+
<PackageReference Include="Microsoft.TestPlatform.AdapterUtilities" Version="$(TestPlatformVersion)" />
129130
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="$(TestPlatformVersion)" />
130131
<PackageReference Include="MicroBuild.Core" Version="0.2.0" PrivateAssets="all">
131132
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -138,7 +139,7 @@
138139
<PropertyGroup>
139140
<SourcePath>$(ProjectDir)..\Build</SourcePath>
140141
<PostBuildEvent>
141-
xcopy /Y /I /S /E "$(SourcePath)" "$(OutDir)..\Build"
142-
</PostBuildEvent>
142+
xcopy /Y /I /S /E "$(SourcePath)" "$(OutDir)..\Build"
143+
</PostBuildEvent>
143144
</PropertyGroup>
144145
</Project>

0 commit comments

Comments
 (0)