From 83c59815fba74e359432d9c3a13243cb75dfc399 Mon Sep 17 00:00:00 2001 From: Jayarani garg Date: Wed, 28 Feb 2018 19:05:55 +0530 Subject: [PATCH] [Symbol archiving]Converting Portable pdb to full (#375) * COnverting portable pdbs to full for Symbol archiving * Fixing nuget package path * Test fix * Indent fix --- Nuget.config | 1 + scripts/PortableToFullPdb.ps1 | 70 +++++++++++++++++++ scripts/toolset/packages.config | 1 + .../Execution/TestExecutionManagerTests.cs | 8 +-- 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 scripts/PortableToFullPdb.ps1 diff --git a/Nuget.config b/Nuget.config index 328214c5c9..57644a2b47 100644 --- a/Nuget.config +++ b/Nuget.config @@ -7,6 +7,7 @@ + diff --git a/scripts/PortableToFullPdb.ps1 b/scripts/PortableToFullPdb.ps1 new file mode 100644 index 0000000000..e62263a3b2 --- /dev/null +++ b/scripts/PortableToFullPdb.ps1 @@ -0,0 +1,70 @@ +# Copyright (c) Microsoft. All rights reserved. +# Portable to Full PDB conversion script for Test Platform. + +[CmdletBinding()] +Param( + [Parameter(Mandatory=$false)] + [ValidateSet("Debug", "Release")] + [System.String] $Configuration = "Release" +) + +# +# Variables +# +Write-Verbose "Setup environment variables." +$TF_ROOT_DIR = (Get-Item (Split-Path $MyInvocation.MyCommand.Path)).Parent.FullName +$TF_PACKAGES_DIR = Join-Path $TF_ROOT_DIR "packages" +$TF_OUT_DIR = Join-Path $TF_ROOT_DIR "artifacts" +$TF_PortablePdbs =@("PlatformServices.NetCore\netstandard1.5\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.pdb") + +$PdbConverterToolVersion = "1.1.0-beta1-62316-01" + +function Locate-PdbConverterTool +{ + $pdbConverter = Join-Path -path $TF_PACKAGES_DIR -ChildPath "Pdb2Pdb.$PdbConverterToolVersion\tools\Pdb2Pdb.exe" + + if (!(Test-Path -path $pdbConverter)) + { + throw "Unable to locate Pdb2Pdb converter exe in path '$pdbConverter'." + } + + Write-Verbose "Pdb2Pdb converter path is : $pdbConverter" + return $pdbConverter + +} + +function ConvertPortablePdbToWindowsPdb +{ + foreach($TF_PortablePdb in $TF_PortablePdbs) + { + $portablePdbs += Join-Path -path $TF_OUT_DIR\$Configuration -childPath $TF_PortablePdb + } + + $pdbConverter = Locate-PdbConverterTool + + foreach($portablePdb in $portablePdbs) + { + # First check if corresponding dll exists + $dllOrExePath = $portablePdb -replace ".pdb",".dll" + + if(!(Test-Path -path $dllOrExePath)) + { + # If no corresponding dll found, check if exe exists + $dllOrExePath = $portablePdb -replace ".pdb",".exe" + + if(!(Test-Path -path $dllOrExePath)) + { + throw "Unable to locate dll/exe corresponding to $portablePdb" + } + } + + $fullpdb = $portablePdb -replace ".pdb",".pdbfull" + + Write-Verbose "$pdbConverter $dll /pdb $portablePdb /out $fullpdb" + & $pdbConverter $dllOrExePath /pdb $portablePdb /out $fullpdb + } +} + +Write-Verbose "Converting Portable pdbs to Windows(Full) Pdbs..." +ConvertPortablePdbToWindowsPdb + diff --git a/scripts/toolset/packages.config b/scripts/toolset/packages.config index e7aa7c09f6..fb85da1e92 100644 --- a/scripts/toolset/packages.config +++ b/scripts/toolset/packages.config @@ -5,4 +5,5 @@ + \ No newline at end of file diff --git a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs index 601a6d10f8..935c448082 100644 --- a/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs +++ b/test/UnitTests/MSTest.CoreAdapter.Unit.Tests/Execution/TestExecutionManagerTests.cs @@ -148,14 +148,12 @@ public void RunTestsForMultipleTestShouldSendMultipleResults() List expectedTestCaseStartList = new List() { "PassingTest", "FailingTest" }; List expectedTestCaseEndList = new List() { "PassingTest:Passed", "FailingTest:Failed" }; - List expectedResultList = new List() { "PassingTest Passed", "FailingTest Failed\r\n Message: (null)" }; + List expectedResultList = new List() { "PassingTest Passed", "FailingTest Failed\r\n Message: Assert.Fail failed." }; CollectionAssert.AreEqual(expectedTestCaseStartList, this.frameworkHandle.TestCaseStartList); CollectionAssert.AreEqual(expectedTestCaseEndList, this.frameworkHandle.TestCaseEndList); - Assert.AreEqual("PassingTest Passed", this.frameworkHandle.ResultsList[0]); - StringAssert.Contains( - this.frameworkHandle.ResultsList[1], - "FailingTest Failed\r\n Message: Assert.Fail failed. \r\n StackTrace:\r\n at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution.TestExecutionManagerTests.DummyTestClass.FailingTest()"); + Assert.AreEqual(expectedResultList[0], this.frameworkHandle.ResultsList[0]); + StringAssert.Contains(this.frameworkHandle.ResultsList[1], expectedResultList[1]); } [TestMethodV1]