From faa2783a7d5ce625eb2a63e2d1fa7d8c4101612f Mon Sep 17 00:00:00 2001 From: fhnaseer Date: Wed, 16 Dec 2020 15:50:54 +0100 Subject: [PATCH] Getting TraceDataCollector from nuget (#2678) * Removing TraceDataCollector project, * Getting tracedatacollector from nuget, * Removing signing of codecoverage libs as they are already signed, updating codecoverage version, * fixing path to tracedatacollector, * Fixing acceptance tests, Co-authored-by: faisal --- TestPlatform.sln | 30 - scripts/build.ps1 | 39 +- scripts/build/TestPlatform.Dependencies.props | 2 +- scripts/test.ps1 | 2 +- scripts/verify-nupkgs.ps1 | 4 +- .../TraceDataCollector/BaseDataCollector.cs | 76 -- ...DataCollectionEnvironmentContextWrapper.cs | 23 - .../DataCollectionEventsWrapper.cs | 47 - .../DataCollectionLoggerWrapper.cs | 43 - .../DataCollectionSinkWrapper.cs | 48 - .../Interfaces/IDataCollectionAgentContext.cs | 16 - .../Interfaces/IDataCollectionEvents.cs | 23 - .../Interfaces/IDataCollectionLogger.cs | 23 - .../Interfaces/IDataCollectionSink.cs | 23 - .../TraceDataCollector/DirectoryHelper.cs | 30 - .../TraceDataCollector/FileHelper.cs | 24 - .../TraceDataCollector/Friends.cs | 8 - .../Interfaces/IDirectoryHelper.cs | 32 - .../Interfaces/IEnvironment.cs | 16 - .../Interfaces/IFileHelper.cs | 29 - .../Interfaces/IProcessJobObject.cs | 22 - .../Interfaces/PlatformOperationSystem.cs | 14 - ...oft.VisualStudio.TraceDataCollector.csproj | 51 - .../TraceDataCollector/PlatformEnvironment.cs | 26 - .../TraceDataCollector/ProcessJobObject.cs | 875 ------------------ .../Properties/AssemblyInfo.cs | 27 - .../Resources/Resources.Designer.cs | 118 --- .../Resources/Resources.resx | 138 --- .../Resources/xlf/Resources.cs.xlf | 55 -- .../Resources/xlf/Resources.de.xlf | 55 -- .../Resources/xlf/Resources.es.xlf | 55 -- .../Resources/xlf/Resources.fr.xlf | 55 -- .../Resources/xlf/Resources.it.xlf | 55 -- .../Resources/xlf/Resources.ja.xlf | 55 -- .../Resources/xlf/Resources.ko.xlf | 55 -- .../Resources/xlf/Resources.pl.xlf | 55 -- .../Resources/xlf/Resources.pt-BR.xlf | 55 -- .../Resources/xlf/Resources.ru.xlf | 55 -- .../Resources/xlf/Resources.tr.xlf | 55 -- .../Resources/xlf/Resources.xlf | 37 - .../Resources/xlf/Resources.zh-Hans.xlf | 55 -- .../Resources/xlf/Resources.zh-Hant.xlf | 55 -- .../DefaultCodeCoverageConfig.xml | 77 -- .../DynamicCoverageDataCollector.cs | 259 ------ .../DynamicCoverageDataCollectorImpl.cs | 392 -------- .../IDynamicCoverageDataCollectorImpl.cs | 30 - .../Interfaces/IProfilersLocationProvider.cs | 59 -- .../VanguardCollector/Interfaces/IVanguard.cs | 38 - .../Interfaces/IVanguardCommandBuilder.cs | 25 - .../Interfaces/VanguardCommand.cs | 21 - .../ProfilersLocationProvider.cs | 108 --- .../VanguardCollector/Vanguard.cs | 373 -------- .../VanguardCommandBuilder.cs | 47 - .../VanguardCollector/VanguardException.cs | 23 - .../nuspec/Microsoft.CodeCoverage.nuspec | 28 +- .../nuspec/Microsoft.TestPlatform.nuspec | 15 +- src/package/sign/sign.proj | 14 - .../DefaultCodeCoverageConfig.xml | 74 -- .../DynamicCoverageDataCollectorImplTests.cs | 489 ---------- .../DynamicCoverageDataCollectorTests.cs | 412 --------- ...atform.TraceDataCollector.UnitTests.csproj | 30 - .../ProfilersLocationProviderTests.cs | 119 --- .../TraceDataCollector.UnitTests/Program.cs | 14 - .../Properties/AssemblyInfo.cs | 21 - .../VanguardCommandBuilderTests.cs | 50 - .../VanguardTests.cs | 204 ---- .../CodeCoverageTests.cs | 2 +- 67 files changed, 50 insertions(+), 5435 deletions(-) delete mode 100644 src/DataCollectors/TraceDataCollector/BaseDataCollector.cs delete mode 100644 src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionEnvironmentContextWrapper.cs delete mode 100644 src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionEventsWrapper.cs delete mode 100644 src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionLoggerWrapper.cs delete mode 100644 src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionSinkWrapper.cs delete mode 100644 src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionAgentContext.cs delete mode 100644 src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionEvents.cs delete mode 100644 src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionLogger.cs delete mode 100644 src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionSink.cs delete mode 100644 src/DataCollectors/TraceDataCollector/DirectoryHelper.cs delete mode 100644 src/DataCollectors/TraceDataCollector/FileHelper.cs delete mode 100644 src/DataCollectors/TraceDataCollector/Friends.cs delete mode 100644 src/DataCollectors/TraceDataCollector/Interfaces/IDirectoryHelper.cs delete mode 100644 src/DataCollectors/TraceDataCollector/Interfaces/IEnvironment.cs delete mode 100644 src/DataCollectors/TraceDataCollector/Interfaces/IFileHelper.cs delete mode 100644 src/DataCollectors/TraceDataCollector/Interfaces/IProcessJobObject.cs delete mode 100644 src/DataCollectors/TraceDataCollector/Interfaces/PlatformOperationSystem.cs delete mode 100644 src/DataCollectors/TraceDataCollector/Microsoft.VisualStudio.TraceDataCollector.csproj delete mode 100644 src/DataCollectors/TraceDataCollector/PlatformEnvironment.cs delete mode 100644 src/DataCollectors/TraceDataCollector/ProcessJobObject.cs delete mode 100644 src/DataCollectors/TraceDataCollector/Properties/AssemblyInfo.cs delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/Resources.Designer.cs delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/Resources.resx delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.cs.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.de.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.es.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.fr.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.it.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ja.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ko.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.pl.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.pt-BR.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ru.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.tr.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.zh-Hans.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.zh-Hant.xlf delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/DefaultCodeCoverageConfig.xml delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollector.cs delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollectorImpl.cs delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IDynamicCoverageDataCollectorImpl.cs delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IProfilersLocationProvider.cs delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IVanguard.cs delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IVanguardCommandBuilder.cs delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/VanguardCommand.cs delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/ProfilersLocationProvider.cs delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/Vanguard.cs delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/VanguardCommandBuilder.cs delete mode 100644 src/DataCollectors/TraceDataCollector/VanguardCollector/VanguardException.cs delete mode 100644 test/DataCollectors/TraceDataCollector.UnitTests/DefaultCodeCoverageConfig.xml delete mode 100644 test/DataCollectors/TraceDataCollector.UnitTests/DynamicCoverageDataCollectorImplTests.cs delete mode 100644 test/DataCollectors/TraceDataCollector.UnitTests/DynamicCoverageDataCollectorTests.cs delete mode 100644 test/DataCollectors/TraceDataCollector.UnitTests/Microsoft.TestPlatform.TraceDataCollector.UnitTests.csproj delete mode 100644 test/DataCollectors/TraceDataCollector.UnitTests/ProfilersLocationProviderTests.cs delete mode 100644 test/DataCollectors/TraceDataCollector.UnitTests/Program.cs delete mode 100644 test/DataCollectors/TraceDataCollector.UnitTests/Properties/AssemblyInfo.cs delete mode 100644 test/DataCollectors/TraceDataCollector.UnitTests/VanguardCommandBuilderTests.cs delete mode 100644 test/DataCollectors/TraceDataCollector.UnitTests/VanguardTests.cs diff --git a/TestPlatform.sln b/TestPlatform.sln index 4150d781ae..9d14b72dc8 100644 --- a/TestPlatform.sln +++ b/TestPlatform.sln @@ -142,10 +142,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "vstest.console.PlatformTest EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.Common.PlatformTests", "test\Microsoft.TestPlatform.Common.PlatformTests\Microsoft.TestPlatform.Common.PlatformTests.csproj", "{24C7683D-2607-4901-B8EB-83A57E49E93D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.TraceDataCollector", "src\DataCollectors\TraceDataCollector\Microsoft.VisualStudio.TraceDataCollector.csproj", "{32BD96BD-16FB-43F0-B952-E7EEDB6DD813}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.TestPlatform.TraceDataCollector.UnitTests", "test\DataCollectors\TraceDataCollector.UnitTests\Microsoft.TestPlatform.TraceDataCollector.UnitTests.csproj", "{A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SettingsMigrator", "src\SettingsMigrator\SettingsMigrator.csproj", "{69F5FF81-5615-4F06-B83C-FCF979BB84CA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SettingsMigrator.UnitTests", "test\SettingsMigrator.UnitTests\SettingsMigrator.UnitTests.csproj", "{E7D4921C-F12D-4E1C-85AC-8B7F91C59B0E}" @@ -696,30 +692,6 @@ Global {24C7683D-2607-4901-B8EB-83A57E49E93D}.Release|x64.Build.0 = Release|Any CPU {24C7683D-2607-4901-B8EB-83A57E49E93D}.Release|x86.ActiveCfg = Release|Any CPU {24C7683D-2607-4901-B8EB-83A57E49E93D}.Release|x86.Build.0 = Release|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Debug|Any CPU.Build.0 = Debug|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Debug|x64.ActiveCfg = Debug|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Debug|x64.Build.0 = Debug|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Debug|x86.ActiveCfg = Debug|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Debug|x86.Build.0 = Debug|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Release|Any CPU.ActiveCfg = Release|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Release|Any CPU.Build.0 = Release|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Release|x64.ActiveCfg = Release|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Release|x64.Build.0 = Release|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Release|x86.ActiveCfg = Release|Any CPU - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813}.Release|x86.Build.0 = Release|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Debug|x64.ActiveCfg = Debug|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Debug|x64.Build.0 = Debug|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Debug|x86.ActiveCfg = Debug|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Debug|x86.Build.0 = Debug|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Release|Any CPU.Build.0 = Release|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Release|x64.ActiveCfg = Release|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Release|x64.Build.0 = Release|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Release|x86.ActiveCfg = Release|Any CPU - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3}.Release|x86.Build.0 = Release|Any CPU {69F5FF81-5615-4F06-B83C-FCF979BB84CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {69F5FF81-5615-4F06-B83C-FCF979BB84CA}.Debug|Any CPU.Build.0 = Debug|Any CPU {69F5FF81-5615-4F06-B83C-FCF979BB84CA}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -853,8 +825,6 @@ Global {0D4DF78D-7E5F-4516-B19F-E6AA71A1DBF4} = {EE49F5DC-5835-4AE3-B3BA-8BDE0AD56330} {8C068694-23A2-47A2-A0DD-DB82D0AF0142} = {376C19DE-31E2-4FF6-88FC-0D0D6233C999} {24C7683D-2607-4901-B8EB-83A57E49E93D} = {376C19DE-31E2-4FF6-88FC-0D0D6233C999} - {32BD96BD-16FB-43F0-B952-E7EEDB6DD813} = {B705537C-B82C-4A30-AFA5-6244D9A7DAEB} - {A7E2261B-B2E6-4CBF-983F-E3A3FF8E52E3} = {D9A30E32-D466-4EC5-B4F2-62E17562279B} {69F5FF81-5615-4F06-B83C-FCF979BB84CA} = {ED0C35EB-7F31-4841-A24F-8EB708FFA959} {E7D4921C-F12D-4E1C-85AC-8B7F91C59B0E} = {B27FAFDF-2DBA-4AB0-BA85-FD5F21D359D6} {236A71E3-01DA-4679-9DFF-16A8E079ACFF} = {5E7F18A8-F843-4C8A-AB02-4C7D9205C6CF} diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 7e26bb4637..fb08b7064c 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -568,17 +568,6 @@ function Publish-Package } Copy-Item -Recurse $intellitraceSourceDirectory\* $intellitraceTargetDirectory -Force - - # Copy Microsoft.VisualStudio.TraceDataCollector - $codeCoverageExternalsVersion = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.CodeCoverageExternalsVersion - $traceDataCollectorSourceDirectory = Join-Path $env:TP_PACKAGES_DIR "Microsoft.VisualStudio.TraceDataCollector\$codeCoverageExternalsVersion\lib" - $traceDataCollectorTargetDirectory = Join-Path $env:TP_OUT_DIR "$TPB_Configuration\Microsoft.VisualStudio.TraceDataCollector" - - if (-not (Test-Path $traceDataCollectorTargetDirectory)) { - New-Item $traceDataCollectorTargetDirectory -Type Directory -Force | Out-Null - } - - Copy-Item -Recurse $traceDataCollectorSourceDirectory\* $traceDataCollectorTargetDirectory -Force # Copy Microsoft.VisualStudio.Telemetry APIs $testPlatformDirectory = Join-Path $env:TP_OUT_DIR "$TPB_Configuration\Intellitrace\Common7\IDE\Extensions\TestPlatform" @@ -699,8 +688,11 @@ function Create-VsixPackage $codeCoverageExternalsVersion = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.CodeCoverageExternalsVersion # Copy Microsoft.VisualStudio.TraceDataCollector to Extensions - $traceDataCollectorSourceDirectory = Join-Path $env:TP_PACKAGES_DIR "Microsoft.VisualStudio.TraceDataCollector\$codeCoverageExternalsVersion\lib\net472" - Copy-Item $traceDataCollectorSourceDirectory\Microsoft.VisualStudio.TraceDataCollector.dll $extensionsPackageDir -Force + $traceDataCollectorPackageDirectory = Join-Path $env:TP_PACKAGES_DIR "Microsoft.VisualStudio.TraceDataCollector\$codeCoverageExternalsVersion\lib\$TPB_TargetFramework472" + Copy-Item $traceDataCollectorPackageDirectory\Microsoft.VisualStudio.TraceDataCollector.dll $extensionsPackageDir -Force + if($TPB_LocalizedBuild) { + Copy-Loc-Files $traceDataCollectorPackageDirectory $extensionsPackageDir "Microsoft.VisualStudio.TraceDataCollector.resources.dll" + } # Copy legacy dependencies $legacyDir = Join-Path $env:TP_PACKAGES_DIR "Microsoft.Internal.TestPlatform.Extensions\$testPlatformExternalsVersion\contentFiles\any\any" @@ -825,6 +817,8 @@ function Create-NugetPackages # Additional external dependency folders $microsoftFakesVersion = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.MicrosoftFakesVersion $FakesPackageDir = Join-Path $env:TP_PACKAGES_DIR "Microsoft.QualityTools.Testing.Fakes.TestRunnerHarness\$microsoftFakesVersion\contentFiles" + $codeCoverageExternalsVersion = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.CodeCoverageExternalsVersion + $TraceDataCollectorPackagesDir = Join-Path $env:TP_PACKAGES_DIR "microsoft.visualstudio.tracedatacollector\$codeCoverageExternalsVersion\lib" # package them from stagingDir foreach ($file in $nuspecFiles) { @@ -834,7 +828,7 @@ function Create-NugetPackages } Write-Verbose "$nugetExe pack $stagingDir\$file -OutputDirectory $packageOutputDir -Version $TPB_Version -Properties Version=$TPB_Version $additionalArgs" - & $nugetExe pack $stagingDir\$file -OutputDirectory $packageOutputDir -Version $TPB_Version -Properties Version=$TPB_Version`;JsonNetVersion=$JsonNetVersion`;Runtime=$TPB_TargetRuntime`;NetCoreTargetFramework=$TPB_TargetFrameworkCore20`;FakesPackageDir=$FakesPackageDir`;NetStandard10Framework=$TPB_TargetFrameworkNS10`;NetStandard13Framework=$TPB_TargetFrameworkNS13`;NetStandard20Framework=$TPB_TargetFrameworkNS20`;Uap10Framework=$testhostUapPackageDir $additionalArgs + & $nugetExe pack $stagingDir\$file -OutputDirectory $packageOutputDir -Version $TPB_Version -Properties Version=$TPB_Version`;JsonNetVersion=$JsonNetVersion`;Runtime=$TPB_TargetRuntime`;NetCoreTargetFramework=$TPB_TargetFrameworkCore20`;FakesPackageDir=$FakesPackageDir`;TraceDataCollectorPackagesDir=$TraceDataCollectorPackagesDir`;NetStandard10Framework=$TPB_TargetFrameworkNS10`;NetStandard13Framework=$TPB_TargetFrameworkNS13`;NetStandard20Framework=$TPB_TargetFrameworkNS20`;Uap10Framework=$testhostUapPackageDir $additionalArgs Set-ScriptFailedOnError } @@ -849,21 +843,22 @@ function Create-NugetPackages function Copy-CodeCoverage-Package-Artifacts { # Copy TraceDataCollector to Microsoft.CodeCoverage folder. + $codeCoverageExternalsVersion = ([xml](Get-Content $env:TP_ROOT_DIR\scripts\build\TestPlatform.Dependencies.props)).Project.PropertyGroup.CodeCoverageExternalsVersion + $traceDataCollectorPackagesDir = Join-Path $env:TP_PACKAGES_DIR "microsoft.visualstudio.tracedatacollector\$codeCoverageExternalsVersion\lib\$TPB_TargetFrameworkNS20" + $internalCodeCoveragePackagesDir = Join-Path $env:TP_PACKAGES_DIR "microsoft.internal.codecoverage\$codeCoverageExternalsVersion\contentFiles\any\any\" + $microsoftCodeCoveragePackageDir = $(Join-Path $env:TP_OUT_DIR "$TPB_Configuration\Microsoft.CodeCoverage\") New-Item -ItemType directory -Path $microsoftCodeCoveragePackageDir -Force | Out-Null - $traceDataCollectorOutDir = Join-Path $env:TP_ROOT_DIR "src\DataCollectors\TraceDataCollector\bin\$TPB_Configuration\$TPB_TargetFrameworkNS20" - - Copy-Item $traceDataCollectorOutDir\Microsoft.VisualStudio.TraceDataCollector.dll $microsoftCodeCoveragePackageDir -Force - Copy-Item $traceDataCollectorOutDir\Microsoft.VisualStudio.TraceDataCollector.pdb $microsoftCodeCoveragePackageDir -Force - Copy-Item $traceDataCollectorOutDir\CodeCoverage $microsoftCodeCoveragePackageDir -Force -Recurse - Copy-Item $traceDataCollectorOutDir\Shim $microsoftCodeCoveragePackageDir -Force -Recurse + Copy-Item $traceDataCollectorPackagesDir\Microsoft.VisualStudio.TraceDataCollector.dll $microsoftCodeCoveragePackageDir -Force + Copy-Item $traceDataCollectorPackagesDir\Microsoft.VisualStudio.TraceDataCollector.pdb $microsoftCodeCoveragePackageDir -Force + Copy-Item $internalCodeCoveragePackagesDir\CodeCoverage $microsoftCodeCoveragePackageDir -Force -Recurse + Copy-Item $internalCodeCoveragePackagesDir\Shim $microsoftCodeCoveragePackageDir -Force -Recurse # Copy TraceDataCollector resource dlls if($TPB_LocalizedBuild) { - Copy-Loc-Files $traceDataCollectorOutDir $microsoftCodeCoveragePackageDir "Microsoft.VisualStudio.TraceDataCollector.resources.dll" - Copy-Loc-Files $traceDataCollectorOutDir $microsoftCodeCoveragePackageDir "Microsoft.VisualStudio.TraceDataCollector.resources.dll" + Copy-Loc-Files $traceDataCollectorPackagesDir $microsoftCodeCoveragePackageDir "Microsoft.VisualStudio.TraceDataCollector.resources.dll" } } diff --git a/scripts/build/TestPlatform.Dependencies.props b/scripts/build/TestPlatform.Dependencies.props index 986afff988..9a09bf8876 100644 --- a/scripts/build/TestPlatform.Dependencies.props +++ b/scripts/build/TestPlatform.Dependencies.props @@ -32,7 +32,7 @@ 9.0.1 4.7.63 16.9.0-preview-4267359 - 16.9.0-beta.20603.1 + 16.9.0-beta.20616.2 16.9.0-beta.20602.2 16.0.461 diff --git a/scripts/test.ps1 b/scripts/test.ps1 index ed2bea934b..576849ddf3 100644 --- a/scripts/test.ps1 +++ b/scripts/test.ps1 @@ -111,7 +111,7 @@ $Script:TPT_TestResultsDir = Join-Path $env:TP_ROOT_DIR "TestResults" $Script:TPT_DefaultTrxFileName = "TrxLogResults.trx" $Script:TPT_ErrorMsgColor = "Red" $Script:TPT_RunSettingsFile = Join-Path (Get-Item (Split-Path $MyInvocation.MyCommand.Path)) "vstest-codecoverage.runsettings" -$Script:TPT_NSTraceDataCollectorPath = Join-Path $env:TP_ROOT_DIR "src\DataCollectors\TraceDataCollector\bin\$Script:TPT_Configuration\netstandard2.0" +$Script:TPT_NSTraceDataCollectorPath = Join-Path $env:TP_OUT_DIR "$Script:TPT_Configuration\Microsoft.CodeCoverage" # # Capture error state in any step globally to modify return code diff --git a/scripts/verify-nupkgs.ps1 b/scripts/verify-nupkgs.ps1 index 70f48ec763..6b2da27353 100644 --- a/scripts/verify-nupkgs.ps1 +++ b/scripts/verify-nupkgs.ps1 @@ -15,9 +15,9 @@ function Verify-Nuget-Packages($packageDirectory, $version) $expectedNumOfFiles = @{ "Microsoft.CodeCoverage" = 44; "Microsoft.NET.Test.Sdk" = 18; - "Microsoft.TestPlatform" = 486; + "Microsoft.TestPlatform" = 499; "Microsoft.TestPlatform.Build" = 19; - "Microsoft.TestPlatform.CLI" = 353; + "Microsoft.TestPlatform.CLI" = 379; "Microsoft.TestPlatform.Extensions.TrxLogger" = 33; "Microsoft.TestPlatform.ObjectModel" = 178; "Microsoft.TestPlatform.Portable" = 568; diff --git a/src/DataCollectors/TraceDataCollector/BaseDataCollector.cs b/src/DataCollectors/TraceDataCollector/BaseDataCollector.cs deleted file mode 100644 index e9c2b5081c..0000000000 --- a/src/DataCollectors/TraceDataCollector/BaseDataCollector.cs +++ /dev/null @@ -1,76 +0,0 @@ -// 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.TraceCollector -{ - using System.Collections.Generic; - using System.Xml; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using TestPlatform.ObjectModel; - - /// - /// Implements the base event hooking logic for data collectors. - /// - /// - /// This class is used so that we can wrap the concrete objects given to us from the collector architecture with interfaces. - /// This allows us to mock up collectors for unit tests. - /// - public abstract class BaseDataCollector : DataCollector, ITestExecutionEnvironmentSpecifier - { - internal IDataCollectionEvents Events { get; private set; } - - internal IDataCollectionLogger Logger { get; private set; } - - internal IDataCollectionSink DataSink { get; private set; } - - internal IDataCollectionAgentContext AgentContext { get; private set; } - - #region Interface entry points - - public override void Initialize( - XmlElement configurationElement, - DataCollectionEvents events, - DataCollectionSink dataSink, - DataCollectionLogger logger, - DataCollectionEnvironmentContext environmentContext) - { - this.Initialize( - configurationElement, - new DataCollectionEventsWrapper(events), - new DataCollectionSinkWrapper(dataSink), - new DataCollectionLoggerWrapper(logger), - new DataCollectionEnvironmentContextWrapper(environmentContext)); - } - - IEnumerable> ITestExecutionEnvironmentSpecifier. - GetTestExecutionEnvironmentVariables() - { - return this.GetEnvironmentVariables(); - } - - #endregion - - internal void Initialize( - XmlElement configurationElement, - IDataCollectionEvents events, - IDataCollectionSink dataSink, - IDataCollectionLogger logger, - IDataCollectionAgentContext agentContext) - { - EqtTrace.Info( - "BaseDataCollector.InternalConstruct: Enabling datacollector with configuration: {0}", - configurationElement?.OuterXml); - this.Events = events; - this.DataSink = dataSink; - this.Logger = logger; - this.AgentContext = agentContext; - - this.OnInitialize(configurationElement); - } - - protected abstract void OnInitialize(XmlElement configurationElement); - - // Provide required environment variables for test execution through this method. - protected abstract IEnumerable> GetEnvironmentVariables(); - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionEnvironmentContextWrapper.cs b/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionEnvironmentContextWrapper.cs deleted file mode 100644 index 8aaac18598..0000000000 --- a/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionEnvironmentContextWrapper.cs +++ /dev/null @@ -1,23 +0,0 @@ -// 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.TraceCollector -{ - using TestPlatform.ObjectModel.DataCollection; - - /// - internal sealed class DataCollectionEnvironmentContextWrapper : IDataCollectionAgentContext - { - private readonly DataCollectionEnvironmentContext environmentContext; - - public DataCollectionEnvironmentContextWrapper(DataCollectionEnvironmentContext environmentContext) - { - this.environmentContext = environmentContext; - } - - public DataCollectionContext SessionDataCollectionContext - { - get { return this.environmentContext.SessionDataCollectionContext; } - } - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionEventsWrapper.cs b/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionEventsWrapper.cs deleted file mode 100644 index 4dffb285ee..0000000000 --- a/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionEventsWrapper.cs +++ /dev/null @@ -1,47 +0,0 @@ -// 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.TraceCollector -{ - using System; - using TestPlatform.ObjectModel.DataCollection; - - /// - internal sealed class DataCollectionEventsWrapper : IDataCollectionEvents - { - private readonly DataCollectionEvents wrapped; - - public DataCollectionEventsWrapper(DataCollectionEvents wrapped) - { - this.wrapped = wrapped; - } - - #region IDataCollectionEvents Members - - event EventHandler IDataCollectionEvents.SessionEnd - { - add { this.wrapped.SessionEnd += value; } - remove { this.wrapped.SessionEnd -= value; } - } - - event EventHandler IDataCollectionEvents.SessionStart - { - add { this.wrapped.SessionStart += value; } - remove { this.wrapped.SessionStart -= value; } - } - - event EventHandler IDataCollectionEvents.TestCaseEnd - { - add { this.wrapped.TestCaseEnd += value; } - remove { this.wrapped.TestCaseEnd -= value; } - } - - event EventHandler IDataCollectionEvents.TestCaseStart - { - add { this.wrapped.TestCaseStart += value; } - remove { this.wrapped.TestCaseStart -= value; } - } - - #endregion - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionLoggerWrapper.cs b/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionLoggerWrapper.cs deleted file mode 100644 index 831fdfdd69..0000000000 --- a/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionLoggerWrapper.cs +++ /dev/null @@ -1,43 +0,0 @@ -// 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.TraceCollector -{ - using System; - using TestPlatform.ObjectModel.DataCollection; - - /// - internal sealed class DataCollectionLoggerWrapper : IDataCollectionLogger - { - private readonly DataCollectionLogger wrapped; - - public DataCollectionLoggerWrapper(DataCollectionLogger wrapped) - { - this.wrapped = wrapped; - } - - #region IDataCollectionLogger Members - - void IDataCollectionLogger.LogError(DataCollectionContext context, Exception exception) - { - this.wrapped.LogError(context, exception); - } - - void IDataCollectionLogger.LogError(DataCollectionContext context, string text) - { - this.wrapped.LogError(context, text); - } - - void IDataCollectionLogger.LogError(DataCollectionContext context, string text, Exception exception) - { - this.wrapped.LogError(context, text, exception); - } - - void IDataCollectionLogger.LogWarning(DataCollectionContext context, string text) - { - this.wrapped.LogWarning(context, text); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionSinkWrapper.cs b/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionSinkWrapper.cs deleted file mode 100644 index 8b65ae14af..0000000000 --- a/src/DataCollectors/TraceDataCollector/DataCollection/DataCollectionSinkWrapper.cs +++ /dev/null @@ -1,48 +0,0 @@ -// 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.TraceCollector -{ - using System.ComponentModel; - using TestPlatform.ObjectModel.DataCollection; - - /// - internal sealed class DataCollectionSinkWrapper : IDataCollectionSink - { - private readonly DataCollectionSink wrapped; - - public DataCollectionSinkWrapper(DataCollectionSink wrapped) - { - this.wrapped = wrapped; - } - - #region IDataCollectionSink Members - - event AsyncCompletedEventHandler IDataCollectionSink.SendFileCompleted - { - add { this.wrapped.SendFileCompleted += value; } - remove { this.wrapped.SendFileCompleted -= value; } - } - - void IDataCollectionSink.SendFileAsync(DataCollectionContext context, string path, bool deleteFile) - { - this.wrapped.SendFileAsync(context, path, deleteFile); - } - - void IDataCollectionSink.SendFileAsync( - DataCollectionContext context, - string path, - string description, - bool deleteFile) - { - this.wrapped.SendFileAsync(context, path, description, deleteFile); - } - - void IDataCollectionSink.SendFileAsync(FileTransferInformation fileInformation) - { - this.wrapped.SendFileAsync(fileInformation); - } - - #endregion - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionAgentContext.cs b/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionAgentContext.cs deleted file mode 100644 index a233a03c64..0000000000 --- a/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionAgentContext.cs +++ /dev/null @@ -1,16 +0,0 @@ -// 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.TraceCollector -{ - using TestPlatform.ObjectModel.DataCollection; - - /// - /// Wrapper for - /// to make the collector testable. - /// - internal interface IDataCollectionAgentContext - { - DataCollectionContext SessionDataCollectionContext { get; } - } -} diff --git a/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionEvents.cs b/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionEvents.cs deleted file mode 100644 index 2de2cae522..0000000000 --- a/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionEvents.cs +++ /dev/null @@ -1,23 +0,0 @@ -// 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.TraceCollector -{ - using System; - using TestPlatform.ObjectModel.DataCollection; - - /// - /// Wrapper for - /// to make the collector testable. - /// - internal interface IDataCollectionEvents - { - event EventHandler SessionEnd; - - event EventHandler SessionStart; - - event EventHandler TestCaseEnd; - - event EventHandler TestCaseStart; - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionLogger.cs b/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionLogger.cs deleted file mode 100644 index 8820acbd01..0000000000 --- a/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionLogger.cs +++ /dev/null @@ -1,23 +0,0 @@ -// 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.TraceCollector -{ - using System; - using TestPlatform.ObjectModel.DataCollection; - - /// - /// Wrapper for - /// to make the collector testable. - /// - internal interface IDataCollectionLogger - { - void LogError(DataCollectionContext context, Exception exception); - - void LogError(DataCollectionContext context, string text); - - void LogError(DataCollectionContext context, string text, Exception exception); - - void LogWarning(DataCollectionContext context, string text); - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionSink.cs b/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionSink.cs deleted file mode 100644 index 654922f97b..0000000000 --- a/src/DataCollectors/TraceDataCollector/DataCollection/Interfaces/IDataCollectionSink.cs +++ /dev/null @@ -1,23 +0,0 @@ -// 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.TraceCollector -{ - using System.ComponentModel; - using TestPlatform.ObjectModel.DataCollection; - - /// - /// Wrapper for - /// to make the collector testable. - /// - internal interface IDataCollectionSink - { - event AsyncCompletedEventHandler SendFileCompleted; - - void SendFileAsync(DataCollectionContext context, string path, bool deleteFile); - - void SendFileAsync(DataCollectionContext context, string path, string displayName, bool deleteFile); - - void SendFileAsync(FileTransferInformation fileInformation); - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/DirectoryHelper.cs b/src/DataCollectors/TraceDataCollector/DirectoryHelper.cs deleted file mode 100644 index a4db2d8a68..0000000000 --- a/src/DataCollectors/TraceDataCollector/DirectoryHelper.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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.TraceCollector -{ - using System.IO; - using Interfaces; - - /// - internal class DirectoryHelper : IDirectoryHelper - { - /// - public void Delete(string path, bool recursive) - { - Directory.Delete(path, recursive); - } - - /// - public void CreateDirectory(string path) - { - Directory.CreateDirectory(path); - } - - /// - public bool Exists(string path) - { - return Directory.Exists(path); - } - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/FileHelper.cs b/src/DataCollectors/TraceDataCollector/FileHelper.cs deleted file mode 100644 index 936a93a9a3..0000000000 --- a/src/DataCollectors/TraceDataCollector/FileHelper.cs +++ /dev/null @@ -1,24 +0,0 @@ -// 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.TraceCollector -{ - using System.IO; - using Interfaces; - - /// - internal class FileHelper : IFileHelper - { - /// - public bool Exists(string path) - { - return File.Exists(path); - } - - /// - public void WriteAllText(string path, string contents) - { - File.WriteAllText(path, contents); - } - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Friends.cs b/src/DataCollectors/TraceDataCollector/Friends.cs deleted file mode 100644 index 10045b5dd3..0000000000 --- a/src/DataCollectors/TraceDataCollector/Friends.cs +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Microsoft.TestPlatform.TraceDataCollector.UnitTests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007d1fa57c4aed9f0a32e84aa0faefd0de9e8fd6aec8f87fb03766c834c99921eb23be79ad9d5dcc1dd9ad236132102900b723cf980957fc4e177108fc607774f29e8320e92ea05ece4e821c0a5efe8f1645c4c0c93c1ab99285d622caa652c1dfad63d745d6f2de5f17e5eaf0fc4963d261c8a12436518206dc093344d5ad293")] - -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] diff --git a/src/DataCollectors/TraceDataCollector/Interfaces/IDirectoryHelper.cs b/src/DataCollectors/TraceDataCollector/Interfaces/IDirectoryHelper.cs deleted file mode 100644 index 3f50af1ce7..0000000000 --- a/src/DataCollectors/TraceDataCollector/Interfaces/IDirectoryHelper.cs +++ /dev/null @@ -1,32 +0,0 @@ -// 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.TraceCollector.Interfaces -{ - /// - /// Interface to Abstract System.IO.Directory methods for mocking in unit tests. - /// - internal interface IDirectoryHelper - { - /// - /// Deletes the specified directory and, if indicated, any subdirectories and files in the directory. - /// - /// The name of the directory to remove. - /// true to remove directories, subdirectories, and files in path; otherwise, false. - void Delete(string path, bool recursive); - - /// - /// Creates all directories and subdirectories in the specified path unless they already exist. - /// - /// The directory to create. - void CreateDirectory(string path); - - /// - /// Determines whether the given path refers to an existing directory on disk. - /// - /// The path to test. - /// true if path refers to an existing directory; - /// false if the directory does not exist or an error occurs when trying to determine if the specified directory exists. - bool Exists(string path); - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Interfaces/IEnvironment.cs b/src/DataCollectors/TraceDataCollector/Interfaces/IEnvironment.cs deleted file mode 100644 index 7ed0e044e2..0000000000 --- a/src/DataCollectors/TraceDataCollector/Interfaces/IEnvironment.cs +++ /dev/null @@ -1,16 +0,0 @@ -// 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.TraceCollector.Interfaces -{ - /// - /// Operating system environment abstractions. - /// - internal interface IEnvironment - { - /// - /// Gets operating System. - /// - PlatformOperatingSystem OperatingSystem { get; } - } -} diff --git a/src/DataCollectors/TraceDataCollector/Interfaces/IFileHelper.cs b/src/DataCollectors/TraceDataCollector/Interfaces/IFileHelper.cs deleted file mode 100644 index 46e5a4fe7b..0000000000 --- a/src/DataCollectors/TraceDataCollector/Interfaces/IFileHelper.cs +++ /dev/null @@ -1,29 +0,0 @@ -// 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.TraceCollector.Interfaces -{ - /// - /// Interface to Abstract System.IO.File methods for mocking in unit tests. - /// - internal interface IFileHelper - { - /// - /// Determines whether the specified file exists. - /// - /// The file to check. - /// true if the caller has the required permissions and path contains the name of an existing file; otherwise, false. - /// This method also returns false if path is null, an invalid path, or a zero-length string. - /// If the caller does not have sufficient permissions to read the specified file, - /// no exception is thrown and the method returns false regardless of the existence of path. - bool Exists(string path); - - /// - /// Creates a new file, writes the specified string to the file, and then closes the file. - /// If the target file already exists, it is overwritten. - /// - /// The file to write to. - /// The string to write to the file. - void WriteAllText(string path, string contents); - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Interfaces/IProcessJobObject.cs b/src/DataCollectors/TraceDataCollector/Interfaces/IProcessJobObject.cs deleted file mode 100644 index e5ab73ab8d..0000000000 --- a/src/DataCollectors/TraceDataCollector/Interfaces/IProcessJobObject.cs +++ /dev/null @@ -1,22 +0,0 @@ -// 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.TraceCollector.Interfaces -{ - using System; - - /// - /// Helper interface used to add a child process to a job object so that it terminates when - /// the parent process dies - /// - /// An interface to the Windows Job Objects API. - internal interface IProcessJobObject : IDisposable - { - /// - /// Helper function to add a process to the job object - /// - /// Handle of the process to be added - /// - void AddProcess(IntPtr handle); - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Interfaces/PlatformOperationSystem.cs b/src/DataCollectors/TraceDataCollector/Interfaces/PlatformOperationSystem.cs deleted file mode 100644 index 6888d8a4fc..0000000000 --- a/src/DataCollectors/TraceDataCollector/Interfaces/PlatformOperationSystem.cs +++ /dev/null @@ -1,14 +0,0 @@ -// 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.TraceCollector.Interfaces -{ - /// - /// Available operating systems. - /// - internal enum PlatformOperatingSystem - { - Windows, - Unix - } -} diff --git a/src/DataCollectors/TraceDataCollector/Microsoft.VisualStudio.TraceDataCollector.csproj b/src/DataCollectors/TraceDataCollector/Microsoft.VisualStudio.TraceDataCollector.csproj deleted file mode 100644 index ddc4444ce0..0000000000 --- a/src/DataCollectors/TraceDataCollector/Microsoft.VisualStudio.TraceDataCollector.csproj +++ /dev/null @@ -1,51 +0,0 @@ - - - - ..\..\..\ - - - - Microsoft.VisualStudio.TraceDataCollector - netstandard2.0 - true - true - - - - - - - - - - - - - - - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - True - True - Resources.resx - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - diff --git a/src/DataCollectors/TraceDataCollector/PlatformEnvironment.cs b/src/DataCollectors/TraceDataCollector/PlatformEnvironment.cs deleted file mode 100644 index 7d783f644d..0000000000 --- a/src/DataCollectors/TraceDataCollector/PlatformEnvironment.cs +++ /dev/null @@ -1,26 +0,0 @@ -// 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.TraceCollector -{ - using System.Runtime.InteropServices; - using Interfaces; - - /// - internal class PlatformEnvironment : IEnvironment - { - /// - public PlatformOperatingSystem OperatingSystem - { - get - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return PlatformOperatingSystem.Windows; - } - - return PlatformOperatingSystem.Unix; - } - } - } -} diff --git a/src/DataCollectors/TraceDataCollector/ProcessJobObject.cs b/src/DataCollectors/TraceDataCollector/ProcessJobObject.cs deleted file mode 100644 index b44164204a..0000000000 --- a/src/DataCollectors/TraceDataCollector/ProcessJobObject.cs +++ /dev/null @@ -1,875 +0,0 @@ -// 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.TraceCollector -{ - using System; - using System.Runtime.InteropServices; - using Interfaces; - using TestPlatform.ObjectModel; - - /// - /// Helper class used to add a child process to a job object so that it terminates when - /// the parent process dies - /// - /// An interface to the Windows Job Objects API. - internal class ProcessJobObject : IProcessJobObject - { - #region Native 32/64 Bit Switching Flag - - /// - /// The structures returned by Windows are different sizes depending on whether - /// the operating system is running in 32bit or 64bit mode. - /// - private static readonly bool Is32Bit = IntPtr.Size == 4; - - #endregion - - /// - /// Job handle created by the CreateJobObject - /// - private IntPtr jobHandle; - - /// - /// Set to true when disposed - /// - private volatile bool disposed; - - /// - /// Initializes a new instance of the class. - /// Creates a job object - /// - /// Handle to the job object created - public ProcessJobObject() - { - this.CreateJobObject(); - } - - /// - /// Finalizes an instance of the class. - /// - ~ProcessJobObject() - { - this.Dispose(false); - } - - #region JobObjectInfoClass Enumeration - - /// - /// Information class for the limits to be set. This parameter can be one of - /// the following values. - /// - private enum JobObjectInfoClass - { - /// - /// The lpJobObjectInfo parameter is a pointer to a - /// JOBOBJECT_BASIC_ACCOUNTING_INFORMATION structure. - /// - BasicAccountingInformation = 1, - - /// - /// The lpJobObjectInfo parameter is a pointer to a - /// JOBOBJECT_BASIC_LIMIT_INFORMATION structure. - /// - BasicLimitInformation = 2, - - /// - /// The lpJobObjectInfo parameter is a pointer to a - /// JOBOBJECT_BASIC_PROCESS_ID_LIST structure. - /// - BasicProcessIdList = 3, - - /// - /// The lpJobObjectInfo parameter is a pointer to a - /// JOBOBJECT_BASIC_UI_RESTRICTIONS structure. - /// - BasicUIRestrictions = 4, - - /// - /// The lpJobObjectInfo parameter is a pointer to a - /// JOBOBJECT_SECURITY_LIMIT_INFORMATION structure. - /// The hJob handle must have the JOB_OBJECT_SET_SECURITY_ATTRIBUTES - /// access right associated with it. - /// - SecurityLimitInformation = 5, - - /// - /// The lpJobObjectInfo parameter is a pointer to a - /// JOBOBJECT_END_OF_JOB_TIME_INFORMATION structure. - /// - EndOfJobTimeInformation = 6, - - /// - /// The lpJobObjectInfo parameter is a pointer to a - /// JOBOBJECT_ASSOCIATE_COMPLETION_PORT structure. - /// - AssociateCompletionPortInformation = 7, - - /// - /// The lpJobObjectInfo parameter is a pointer to a - /// JOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION structure. - /// - BasicAndIoAccountingInformation = 8, - - /// - /// The lpJobObjectInfo parameter is a pointer to a - /// JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure. - /// - ExtendedLimitInformation = 9 - } - - #endregion - - #region LimitFlags Enumeration - - /// - /// Limit flags that are in effect. This member is a bit field that determines - /// whether other structure members are used. Any combination of the following - /// values can be specified. - /// - [Flags] - private enum LimitFlags - { - /// - /// Causes all processes associated with the job to use the same minimum and maximum working set sizes. - /// - LimitWorkingSet = 0x00000001, - - /// - /// Establishes a user-mode execution time limit for each currently active process - /// and for all future processes associated with the job. - /// - LimitProcessTime = 0x00000002, - - /// - /// Establishes a user-mode execution time limit for the job. This flag cannot - /// be used with JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME. - /// - LimitJobTime = 0x00000004, - - /// - /// Establishes a maximum number of simultaneously active processes associated - /// with the job. - /// - LimitActiveProcesses = 0x00000008, - - /// - /// Causes all processes associated with the job to use the same processor - /// affinity. - /// - LimitAffinity = 0x00000010, - - /// - /// Causes all processes associated with the job to use the same priority class. - /// For more information, see Scheduling Priorities. - /// - LimitPriorityClass = 0x00000020, - - /// - /// Preserves any job time limits you previously set. As long as this flag is - /// set, you can establish a per-job time limit once, then alter other limits - /// in subsequent calls. This flag cannot be used with JOB_OBJECT_LIMIT_JOB_TIME. - /// - PreserveJobTime = 0x00000040, - - /// - /// Causes all processes in the job to use the same scheduling class. - /// - LimitSchedulingClass = 0x00000080, - - /// - /// Causes all processes associated with the job to limit their committed memory. - /// When a process attempts to commit memory that would exceed the per-process - /// limit, it fails. If the job object is associated with a completion port, a - /// JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT message is sent to the completion port. - /// This limit requires use of a JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure. - /// Its BasicLimitInformation member is a JOBOBJECT_BASIC_LIMIT_INFORMATION - /// structure. - /// - LimitProcessMemory = 0x00000100, - - /// - /// Causes all processes associated with the job to limit the job-wide sum of - /// their committed memory. When a process attempts to commit memory that would - /// exceed the job-wide limit, it fails. If the job object is associated with a - /// completion port, a JOB_OBJECT_MSG_JOB_MEMORY_LIMIT message is sent to the - /// completion port. This limit requires use of a - /// JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure. Its BasicLimitInformation - /// member is a JOBOBJECT_BASIC_LIMIT_INFORMATION structure. - /// - LimitJobMemory = 0x00000200, - - /// - /// Forces a call to the SetErrorMode function with the SEM_NOGPFAULTERRORBOX - /// flag for each process associated with the job. If an exception occurs and - /// the system calls the UnhandledExceptionFilter function, the debugger will - /// be given a chance to act. If there is no debugger, the functions returns - /// EXCEPTION_EXECUTE_HANDLER. Normally, this will cause termination of the - /// process with the exception code as the exit status. This limit requires - /// use of a JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure. Its - /// BasicLimitInformation member is a JOBOBJECT_BASIC_LIMIT_INFORMATION structure. - /// - DieOnUnhandledException = 0x00000400, - - /// - /// If any process associated with the job creates a child process using the - /// CREATE_BREAKAWAY_FROM_JOB flag while this limit is in effect, the child - /// process is not associated with the job. This limit requires use of a - /// JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure. Its BasicLimitInformation - /// member is a JOBOBJECT_BASIC_LIMIT_INFORMATION structure. - /// - LimitBreakawayOk = 0x00000800, - - /// - /// Allows any process associated with the job to create child processes - /// that are not associated with the job. This limit requires use of a - /// JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure. Its BasicLimitInformation - /// member is a JOBOBJECT_BASIC_LIMIT_INFORMATION structure. - /// - LimitSilentBreakawayOk = 0x00001000, - - /// - /// Causes all processes associated with the job to terminate when the last - /// handle to the job is closed. This limit requires use of a - /// JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure. Its BasicLimitInformation - /// member is a JOBOBJECT_BASIC_LIMIT_INFORMATION structure. - /// Windows 2000: This flag is not supported. - /// - LimitKillOnJobClose = 0x00002000 - } - - #endregion - - /// - /// Helper function to add a process to the job object - /// - /// Handle of the process to be added - public void AddProcess(IntPtr handle) - { - if (this.jobHandle != IntPtr.Zero) - { - if (!WinAPI.AssignProcessToJobObject(this.jobHandle, handle)) - { - EqtTrace.Warning("AddProcess : Failed to AddProcess {0}", Marshal.GetLastWin32Error()); - } - } - else - { - EqtTrace.Warning("AddProcess : Ignoring as job object is not created"); - } - } - - /// - /// Dispose the resources - /// - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - #region Private Members - - /// - /// Helper function to create job object - /// - private void CreateJobObject() - { - this.jobHandle = WinAPI.CreateJobObject(IntPtr.Zero, null); - if (this.jobHandle == IntPtr.Zero) - { - EqtTrace.Warning("CreateJobObject : Failed {0}", Marshal.GetLastWin32Error()); - } - - if (ProcessJobObject.Is32Bit) - { - BasicLimits32 basicInfo = default(BasicLimits32); - basicInfo.LimitFlags = LimitFlags.LimitKillOnJobClose; - - ExtendedLimits32 extendedInfo = default(ExtendedLimits32); - extendedInfo.BasicLimits = basicInfo; - - JobObjectInfo info = default(JobObjectInfo); - info.basicLimits32 = basicInfo; - info.extendedLimits32 = extendedInfo; - - if (!WinAPI.SetInformationJobObject( - this.jobHandle, - JobObjectInfoClass.ExtendedLimitInformation, - ref info, - Marshal.SizeOf())) - { - EqtTrace.Warning("CreateJobObject [32] : Failed to setInformation {0}", Marshal.GetLastWin32Error()); - } - } - else - { - BasicLimits64 basicInfo = default(BasicLimits64); - basicInfo.LimitFlags = LimitFlags.LimitKillOnJobClose; - - ExtendedLimits64 extendedInfo = default(ExtendedLimits64); - extendedInfo.BasicLimits = basicInfo; - - JobObjectInfo info = default(JobObjectInfo); - info.basicLimits64 = basicInfo; - info.extendedLimits64 = extendedInfo; - - if (!WinAPI.SetInformationJobObject( - this.jobHandle, - JobObjectInfoClass.ExtendedLimitInformation, - ref info, - Marshal.SizeOf())) - { - EqtTrace.Warning("CreateJobObject [64] : Failed to setInformation {0}", Marshal.GetLastWin32Error()); - } - } - } - - /// - /// Helper function to dispose managed and unmanaged resources - /// - /// The disposing. - private void Dispose(bool disposing) - { - bool isDisposed = this.disposed; - if (!isDisposed) - { - this.disposed = true; - if (disposing) - { - // Managed resources - } - - if (this.jobHandle != IntPtr.Zero) - { - WinAPI.CloseHandle(this.jobHandle); - } - } - } - - #endregion - - #region IoCounters Structures - - /// - /// Various counters for different types of IO operations - /// - [StructLayout(LayoutKind.Explicit)] - private struct IoCounters32 - { - /// - /// The number of read operations. - /// - [FieldOffset(0)] - public ulong ReadOperationCount; - - /// - /// The number of write operations. - /// - [FieldOffset(8)] - public ulong WriteOperationCount; - - /// - /// The number of other operations. - /// - [FieldOffset(16)] - public ulong OtherOperationCount; - - /// - /// The number of read transfers. - /// - [FieldOffset(24)] - public ulong ReadTransferCount; - - /// - /// The number of write transfers. - /// - [FieldOffset(32)] - public ulong WriteTransferCount; - - /// - /// The number of other transfers. - /// - [FieldOffset(40)] - public ulong OtherTransferCount; - } - - /// - /// Various counters for different types of IO operations. - /// - [StructLayout(LayoutKind.Explicit)] - private struct IoCounters64 - { - /// - /// The number of read operations. - /// - [FieldOffset(0)] - public ulong ReadOperationCount; - - /// - /// The number of write operations. - /// - [FieldOffset(8)] - public ulong WriteOperationCount; - - /// - /// The number of other operations. - /// - [FieldOffset(16)] - public ulong OtherOperationCount; - - /// - /// The number of read transfers. - /// - [FieldOffset(24)] - public ulong ReadTransferCount; - - /// - /// The number of write transfers. - /// - [FieldOffset(32)] - public ulong WriteTransferCount; - - /// - /// The number of other transfers. - /// - [FieldOffset(40)] - public ulong OtherTransferCount; - } - - #endregion - - #region BasicLimits Structures - - /// - /// The JOBOBJECT_BASIC_LIMIT_INFORMATION structure contains basic limit - /// information for a job object. - /// - [StructLayout(LayoutKind.Explicit)] - private struct BasicLimits32 - { - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_PROCESS_TIME, this member is - /// the per-process user-mode execution time limit, in 100-nanosecond ticks. - /// Otherwise, this member is ignored. The system periodically checks to - /// determine whether each process associated with the job has accumulated - /// more user-mode time than the set limit. If it has, the process is terminated. - /// - [FieldOffset(0)] - public long PerProcessUserTimeLimit; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_JOB_TIME, this member is the - /// per-job user-mode execution time limit, in 100-nanosecond ticks. Otherwise, - /// this member is ignored. The system adds the current time of the processes - /// associated with the job to this limit. For example, if you set this limit - /// to 1 minute, and the job has a process that has accumulated 5 minutes of - /// user-mode time, the limit actually enforced is 6 minutes. The system - /// periodically checks to determine whether the sum of the user-mode execution - /// time for all processes is greater than this end-of-job limit. If it is, the - /// action specified in the EndOfJobTimeAction member of the - /// JOBOBJECT_END_OF_JOB_TIME_INFORMATION structure is carried out. By default, - /// all processes are terminated and the status code is set to - /// ERROR_NOT_ENOUGH_QUOTA. - /// - [FieldOffset(8)] - public long PerJobUserTimeLimit; - - /// - /// Limit flags that are in effect. This member is a bit field that determines - /// whether other structure members are used. Any combination LimitFlag values - /// can be specified. - /// - [FieldOffset(16)] - public LimitFlags LimitFlags; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_WORKINGSET, this member is the - /// minimum working set size for each process associated with the job. Otherwise, - /// this member is ignored. If MaximumWorkingSetSize is nonzero, - /// MinimumWorkingSetSize cannot be zero. - /// - [FieldOffset(20)] - public uint MinimumWorkingSetSize; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_WORKINGSET, this member is the - /// maximum working set size for each process associated with the job. Otherwise, - /// this member is ignored. If MinimumWorkingSetSize is nonzero, - /// MaximumWorkingSetSize cannot be zero. - /// - [FieldOffset(24)] - public uint MaximumWorkingSetSize; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_ACTIVE_PROCESS, this member is the - /// active process limit for the job. Otherwise, this member is ignored. If you - /// try to associate a process with a job, and this causes the active process - /// count to exceed this limit, the process is terminated and the association - /// fails. - /// - [FieldOffset(28)] - public int ActiveProcessLimit; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_AFFINITY, this member is the - /// processor affinity for all processes associated with the job. Otherwise, - /// this member is ignored. The affinity must be a proper subset of the system - /// affinity mask obtained by calling the GetProcessAffinityMask function. The - /// affinity of each thread is set to this value, but threads are free to - /// subsequently set their affinity, as long as it is a subset of the specified - /// affinity mask. Processes cannot set their own affinity mask. - /// - [FieldOffset(32)] - public IntPtr Affinity; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_PRIORITY_CLASS, this member is the - /// priority class for all processes associated with the job. Otherwise, this - /// member is ignored. Processes and threads cannot modify their priority class. - /// The calling process must enable the SE_INC_BASE_PRIORITY_NAME privilege. - /// - [FieldOffset(36)] - public int PriorityClass; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_SCHEDULING_CLASS, this member is - /// the scheduling class for all processes associated with the job. Otherwise, - /// this member is ignored. The valid values are 0 to 9. Use 0 for the least - /// favorable scheduling class relative to other threads, and 9 for the most - /// favorable scheduling class relative to other threads. By default, this - /// value is 5. To use a scheduling class greater than 5, the calling process - /// must enable the SE_INC_BASE_PRIORITY_NAME privilege. - /// - [FieldOffset(40)] - public int SchedulingClass; - } - - /// - /// The JOBOBJECT_BASIC_LIMIT_INFORMATION structure contains basic limit - /// information for a job object. - /// - [StructLayout(LayoutKind.Explicit)] - private struct BasicLimits64 - { - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_PROCESS_TIME, this member is - /// the per-process user-mode execution time limit, in 100-nanosecond ticks. - /// Otherwise, this member is ignored. The system periodically checks to - /// determine whether each process associated with the job has accumulated - /// more user-mode time than the set limit. If it has, the process is terminated. - /// - [FieldOffset(0)] - public long PerProcessUserTimeLimit; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_JOB_TIME, this member is the - /// per-job user-mode execution time limit, in 100-nanosecond ticks. Otherwise, - /// this member is ignored. The system adds the current time of the processes - /// associated with the job to this limit. For example, if you set this limit - /// to 1 minute, and the job has a process that has accumulated 5 minutes of - /// user-mode time, the limit actually enforced is 6 minutes. The system - /// periodically checks to determine whether the sum of the user-mode execution - /// time for all processes is greater than this end-of-job limit. If it is, the - /// action specified in the EndOfJobTimeAction member of the - /// JOBOBJECT_END_OF_JOB_TIME_INFORMATION structure is carried out. By default, - /// all processes are terminated and the status code is set to - /// ERROR_NOT_ENOUGH_QUOTA. - /// - [FieldOffset(8)] - public long PerJobUserTimeLimit; - - /// - /// Limit flags that are in effect. This member is a bit field that determines - /// whether other structure members are used. Any combination LimitFlag values - /// can be specified. - /// - [FieldOffset(16)] - public LimitFlags LimitFlags; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_WORKINGSET, this member is the - /// minimum working set size for each process associated with the job. Otherwise, - /// this member is ignored. If MaximumWorkingSetSize is nonzero, - /// MinimumWorkingSetSize cannot be zero. - /// - [FieldOffset(24)] - public ulong MinimumWorkingSetSize; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_WORKINGSET, this member is the - /// maximum working set size for each process associated with the job. Otherwise, - /// this member is ignored. If MinimumWorkingSetSize is nonzero, - /// MaximumWorkingSetSize cannot be zero. - /// - [FieldOffset(32)] - public ulong MaximumWorkingSetSize; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_ACTIVE_PROCESS, this member is the - /// active process limit for the job. Otherwise, this member is ignored. If you - /// try to associate a process with a job, and this causes the active process - /// count to exceed this limit, the process is terminated and the association - /// fails. - /// - [FieldOffset(40)] - public int ActiveProcessLimit; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_AFFINITY, this member is the - /// processor affinity for all processes associated with the job. Otherwise, - /// this member is ignored. The affinity must be a proper subset of the system - /// affinity mask obtained by calling the GetProcessAffinityMask function. The - /// affinity of each thread is set to this value, but threads are free to - /// subsequently set their affinity, as long as it is a subset of the specified - /// affinity mask. Processes cannot set their own affinity mask. - /// - [FieldOffset(48)] - public IntPtr Affinity; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_PRIORITY_CLASS, this member is the - /// priority class for all processes associated with the job. Otherwise, this - /// member is ignored. Processes and threads cannot modify their priority class. - /// The calling process must enable the SE_INC_BASE_PRIORITY_NAME privilege. - /// - [FieldOffset(56)] - public int PriorityClass; - - /// - /// If LimitFlags specifies JOB_OBJECT_LIMIT_SCHEDULING_CLASS, this member is - /// the scheduling class for all processes associated with the job. Otherwise, - /// this member is ignored. The valid values are 0 to 9. Use 0 for the least - /// favorable scheduling class relative to other threads, and 9 for the most - /// favorable scheduling class relative to other threads. By default, this - /// value is 5. To use a scheduling class greater than 5, the calling process - /// must enable the SE_INC_BASE_PRIORITY_NAME privilege. - /// - [FieldOffset(60)] - public int SchedulingClass; - } - #endregion - - #region ExtendedLimits Structures - - /// - /// The JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure contains basic and extended limit - /// information for a job object. - /// - [StructLayout(LayoutKind.Explicit)] - private struct ExtendedLimits32 - { - /// - /// A JOBOBJECT_BASIC_LIMIT_INFORMATION structure that contains - /// basic limit information. - /// - [FieldOffset(0)] - public BasicLimits32 BasicLimits; - - /// - /// Reserved. - /// - [FieldOffset(48)] - public IoCounters32 IoInfo; - - /// - /// If the LimitFlags member of the JOBOBJECT_BASIC_LIMIT_INFORMATION structure - /// specifies the JOB_OBJECT_LIMIT_PROCESS_MEMORY value, this member specifies - /// the limit for the virtual memory that can be committed by a process. - /// Otherwise, this member is ignored. - /// - [FieldOffset(96)] - public uint ProcessMemoryLimit; - - /// - /// If the LimitFlags member of the JOBOBJECT_BASIC_LIMIT_INFORMATION structure - /// specifies the JOB_OBJECT_LIMIT_JOB_MEMORY value, this member specifies the - /// limit for the virtual memory that can be committed for the job. Otherwise, - /// this member is ignored. - /// - [FieldOffset(100)] - public uint JobMemoryLimit; - - /// - /// Peak memory used by any process ever associated with the job. - /// - [FieldOffset(104)] - public uint PeakProcessMemoryUsed; - - /// - /// Peak memory usage of all processes currently associated with the job. - /// - [FieldOffset(108)] - public uint PeakJobMemoryUsed; - } - - /// - /// The JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure contains basic and extended limit - /// information for a job object. - /// - [StructLayout(LayoutKind.Explicit)] - private struct ExtendedLimits64 - { - /// - /// A JOBOBJECT_BASIC_LIMIT_INFORMATION structure that contains - /// basic limit information. - /// - [FieldOffset(0)] - public BasicLimits64 BasicLimits; - - /// - /// Reserved. - /// - [FieldOffset(64)] - public IoCounters64 IoInfo; - - /// - /// If the LimitFlags member of the JOBOBJECT_BASIC_LIMIT_INFORMATION structure - /// specifies the JOB_OBJECT_LIMIT_PROCESS_MEMORY value, this member specifies - /// the limit for the virtual memory that can be committed by a process. - /// Otherwise, this member is ignored. - /// - [FieldOffset(112)] - public ulong ProcessMemoryLimit; - - /// - /// If the LimitFlags member of the JOBOBJECT_BASIC_LIMIT_INFORMATION structure - /// specifies the JOB_OBJECT_LIMIT_JOB_MEMORY value, this member specifies the - /// limit for the virtual memory that can be committed for the job. Otherwise, - /// this member is ignored. - /// - [FieldOffset(120)] - public ulong JobMemoryLimit; - - /// - /// Peak memory used by any process ever associated with the job. - /// - [FieldOffset(128)] - public ulong PeakProcessMemoryUsed; - - /// - /// Peak memory usage of all processes currently associated with the job. - /// - [FieldOffset(136)] - public ulong PeakJobMemoryUsed; - } - #endregion - - #region JobObjectInfo Union - -#pragma warning disable SA1307 // Accessible fields must begin with upper-case letter - - /// - /// Union of different limit data structures that may be passed - /// to SetInformationJobObject / from QueryInformationJobObject. - /// This union also contains separate 32 and 64 bit versions of - /// each structure. - /// - [StructLayout(LayoutKind.Explicit)] - private struct JobObjectInfo - { - #region 32 bit structures - - /// - /// The BasicLimits32 structure contains basic limit information - /// for a job object on a 32bit platform. - /// - [FieldOffset(0)] - public BasicLimits32 basicLimits32; - - /// - /// The ExtendedLimits32 structure contains extended limit information - /// for a job object on a 32bit platform. - /// - [FieldOffset(0)] - - public ExtendedLimits32 extendedLimits32; - - #endregion - - #region 64 bit structures - - /// - /// The BasicLimits64 structure contains basic limit information - /// for a job object on a 64bit platform. - /// - [FieldOffset(0)] - public BasicLimits64 basicLimits64; - - /// - /// The ExtendedLimits64 structure contains extended limit information - /// for a job object on a 64bit platform. - /// - [FieldOffset(0)] - public ExtendedLimits64 extendedLimits64; - - #endregion - } - - #endregion - -#pragma warning restore SA1307 // Accessible fields must begin with upper-case letter - - #region IDisposable implementation - - #endregion - - #region WinAPI Class - - /// - /// Private class that holds all the Windows API calls made by this - /// - private class WinAPI - { - /// - /// The CreateJobObject function creates or opens a job object. - /// - /// Pointer to a SECURITY_ATTRIBUTES structure - /// Pointer to a null-terminated string specifying the name of the job. - /// If the function succeeds, the return value is a handle to the job object - [DllImport("kernel32.dll", SetLastError = true)] - public static extern IntPtr CreateJobObject(IntPtr jobAttributes, string name); - - /// - /// The AssignProcessToJobObject function assigns a process to an existing job object. - /// - /// Handle to the job object to which the process will be associated. - /// Handle to the process to associate with the job object - /// If the function succeeds, the return value is nonzero - [DllImport("kernel32.dll", SetLastError = true)] - public static extern bool AssignProcessToJobObject(IntPtr jobHandle, IntPtr processHandle); - - /// - /// The SetInformationJobObject function sets limits for a job object. - /// - /// Handle to the job whose limits are being set. - /// Information class for the limits to be set. This - /// parameter can be one of the following values. - /// Limits to be set for the job. The format of this data - /// depends on the value of JobObjectInfoClass. - /// Size of the job information being set, in - /// bytes. - /// If the function succeeds, the return value is nonzero. If the function - /// fails, the return value is zero. To get extended error information, - /// call GetLastError. - [DllImport("kernel32.dll", SetLastError = true)] - public static extern bool SetInformationJobObject( - [In] IntPtr jobHandle, - [In] JobObjectInfoClass jobObjectInfoClass, - [In] ref JobObjectInfo jobObjectInfo, - [In] int jobObjectInfoLength); - - /// - /// The CloseHandle function lets us destroy a JobObject handle. - /// - /// Handle to the job - /// If the function succeeds, the return value true. If the function - /// fails, the return value is false. To get extended error information, - /// call GetLastError. - [DllImport("kernel32.dll", SetLastError = true)] - public static extern bool CloseHandle([In] IntPtr jobHandle); - } - - #endregion - } -} diff --git a/src/DataCollectors/TraceDataCollector/Properties/AssemblyInfo.cs b/src/DataCollectors/TraceDataCollector/Properties/AssemblyInfo.cs deleted file mode 100644 index 348b5dcdfc..0000000000 --- a/src/DataCollectors/TraceDataCollector/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Reflection; -using System.Runtime.InteropServices; - -using Microsoft.VisualStudio.Coverage; -using Microsoft.VisualStudio.TestPlatform; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft Corporation")] -[assembly: AssemblyCopyright(" Microsoft Corporation. All rights reserved.")] -[assembly: AssemblyProduct("Microsoft.VisualStudio.TraceDataCollector")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("b06e12a5-025f-42aa-8f09-c6666c65ece7")] - -[assembly: TestExtensionTypes(typeof(DynamicCoverageDataCollector))] \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/Resources.Designer.cs b/src/DataCollectors/TraceDataCollector/Resources/Resources.Designer.cs deleted file mode 100644 index e4669a0a8c..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/Resources.Designer.cs +++ /dev/null @@ -1,118 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.VisualStudio.TraceDataCollector.Resources { - using System; - using System.Reflection; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.VisualStudio.TraceDataCollector.Resources.Resources", typeof(Resources).GetTypeInfo().Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to No code coverage data available. Code coverage is currently supported only on Windows.. - /// - internal static string CodeCoverageOnlySupportsWindows { - get { - return ResourceManager.GetString("CodeCoverageOnlySupportsWindows", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Failed to create directory: {0} with error:{1}. - /// - internal static string FailedToCreateDirectory { - get { - return ResourceManager.GetString("FailedToCreateDirectory", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Failed to initialize code coverage datacollector with error: {0}. - /// - internal static string FailedToInitializeCodeCoverageDataCollector { - get { - return ResourceManager.GetString("FailedToInitializeCodeCoverageDataCollector", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Running event not received from CodeCoverage.exe. Check eventlogs for failure reason.. - /// - internal static string NoRunningEventFromVanguard { - get { - return ResourceManager.GetString("NoRunningEventFromVanguard", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout.. - /// - internal static string VanguardConnectionTimeout { - get { - return ResourceManager.GetString("VanguardConnectionTimeout", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Cannot find CodeCoverage.exe at {0}. - /// - internal static string VanguardNotFound { - get { - return ResourceManager.GetString("VanguardNotFound", resourceCulture); - } - } - } -} diff --git a/src/DataCollectors/TraceDataCollector/Resources/Resources.resx b/src/DataCollectors/TraceDataCollector/Resources/Resources.resx deleted file mode 100644 index bec54d6610..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/Resources.resx +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Failed to create directory: {0} with error:{1} - - - Failed to initialize code coverage datacollector with error: {0} - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - - - Cannot find CodeCoverage.exe at {0} - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - - - No code coverage data available. Code coverage is currently supported only on Windows. - - \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.cs.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.cs.xlf deleted file mode 100644 index eb8fd00b89..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.cs.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - Adresář {0} se nepovedlo vytvořit. Chyba: {1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - Od CodeCoverage.exe se nepřijala spuštěná událost. Zkontrolujte důvod selhání v protokolech událostí. - - - - Cannot find CodeCoverage.exe at {0} - Nepovedlo se najít CodeCoverage.exe v {0} - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - Za {0} s se nepovedlo získat spuštěnou událost z CodeCoverage.exe. Důvodem může být pomalý počítač. Nastavením proměnné prostředí {1} prosím časový limit prodlužte. - - - - Failed to initialize code coverage datacollector with error: {0} - Nepovedlo se inicializovat kolekci dat pro pokrytí kódu. Chyba: {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - Data pokrytí kódu nejsou dostupná. Pokrytí kódu se momentálně podporuje jenom ve Windows. - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.de.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.de.xlf deleted file mode 100644 index e2b8f978e6..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.de.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - Fehler beim Erstellen des Verzeichnisses "{0}": {1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - Das ausgeführte Ereignis wurde von "CodeCoverage.exe" nicht erhalten. Suchen Sie in den Ereignisprotokollen nach der Fehlerursache. - - - - Cannot find CodeCoverage.exe at {0} - "CodeCoverage.exe" wurde unter "{0}" nicht gefunden. - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - Fehler beim Abrufen des ausgeführten Ereignisses von "CodeCoverage.exe" nach {0} Sekunden. Möglicherweise ist der Computer langsam. Legen Sie die Umgebungsvariable "{1}" fest, um den Timeoutwert zu erhöhen. - - - - Failed to initialize code coverage datacollector with error: {0} - Fehler beim Initialisieren des Code Coverage-Datensammlers: {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - Es sind keine Code Coverage-Daten verfügbar. Code Coverage wird zurzeit nur unter Windows unterstützt. - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.es.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.es.xlf deleted file mode 100644 index c9b840ad99..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.es.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - No se pudo crear el directorio {0} debido al error {1}. - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - No se recibió el evento en ejecución de CodeCoverage.exe. Compruebe los registros del evento para ver el motivo del error. - - - - Cannot find CodeCoverage.exe at {0} - No se encuentra el archivo CodeCoverage.exe en {0}. - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - No se pudo recibir el evento en ejecución de CodeCoverage.exe en {0} segundos. Esto puede deberse a la lentitud de la máquina. Configure la variable de entorno {1} para aumentar el tiempo de espera. - - - - Failed to initialize code coverage datacollector with error: {0} - No se pudo inicializar el recopilador de datos de la cobertura de código debido al error {0}. - - - - No code coverage data available. Code coverage is currently supported only on Windows. - No hay datos de la cobertura de código disponibles. La cobertura de código solo se admite en Windows actualmente. - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.fr.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.fr.xlf deleted file mode 100644 index 4df9ff3fc7..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.fr.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - Échec de la création du répertoire : {0} avec l’erreur :{1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - Événement en cours d’exécution non reçu de CodeCoverage.exe. Pour en connaître la raison, consultez les journaux des événements. - - - - Cannot find CodeCoverage.exe at {0} - CodeCoverage.exe introuvable à l’emplacement {0} - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - Impossible de recevoir l’événement en cours d’exécution de CodeCoverage.exe en {0} secondes. Cette situation peut se produire à cause de la lenteur de l’ordinateur. Définissez la variable d’environnement {1} de sorte à augmenter le délai d’expiration. - - - - Failed to initialize code coverage datacollector with error: {0} - Échec de l’initialisation du collecteur de données de couverture du code avec l’erreur : {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - Les données de couverture du code ne sont pas disponibles. La couverture du code est actuellement prise en charge uniquement sur Windows. - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.it.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.it.xlf deleted file mode 100644 index 410b024a3a..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.it.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - Non è stato possibile creare la directory: {0}. Errore:{1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - Evento in esecuzione non ricevuto da CodeCoverage.exe. Per la causa dell'errore, vedere i log eventi. - - - - Cannot find CodeCoverage.exe at {0} - CodeCoverage.exe non è stato trovato in {0} - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - Non è stato possibile ricevere l'evento in esecuzione da CodeCoverage.exe in {0} secondi. Questo problema può verificarsi a causa della lentezza del computer. Impostare la variabile di ambiente {1} in modo da incrementare il timeout. - - - - Failed to initialize code coverage datacollector with error: {0} - Non è stato possibile inizializzare l'agente di raccolta dati di code coverage. Errore: {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - I dati di code coverage non sono disponibili. Il code coverage è attualmente supportato solo in Windows. - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ja.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ja.xlf deleted file mode 100644 index 8be9b701e0..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ja.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - ディレクトリ {0} の作成に失敗しました。エラー: {1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - 実行中イベントが CodeCoverage.exe から受信されません。エラーの原因については、EventLog をご確認ください。 - - - - Cannot find CodeCoverage.exe at {0} - CodeCoverage.exe が次の場所に見つかりません: {0} - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - 実行中イベントを CodeCoverage.exe から {0} 秒以内に受信できませんでした。これは、マシンの遅さが原因で発生する可能性があるため、環境変数 {1} を設定してタイムアウト時間を増やしてください。 - - - - Failed to initialize code coverage datacollector with error: {0} - 次のエラーが原因で、コード カバレッジ データ コレクターを初期化できませんでした: {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - コード カバレッジ データを利用できません。現在、コード カバレッジは Windows でのみサポートされています。 - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ko.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ko.xlf deleted file mode 100644 index 4849c97766..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ko.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - 다음 오류가 발생하여 {0} 디렉터리를 만들지 못했습니다.{1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - CodeCoverage.exe에서 실행 중인 이벤트를 받지 못했습니다. 실패 원인은 이벤트 로그를 확인하세요. - - - - Cannot find CodeCoverage.exe at {0} - {0}에서 CodeCoverage.exe를 찾을 수 없습니다. - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - CodeCoverage.exe에서 실행 중인 이벤트를 {0}초 내에 받지 못했습니다. 이런 오류는 컴퓨터가 느려서 발생할 수 있습니다. 환경 변수 {1}을(를) 설정하여 시간 제한을 늘리세요. - - - - Failed to initialize code coverage datacollector with error: {0} - 다음 오류가 발생하여 코드 검사 datacollector를 초기화하지 못했습니다. {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - 사용할 수 있는 코드 검사 데이터가 없습니다. 코드 검사는 현재 Windows에서만 지원됩니다. - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.pl.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.pl.xlf deleted file mode 100644 index ead72f590e..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.pl.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - Nie można utworzyć katalogu: {0}. Błąd: {1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - Nie odebrano bieżącego zdarzenia z pliku CodeCoverage.exe. Sprawdź dziennik zdarzeń, aby poznać przyczynę niepowodzenia. - - - - Cannot find CodeCoverage.exe at {0} - Nie można znaleźć pliku CodeCoverage.exe w lokalizacji {0} - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - Nie udało się odebrać bieżącego zdarzenia z programu CodeCoverage.exe w ciągu {0} sek. Przyczyną może być wolne działanie maszyny. Aby zwiększyć limit czasu, ustaw zmienną środowiskową {1}. - - - - Failed to initialize code coverage datacollector with error: {0} - Nie udało się zainicjować modułu zbierającego dane pokrycia kodu. Błąd: {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - Dane pokrycia kodu są niedostępne. Pokrycie kodu jest obecnie obsługiwane wyłącznie w systemie Windows. - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.pt-BR.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.pt-BR.xlf deleted file mode 100644 index edee3bfe8e..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.pt-BR.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - Falha ao criar o diretório: {0} com erro:{1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - Evento de execução não recebido de CodeCoverage.exe. Verifique os logs de eventos para ver o motivo da falha. - - - - Cannot find CodeCoverage.exe at {0} - Não é possível encontrar CodeCoverage.exe em {0} - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - Falha ao receber o evento de execução de CodeCoverage.exe em {0} segundo(s). Isso pode ocorrer devido à lentidão do computador. Defina a variável de ambiente {1} para aumentar o tempo limite. - - - - Failed to initialize code coverage datacollector with error: {0} - Falha ao inicializar o datacollector de cobertura do código com o erro: {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - Nenhum dado de cobertura do código disponível. A cobertura do código é suportada atualmente apenas no Windows. - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ru.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ru.xlf deleted file mode 100644 index aeb81cf9c8..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.ru.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - Не удалось создать каталог {0}, ошибка: {1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - Выполняемое событие не получено из CodeCoverage.exe. Причину сбоя см. в журналах событий. - - - - Cannot find CodeCoverage.exe at {0} - Не удается найти CodeCoverage.exe в {0} - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - Не удалось получить выполняемое событие из CodeCoverage.exe за {0} с. Возможно, компьютер работает медленно. Увеличьте время ожидания в переменной среды {1}. - - - - Failed to initialize code coverage datacollector with error: {0} - Не удалось инициализировать сборщик данных объема протестированного кода, ошибка: {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - Нет доступных данных объема протестированного кода. Определение объема протестированного кода сейчас поддерживается только на Windows. - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.tr.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.tr.xlf deleted file mode 100644 index 203d06343f..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.tr.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - {0} dizini şu hatayla oluşturulamadı:{1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - Çalıştırılan olay CodeCoverage.exe kaynağından alınamadı. İşlemin başarısız olmasının nedenini öğrenmek için eventlogs verilerini inceleyin. - - - - Cannot find CodeCoverage.exe at {0} - CodeCoverage.exe şu konumda bulunamıyor: {0} - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - Çalıştırılan olay CodeCoverage.exe kaynağından {0} saniye içinde alınamadı. Bu durum makinenin yavaşlığından kaynaklanıyor olabilir. Zaman aşımı süresini artırmak için lütfen ortam değişkenini {1} olarak ayarlayın. - - - - Failed to initialize code coverage datacollector with error: {0} - Kod kapsamı veri toplayıcısı şu hata nedeniyle başlatılamadı: {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - Kod kapsamı verisi yok. Kod kapsamı şu anda yalnızca Windows’da destekleniyor. - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.xlf deleted file mode 100644 index ac591caaee..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.xlf +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - Failed to create directory: {0} with error:{1} - Failed to create directory: {0} with error:{1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - Running event not received from CodeCoverage.exe in {0} seconds. Check eventlogs for failure reason. This may occur due to machine slowness, please set environment variable {2} to increase timeout. - - - - Cannot find CodeCoverage.exe at {0} - Cannot find CodeCoverage.exe at {0} - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - - - - Failed to initialize code coverage datacollector with error: {0} - Failed to initialize code coverage datacollector with error: {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - Currently code coverage support available only for Windows operating system. No code coverage data available for current test run. - - - - - \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.zh-Hans.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.zh-Hans.xlf deleted file mode 100644 index 6fc42aae54..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.zh-Hans.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - 目录 {0} 创建失败,出现错误: {1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - 未收到来自 CodeCoverage.exe 的运行事件。请查看事件日志,了解失败原因。 - - - - Cannot find CodeCoverage.exe at {0} - 无法在 {0} 中找到 CodeCoverage.exe - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - 未能在 {0} 秒内接收到来自 CodeCoverage.exe 的运行事件,出现此问题可能是因为计算机性能较低,请设置环境变量 {1},增加超时时间值。 - - - - Failed to initialize code coverage datacollector with error: {0} - 无法初始化代码覆盖率 datacollector,出现错误: {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - 没有可用的代码覆盖率数据。代码覆盖率目前仅在 Windows 上受支持。 - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.zh-Hant.xlf b/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.zh-Hant.xlf deleted file mode 100644 index 4a2b746ab0..0000000000 --- a/src/DataCollectors/TraceDataCollector/Resources/xlf/Resources.zh-Hant.xlf +++ /dev/null @@ -1,55 +0,0 @@ - - - -
- - 119 - 101.15 - 101.15 - 0 - 0 - - - 0 - 0 - 0 - 0 - 0 - 119 - 0 - -
- - - Failed to create directory: {0} with error:{1} - 無法建立目錄: {0},出現錯誤:{1} - - - - Running event not received from CodeCoverage.exe. Check eventlogs for failure reason. - 正在執行並非從 CodeCoverage.exe 接收的事件。請查看事件記錄檔,以了解失敗原因。 - - - - Cannot find CodeCoverage.exe at {0} - 在 {0} 找不到 CodeCoverage.exe - - - - Failed to receive running event from CodeCoverage.exe in {0} seconds, This may occur due to machine slowness, please set environment variable {1} to increase timeout. - 未在 {0} 秒內從 CodeCoverage.exe 收到執行中的事件。可能是因為電腦太慢,請設定環境變數 {1},加長逾時。 - - - - Failed to initialize code coverage datacollector with error: {0} - 無法初始化程式碼涵蓋範圍資料收集器,錯誤為: {0} - - - - No code coverage data available. Code coverage is currently supported only on Windows. - 無任何程式碼涵蓋範圍可用。目前只有在 Windows 上才支援程式碼涵蓋範圍。 - - - -
-
\ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/DefaultCodeCoverageConfig.xml b/src/DataCollectors/TraceDataCollector/VanguardCollector/DefaultCodeCoverageConfig.xml deleted file mode 100644 index 4ead29517a..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/DefaultCodeCoverageConfig.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - .*CPPUnitTestFramework.* - .*vstest.console.* - .*microsoft.intellitrace.* - .*testhost.* - .*datacollector.* - .*microsoft.teamfoundation.testplatform.* - .*microsoft.visualstudio.testplatform.* - .*microsoft.visualstudio.testwindow.* - .*microsoft.visualstudio.mstest.* - .*microsoft.visualstudio.qualitytools.* - .*microsoft.vssdk.testhostadapter.* - .*microsoft.vssdk.testhostframework.* - .*qtagent32.* - .*msvcr.*dll$ - .*msvcp.*dll$ - .*clr.dll$ - .*clr.ni.dll$ - .*clrjit.dll$ - .*clrjit.ni.dll$ - .*mscoree.dll$ - .*mscoreei.dll$ - .*mscoreei.ni.dll$ - .*mscorlib.dll$ - .*mscorlib.ni.dll$ - .*cryptbase.dll$ - .*bcryptPrimitives.dll$ - - - True - True - True - false - - - - ^std::.* - ^ATL::.* - .*::__GetTestMethodInfo.* - .*__CxxPureMSILEntry.* - ^Microsoft::VisualStudio::CppCodeCoverageFramework::.* - ^Microsoft::VisualStudio::CppUnitTestFramework::.* - .*::YOU_CAN_ONLY_DESIGNATE_ONE_.* - ^__.* - .*::__.* - - - - - ^System.Diagnostics.DebuggerHiddenAttribute$ - ^System.Diagnostics.DebuggerNonUserCodeAttribute$ - System.Runtime.CompilerServices.CompilerGeneratedAttribute$ - ^System.CodeDom.Compiler.GeneratedCodeAttribute$ - ^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$ - ^Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode.* - - - - - .*\\atlmfc\\.* - .*\\vctools\\.* - .*\\public\\sdk\\.* - .*\\externalapis\\.* - .*\\microsoft sdks\\.* - .*\\vc\\include\\.* - .*\\msclr\\.* - .*\\ucrt\\.* - - - - - - \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollector.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollector.cs deleted file mode 100644 index 6f499016c4..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollector.cs +++ /dev/null @@ -1,259 +0,0 @@ -// 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.Coverage -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Linq; - using System.Xml; - using Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TraceCollector; - using TestPlatform.ObjectModel; - using TraceCollector.Interfaces; - using TraceDataCollector.Resources; - - /// - /// DynamicCoverageDataCollector implements BaseDataCollector for "Code Coverage" . Handles datacollector's SessionStart and SessionsEnd events - /// and provides environment variable required for code coverage profiler. - /// - [DataCollectorTypeUri("datacollector://Microsoft/CodeCoverage/2.0")] - [DataCollectorFriendlyName("Code Coverage")] - public class DynamicCoverageDataCollector : BaseDataCollector - { - private const string VanguardX86ProfilerConfigVariable = "MicrosoftInstrumentationEngine_ConfigPath32_VanguardInstrumentationProfiler"; - private const string VanguardX64ProfilerConfigVariable = "MicrosoftInstrumentationEngine_ConfigPath64_VanguardInstrumentationProfiler"; - - private const string CoreclrProfilerPathVariable32 = "CORECLR_PROFILER_PATH_32"; - private const string CoreclrProfilerPathVariable64 = "CORECLR_PROFILER_PATH_64"; - private const string CoreclrEnableProfilingVariable = "CORECLR_ENABLE_PROFILING"; - private const string CoreclrProfilerVariable = "CORECLR_PROFILER"; - private const string CorProfilerPathVariable32 = "COR_PROFILER_PATH_32"; - private const string CorProfilerPathVariable64 = "COR_PROFILER_PATH_64"; - private const string CorEnableProfilingVariable = "COR_ENABLE_PROFILING"; - private const string CorProfilerVariable = "COR_PROFILER"; - - private const string VanguardProfilerGuid = "{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}"; - private const string VanguardInstrumentationMethodGuid = "{2A1F2A34-8192-44AC-A9D8-4FCC03DCBAA8}"; - private const string ClrInstrumentationEngineProfilerGuid = "{324F817A-7420-4E6D-B3C1-143FBED6D855}"; - - private const string CodeCoverageSessionNameVariable = "CODE_COVERAGE_SESSION_NAME"; - - private const string ClrIeInstrumentationForNetCoreSettingName = "CLRIEInstrumentationNetCore"; - private const string ClrIeInstrumentationForNetFrameworkSettingName = "CLRIEInstrumentationNetFramework"; - private const string ClrIeInstrumentationForNetCoreVariable = "VANGUARD_CLR_IE_INSTRUMENTATION_NETCORE"; - private const string ClrIeInstrumentationForNetFrameworkVariable = "VANGUARD_CLR_IE_INSTRUMENTATION_NETFRAMEWORK"; - - private const string ClrIeLogLevelVariable = @"MicrosoftInstrumentationEngine_LogLevel"; - private const string ClrIeDisableCodeSignatureValidationVariable = @"MicrosoftInstrumentationEngine_DisableCodeSignatureValidation"; - private const string ClrieFileLogPathVariable = @"MicrosoftInstrumentationEngine_FileLogPath"; - - private const string InjectDotnetAdditionalDepsSettingName = "InjectDotnetAdditionalDeps"; - private const string VanguardDotnetAdditionalDepsVariable = "VANGUARD_DOTNET_ADDITIONAL_DEPS"; - - private readonly IEnvironment environment; - private bool useClrIeInstrumentationForNetCore; - private bool useClrIeInstrumentationForNetFramework; - private bool injectDotnetAdditionalDeps; - - /// - /// Data collector implementation - /// - private IDynamicCoverageDataCollectorImpl implementation; - - private IProfilersLocationProvider profilersLocationProvider; - - /// - /// To show warning on non windows. - /// - private bool isWindowsOS; - - public DynamicCoverageDataCollector() - : this( - new ProfilersLocationProvider(), - null, /* DynamicCoverageDataCollectorImpl .ctor has dependency on WinAPIs */ - new PlatformEnvironment()) - { - } - - internal DynamicCoverageDataCollector( - IProfilersLocationProvider vanguardLocationProvider, - IDynamicCoverageDataCollectorImpl dynamicCoverageDataCollectorImpl, - IEnvironment environment) - { - this.profilersLocationProvider = vanguardLocationProvider; - this.environment = environment; - - // Create DynamicCoverageDataCollectorImpl .ctor only when running on windows, because it has dependency on WinAPIs. - if (dynamicCoverageDataCollectorImpl == null) - { - this.isWindowsOS = this.environment.OperatingSystem.Equals(PlatformOperatingSystem.Windows); - if (this.isWindowsOS) - { - this.implementation = new DynamicCoverageDataCollectorImpl(); - } - } - else - { - this.isWindowsOS = true; - this.implementation = dynamicCoverageDataCollectorImpl; - } - } - - protected override void OnInitialize(XmlElement configurationElement) - { - if (this.isWindowsOS == false) - { - EqtTrace.Warning($"DynamicCoverageDataCollector.OnInitialize: Code coverage not supported for operating system: {this.environment.OperatingSystem}"); - - this.Logger.LogWarning( - this.AgentContext.SessionDataCollectionContext, - string.Format(CultureInfo.CurrentUICulture, Resources.CodeCoverageOnlySupportsWindows)); - - return; - } - - try - { - this.useClrIeInstrumentationForNetCore = IsClrInstrumentationEnabled(configurationElement, ClrIeInstrumentationForNetCoreSettingName, ClrIeInstrumentationForNetCoreVariable); - this.useClrIeInstrumentationForNetFramework = IsClrInstrumentationEnabled(configurationElement, ClrIeInstrumentationForNetFrameworkSettingName, ClrIeInstrumentationForNetFrameworkVariable); - this.injectDotnetAdditionalDeps = GetConfigurationValue(configurationElement, InjectDotnetAdditionalDepsSettingName) ?? true; - - this.implementation.Initialize(configurationElement, this.DataSink, this.Logger); - this.Events.SessionStart += this.SessionStart; - this.Events.SessionEnd += this.SessionEnd; - } - catch (Exception ex) - { - EqtTrace.Error("DynamicCoverageDataCollector.OnInitialize: Failed to initialize code coverage datacollector with exception: {0}", ex); - this.Logger.LogError( - this.AgentContext.SessionDataCollectionContext, - string.Format(CultureInfo.CurrentUICulture, Resources.FailedToInitializeCodeCoverageDataCollector, ex)); - throw; - } - } - - /// - /// Dispose. - /// - /// The disposing - protected override void Dispose(bool disposing) - { - this.Events.SessionStart -= this.SessionStart; - this.Events.SessionEnd -= this.SessionEnd; - this.implementation?.Dispose(); - base.Dispose(disposing); - } - - /// - /// The GetEnvironmentVariables - /// - /// Returns EnvironmentVariables required for code coverage profiler. - protected override IEnumerable> GetEnvironmentVariables() - { - if (this.isWindowsOS == false) - { - return Enumerable.Empty>(); - } - - var envVaribles = new List> - { - new KeyValuePair(CoreclrEnableProfilingVariable, "1"), - new KeyValuePair(CoreclrProfilerPathVariable32, this.useClrIeInstrumentationForNetCore ? this.profilersLocationProvider.GetClrInstrumentationEngineX86Path() : this.profilersLocationProvider.GetVanguardProfilerX86Path()), - new KeyValuePair(CoreclrProfilerPathVariable64, this.useClrIeInstrumentationForNetCore ? this.profilersLocationProvider.GetClrInstrumentationEngineX64Path() : this.profilersLocationProvider.GetVanguardProfilerX64Path()), - new KeyValuePair(CoreclrProfilerVariable, this.useClrIeInstrumentationForNetCore ? ClrInstrumentationEngineProfilerGuid : VanguardProfilerGuid), - new KeyValuePair(CodeCoverageSessionNameVariable, this.implementation.GetSessionName()), - new KeyValuePair(CorEnableProfilingVariable, "1"), - new KeyValuePair(CorProfilerPathVariable32, this.useClrIeInstrumentationForNetFramework ? this.profilersLocationProvider.GetClrInstrumentationEngineX86Path() : this.profilersLocationProvider.GetVanguardProfilerX86Path()), - new KeyValuePair(CorProfilerPathVariable64, this.useClrIeInstrumentationForNetFramework ? this.profilersLocationProvider.GetClrInstrumentationEngineX64Path() : this.profilersLocationProvider.GetVanguardProfilerX64Path()), - new KeyValuePair(CorProfilerVariable, this.useClrIeInstrumentationForNetFramework ? ClrInstrumentationEngineProfilerGuid : VanguardProfilerGuid), - new KeyValuePair(VanguardX86ProfilerConfigVariable, this.profilersLocationProvider.GetVanguardProfilerConfigX86Path()), - new KeyValuePair(VanguardX64ProfilerConfigVariable, this.profilersLocationProvider.GetVanguardProfilerConfigX64Path()), - }; - - if (this.useClrIeInstrumentationForNetCore || this.useClrIeInstrumentationForNetFramework) - { - envVaribles.Add(new KeyValuePair(ClrIeLogLevelVariable, "Errors")); - envVaribles.Add(new KeyValuePair($"{ClrIeLogLevelVariable}_{VanguardInstrumentationMethodGuid}", "Errors")); - envVaribles.Add(new KeyValuePair(ClrIeDisableCodeSignatureValidationVariable, "1")); - envVaribles.Add(new KeyValuePair(ClrieFileLogPathVariable, Path.Combine(Path.GetTempPath(), this.implementation.GetSessionName(), Guid.NewGuid() + ".log"))); - } - - if (this.injectDotnetAdditionalDeps && !string.IsNullOrEmpty(this.implementation.CodeCoverageDepsJsonFilePath)) - { - envVaribles.Add(new KeyValuePair(VanguardDotnetAdditionalDepsVariable, this.implementation.CodeCoverageDepsJsonFilePath)); - } - - if (EqtTrace.IsInfoEnabled) - { - EqtTrace.Info("DynamicCoverageDataCollector.GetEnvironmentVariables: Returning following environment variables: {0}", string.Join(",", envVaribles)); - } - - return envVaribles.AsReadOnly(); - } - - /// - /// Check if CLR Instrumentation Engine Instrumentation is enabled - /// - /// Data collector configuration - /// Configuration setting name - /// Environment variable name - /// If CLR IE should be enabled - private static bool IsClrInstrumentationEnabled(XmlElement configurationElement, string configurationSettingName, string environmentVariableName) - { - var clrInstrumentationEnabledByConfiguration = GetConfigurationValue(configurationElement, configurationSettingName); - - if (clrInstrumentationEnabledByConfiguration == true) - { - return true; - } - - var environmentVariableValue = Environment.GetEnvironmentVariable(environmentVariableName); - if (string.IsNullOrEmpty(environmentVariableValue)) - { - return false; - } - - return int.TryParse(environmentVariableValue, out var environmentVariableIntValue) && environmentVariableIntValue > 0; - } - - /// - /// Check flag in configuration - /// - /// Configuration - /// Configuration setting name - /// Flag value in configuration. Null if not present. - private static bool? GetConfigurationValue(XmlElement configurationElement, string configurationSettingName) - { - if (bool.TryParse(configurationElement?[configurationSettingName]?.InnerText, out var settingValue)) - { - return settingValue; - } - - return null; - } - - /// - /// On session end - /// - /// Sender - /// Event arguments - private void SessionEnd(object sender, SessionEndEventArgs e) - { - this.implementation.SessionEnd(sender, e); - } - - /// - /// On session start - /// - /// Sender - /// Event arguments - private void SessionStart(object sender, SessionStartEventArgs e) - { - this.implementation.SessionStart(sender, e); - } - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollectorImpl.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollectorImpl.cs deleted file mode 100644 index 5803d0a954..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/DynamicCoverageDataCollectorImpl.cs +++ /dev/null @@ -1,392 +0,0 @@ -// 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.Coverage -{ - using System; - using System.ComponentModel; - using System.Globalization; - using System.IO; - using System.Reflection; - using System.Xml; - using Interfaces; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TestPlatform.Utilities; - using TestPlatform.ObjectModel; - using TraceCollector; - using TraceCollector.Interfaces; - using TraceDataCollector.Resources; - using IDataCollectionSink = TraceCollector.IDataCollectionSink; - - /// - /// Create config file and output directory required for vanguard process and manages life cycle of vanguard process. - /// - internal class DynamicCoverageDataCollectorImpl : IDynamicCoverageDataCollectorImpl - { - /// - /// Name of elements under which all the config details required for vanguard process. - /// - private const string ConfigCodeCoverageElementName = "CodeCoverage"; - - /// - /// File name which contains config for vanguard process. - /// - private const string VanguardConfigFileName = "CodeCoverage.config"; - - /// - /// File name of deps.json file with reference to Microsoft.VisualStudio.CodeCoverage.Shim.dll. - /// - private const string CodeCoverageDepsJsonFileName = "CodeCoverage.deps.json"; - - /// - /// Name of element for custom coverage filename. - /// - private const string CoverageFileSettingName = "CoverageFileName"; - - private const string CodeCoverageDepsJsonTemplate = @" -{{ - ""runtimeTarget"": {{ - ""name"": ""codecoverage"", - ""signature"": """" - }}, - ""targets"": {{ - ""codecoverage"": {{ - ""Microsoft.VisualStudio.CodeCoverage.Shim/15.0.0.0"": {{ - ""runtime"": {{ - ""{0}"": {{ }} - }} - }} - }} - }}, - ""libraries"": {{ - ""Microsoft.VisualStudio.CodeCoverage.Shim/15.0.0.0"": {{ - ""type"": ""reference"", - ""serviceable"": false, - ""sha512"": """" - }} - }} -}} -"; - - /// - /// Directory helper - /// - private readonly IDirectoryHelper directoryHelper; - - /// - /// Profilers location provider - /// - private readonly IProfilersLocationProvider profilersLocationProvider; - - /// - /// File helper - /// - private readonly IFileHelper fileHelper; - - /// - /// Coverage file name - /// - private string coverageFileName; - - /// - /// Logger - /// - private IDataCollectionLogger logger; - - /// - /// Data sink - /// - private TraceCollector.IDataCollectionSink dataSink; - - /// - /// Folder to store temporary files - /// - private string sessionDirectory; - - private string coverageFilePath; - - public DynamicCoverageDataCollectorImpl() - : this(new Vanguard(), new DirectoryHelper(), new FileHelper(), new ProfilersLocationProvider()) - { - } - - internal DynamicCoverageDataCollectorImpl(IVanguard vanguard, IDirectoryHelper directoryHelper, IFileHelper fileHelper, IProfilersLocationProvider profilersLocationProvider) - { - this.Vanguard = vanguard; - this.directoryHelper = directoryHelper; - this.fileHelper = fileHelper; - this.profilersLocationProvider = profilersLocationProvider; - } - - /// - /// Gets path to deps.json file with reference to Microsoft.VisualStudio.CodeCoverage.Shim.dll. - /// - public string CodeCoverageDepsJsonFilePath { get; private set; } - - /// - /// Gets or sets session name - /// - private string SessionName { get; set; } - - /// - /// Gets or sets vanguard instance - /// - private IVanguard Vanguard { get; set; } - - public string GetSessionName() - { - return this.SessionName; - } - - /// - /// Initialize - /// - /// Configuration element - /// Data sink - /// Logger - public virtual void Initialize( - XmlElement configurationElement, - IDataCollectionSink dataSink, - IDataCollectionLogger logger) - { - var defaultConfigurationElement = DynamicCoverageDataCollectorImpl.GetDefaultConfiguration(); - - try - { - // WARNING: Do NOT remove this function call !!! - // - // Due to a dependency we took on Microsoft.TestPlatform.Utilities.dll, an - // exception may be thrown if we cannot resolve CodeCoverageRunSettingsProcessor. - // If such an exception is thrown we cannot catch it in this try-catch block - // because all method dependencies must be resolved before the method call, thus - // we introduced an additional layer of indirection. - configurationElement = this.AddDefaultExclusions(configurationElement, defaultConfigurationElement); - } - catch (Exception ex) - { - EqtTrace.Warning( - string.Format( - CultureInfo.CurrentCulture, - string.Join( - " ", - "DynamicCoverageDataCollectorImpl.Initialize: Exception encountered while processing the configuration element.", - "Keeping the configuration element unaltered. More info about the exception: {0}"), - ex.Message)); - } - - EqtTrace.Info("DynamicCoverageDataCollectorImpl.Initialize: Initialize configuration. "); - if (string.IsNullOrEmpty(configurationElement?.InnerXml)) - { - configurationElement = defaultConfigurationElement; - } - - this.logger = logger; - this.dataSink = dataSink; - - this.dataSink.SendFileCompleted += this.OnSendFileCompletedEvent; - - this.SessionName = Guid.NewGuid().ToString(); - - this.sessionDirectory = Path.Combine(Path.GetTempPath(), this.SessionName); - this.directoryHelper.CreateDirectory(this.sessionDirectory); - - this.SetCoverageFileName(configurationElement); - - this.PrepareVanguardProcess(configurationElement); - } - - /// - /// Cleanup temp folder - /// - public virtual void Dispose() - { - if (this.Vanguard != null) - { - this.Vanguard.Stop(); - this.Vanguard.Dispose(); - } - - if (this.dataSink != null) - { - this.dataSink.SendFileCompleted -= this.OnSendFileCompletedEvent; - } - - this.CleanupDirectory(); - } - - /// - /// Session start - /// - /// Sender - /// Event arguments - public void SessionStart(object sender, SessionStartEventArgs e) - { - this.StartVanguard(e.Context); - } - - /// - /// Session end - /// - /// Sender - /// Event arguments - public void SessionEnd(object sender, SessionEndEventArgs e) - { - this.StopVanguard(e.Context); - } - - /// - /// Start vanguard - /// - /// Context - protected void StartVanguard(DataCollectionContext context) - { - if (this.Vanguard != null) - { - string outputCoverageFolder = Path.Combine(this.sessionDirectory, Guid.NewGuid().ToString()); - this.CreateDirectory(context, outputCoverageFolder); - - this.coverageFilePath = Path.Combine(outputCoverageFolder, this.coverageFileName); - try - { - this.Vanguard.Start(this.coverageFilePath, context); - } - catch (Exception ex) - { - EqtTrace.Error( - "DynamicCoverageDataCollectorImpl.StartVanguard: Failed to start Vanguard for datacollection context sessionID: {0}, with exception: {1}", - context.SessionId, - ex); - this.logger.LogError(context, ex); - throw; - } - } - } - - /// - /// Stop vanguard - /// - /// Context - protected void StopVanguard(DataCollectionContext context) - { - EqtTrace.Info("DynamicCoverageDataCollectorImpl.StopVanguard: Calling Stop Vanguard. datacollection context sessionID: {0}", context.SessionId); - if (this.Vanguard != null) - { - this.Vanguard.Stop(); - - if (this.fileHelper.Exists(this.coverageFilePath)) - { - this.dataSink.SendFileAsync(context, this.coverageFilePath, false); - } - - this.Vanguard = null; - } - } - - protected void OnSendFileCompletedEvent(object sender, AsyncCompletedEventArgs e) - { - this.CleanupDirectory(); - } - - /// - /// Generate the file name for coverage file. - /// - /// Returns code coverage file name. - private static string GenerateCoverageFileName() - { - string GetUserName() - { - return Environment.GetEnvironmentVariable("USERNAME") ?? Environment.GetEnvironmentVariable("USER"); - } - - return string.Format( - CultureInfo.InvariantCulture, - "{0}_{1}_{2}.coverage", - GetUserName(), - Environment.MachineName, - DateTime.Now.ToString("yyyy-MM-dd.HH_mm_ss", CultureInfo.InvariantCulture)); - } - - private static XmlElement GetDefaultConfiguration() - { - // Add default configuration specific to CodeCoverage. https://msdn.microsoft.com/en-us/library/jj635153.aspx - var doc = new XmlDocument(); - Assembly a = typeof(DynamicCoverageDataCollectorImpl).GetTypeInfo().Assembly; - using (Stream s = a.GetManifestResourceStream( - "Microsoft.VisualStudio.TraceDataCollector.VanguardCollector.DefaultCodeCoverageConfig.xml")) - { - doc.Load(s); - } - - return doc.DocumentElement; - } - - private void SetCoverageFileName(XmlElement configurationElement) - { - XmlElement coverageFileNameElement = configurationElement[CoverageFileSettingName]; - this.coverageFileName = coverageFileNameElement != null - ? coverageFileNameElement.InnerText - : GenerateCoverageFileName(); - } - - private void PrepareVanguardProcess(XmlElement configurationElement) - { - EqtTrace.Info("DynamicCoverageDataCollectorImpl.PrepareVanguardProcess: Preparing Vanguard process."); - - XmlElement config = configurationElement[ConfigCodeCoverageElementName] - ?? DynamicCoverageDataCollectorImpl.GetDefaultConfiguration()[ConfigCodeCoverageElementName]; - - string configurationFileName = Path.Combine(this.sessionDirectory, VanguardConfigFileName); - this.fileHelper.WriteAllText(configurationFileName, config.OuterXml); - - this.CodeCoverageDepsJsonFilePath = Path.Combine(this.sessionDirectory, CodeCoverageDepsJsonFileName); - var codeCoverageDepsJsonContent = this.profilersLocationProvider.GetCodeCoverageShimPath()?.Replace(@"\", "/"); - this.fileHelper.WriteAllText(this.CodeCoverageDepsJsonFilePath, string.Format(CodeCoverageDepsJsonTemplate, codeCoverageDepsJsonContent)); - - EqtTrace.Info("DynamicCoverageDataCollectorImpl.PrepareVanguardProcess: Initializing with config: {0}.", config.OuterXml); - this.Vanguard.Initialize(this.SessionName, configurationFileName, this.logger); - } - - private void CleanupDirectory() - { - try - { - if (this.directoryHelper.Exists(this.sessionDirectory)) - { - this.directoryHelper.Delete(this.sessionDirectory, true); - } - } - catch (Exception ex) - { - EqtTrace.Warning("DynamicCoverageDataCollectorImpl.CleanupDirectory:Failed to delete directory: {0}, with exception: {1}", this.sessionDirectory, ex); - } - } - - private void CreateDirectory(DataCollectionContext context, string path) - { - try - { - this.directoryHelper.CreateDirectory(path); - } - catch (Exception ex) - { - EqtTrace.Error("DynamicCoverageDataCollectorImpl.CreateDirectory:Failed to create directory: {0}, with exception: {1}", path, ex); - this.logger.LogError( - context, - string.Format(CultureInfo.CurrentUICulture, Resources.FailedToCreateDirectory, path, ex)); - throw; - } - } - - /// - /// Adding default exclusions to the configuration element. - /// - /// The configuration element. - /// The default configuration element. - /// The original configuration element with additional default exclusions. - private XmlElement AddDefaultExclusions(XmlElement configurationElement, XmlElement defaultConfigurationElement) - { - var processor = new CodeCoverageRunSettingsProcessor(defaultConfigurationElement); - return (XmlElement)processor.Process(configurationElement); - } - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IDynamicCoverageDataCollectorImpl.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IDynamicCoverageDataCollectorImpl.cs deleted file mode 100644 index c87ff56b2a..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IDynamicCoverageDataCollectorImpl.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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.Coverage.Interfaces -{ - using System; - using System.Xml; - using TestPlatform.ObjectModel.DataCollection; - using TraceCollector; - using IDataCollectionSink = TraceCollector.IDataCollectionSink; - - /// - /// The IDynamicCoverageDataCollectorImpl interface. - /// - internal interface IDynamicCoverageDataCollectorImpl : IDisposable - { - string CodeCoverageDepsJsonFilePath { get; } - - string GetSessionName(); - - void Initialize( - XmlElement configurationElement, - IDataCollectionSink dataSink, - IDataCollectionLogger logger); - - void SessionEnd(object sender, SessionEndEventArgs sessionEndEventArgs); - - void SessionStart(object sender, SessionStartEventArgs sessionStartEventArgs); - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IProfilersLocationProvider.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IProfilersLocationProvider.cs deleted file mode 100644 index 6ca0fb672f..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IProfilersLocationProvider.cs +++ /dev/null @@ -1,59 +0,0 @@ -// 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.Coverage.Interfaces -{ - /// - /// Interface to provide vanguard and CLR IE directory and path. - /// - internal interface IProfilersLocationProvider - { - /// - /// Get path to vanguard exe - /// - /// Vanguard path - string GetVanguardPath(); - - /// - /// Get path to x86 vanguard profiler - /// - /// Vanguard x86 profiler path - string GetVanguardProfilerX86Path(); - - /// - /// Get path to x64 vanguard profiler config - /// - /// Vanguard x64 profiler config path - string GetVanguardProfilerConfigX64Path(); - - /// - /// Get path to x86 vanguard profiler config - /// - /// Vanguard x86 profiler config path - string GetVanguardProfilerConfigX86Path(); - - /// - /// Get path to x64 vanguard profiler - /// - /// Vanguard x64 profiler path - string GetVanguardProfilerX64Path(); - - /// - /// Get path to x86 CLR Instrumentation Engine - /// - /// x86 CLR IE Path - string GetClrInstrumentationEngineX86Path(); - - /// - /// Get path to x64 CLR Instrumentation Engine - /// - /// x64 CLR IE Path - string GetClrInstrumentationEngineX64Path(); - - /// - /// Get path to Microsoft.VisualStudio.CodeCoverage.Shim library - /// - /// Path to Microsoft.VisualStudio.CodeCoverage.Shim library - string GetCodeCoverageShimPath(); - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IVanguard.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IVanguard.cs deleted file mode 100644 index 3cf682e22b..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IVanguard.cs +++ /dev/null @@ -1,38 +0,0 @@ -// 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.Coverage.Interfaces -{ - using System; - using TestPlatform.ObjectModel.DataCollection; - using TraceCollector; - - /// - /// The IVanguard interface. - /// - internal interface IVanguard : IDisposable - { - /// - /// Initialize Vanguard. - /// - /// Session name - /// Configuration file name - /// Data collection logger. - void Initialize( - string sessionName, - string configurationFileName, - IDataCollectionLogger logger); - - /// - /// Start a vanguard logger. - /// - /// Output file name - /// Data collection context. - void Start(string outputName, DataCollectionContext context); - - /// - /// Stop vanguard logger. - /// - void Stop(); - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IVanguardCommandBuilder.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IVanguardCommandBuilder.cs deleted file mode 100644 index aafe00f8c5..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/IVanguardCommandBuilder.cs +++ /dev/null @@ -1,25 +0,0 @@ -// 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.Coverage.Interfaces -{ - /// - /// The IVanguardCommandBuilder interface. - /// - internal interface IVanguardCommandBuilder - { - /// - /// Generate a vanguardCommand line string, given some parameters - /// - /// VanguardCommand to execute - /// Session name - /// Output file name (for collect vanguardCommand) - /// Configuration file name - /// VanguardCommand line string - string GenerateCommandLine( - VanguardCommand vanguardCommand, - string sessionName, - string outputName, - string configurationFileName); - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/VanguardCommand.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/VanguardCommand.cs deleted file mode 100644 index b31322a807..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/Interfaces/VanguardCommand.cs +++ /dev/null @@ -1,21 +0,0 @@ -// 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.Coverage.Interfaces -{ - /// - /// Commands for vanguard process. - /// - public enum VanguardCommand - { - /// - /// Start the collecting code coverage for given session. - /// - Collect, - - /// - /// Stop the collecting code coverage for given session. - /// - Shutdown - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/ProfilersLocationProvider.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/ProfilersLocationProvider.cs deleted file mode 100644 index ce6230879a..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/ProfilersLocationProvider.cs +++ /dev/null @@ -1,108 +0,0 @@ -// 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.TraceCollector -{ - using System; - using System.Globalization; - using System.IO; - using System.Reflection; - using Coverage; - using Coverage.Interfaces; - using TraceDataCollector.Resources; - - internal class ProfilersLocationProvider : IProfilersLocationProvider - { - private const string ClrIeX86InstallDirVariable = "CLRIEX86InstallDir"; - private const string ClrIeX64InstallDirVariable = "CLRIEX64InstallDir"; - private const string ClrIeX86FileName = "MicrosoftInstrumentationEngine_x86.dll"; - private const string ClrIeX64FileName = "MicrosoftInstrumentationEngine_x64.dll"; - - private const string VanguardX86ProfilerPath = @"covrun32.dll"; - private const string VanguardX64ProfilerPath = @"amd64\covrun64.dll"; - private const string VanguardX86ProfilerConfigPath = @"VanguardInstrumentationProfiler_x86.config"; - private const string VanguardX64ProfilerConfigPath = @"amd64\VanguardInstrumentationProfiler_x64.config"; - private const string VanguardShimPath = @"coreclr\Microsoft.VisualStudio.CodeCoverage.Shim.dll"; - - /// - /// Vanguard executable name - /// - private const string VanguardExeName = @"CodeCoverage.exe"; - - /// - public string GetVanguardPath() - { - var vanguardPath = Path.Combine(this.GetVanguardDirectory(), VanguardExeName); - if (!File.Exists(vanguardPath)) - { - throw new VanguardException(string.Format(CultureInfo.CurrentUICulture, Resources.VanguardNotFound, vanguardPath)); - } - - return vanguardPath; - } - - /// - public string GetVanguardProfilerX86Path() - { - return Path.Combine(this.GetVanguardDirectory(), VanguardX86ProfilerPath); - } - - /// - public string GetVanguardProfilerX64Path() - { - return Path.Combine(this.GetVanguardDirectory(), VanguardX64ProfilerPath); - } - - /// - public string GetVanguardProfilerConfigX86Path() - { - return Path.Combine(this.GetVanguardDirectory(), VanguardX86ProfilerConfigPath); - } - - /// - public string GetVanguardProfilerConfigX64Path() - { - return Path.Combine(this.GetVanguardDirectory(), VanguardX64ProfilerConfigPath); - } - - /// - public string GetClrInstrumentationEngineX86Path() - { - return this.GetClrInstrumentationEnginePath("x86", ClrIeX86FileName, ClrIeX86InstallDirVariable); - } - - /// - public string GetClrInstrumentationEngineX64Path() - { - return this.GetClrInstrumentationEnginePath("x64", ClrIeX64FileName, ClrIeX64InstallDirVariable); - } - - /// - public string GetCodeCoverageShimPath() - { - return Path.Combine(this.GetVanguardDirectory(), VanguardShimPath); - } - - private string GetClrInstrumentationEnginePath(string arch, string fileName, string environmentVariableName) - { - var installationPath = Environment.GetEnvironmentVariable(environmentVariableName); - - if (!string.IsNullOrEmpty(installationPath)) - { - return Path.Combine(installationPath, fileName); - } - - return Path.Combine(this.GetCurrentAssemblyLocation(), "InstrumentationEngine", arch, fileName); - } - - private string GetVanguardDirectory() - { - return Path.Combine(this.GetCurrentAssemblyLocation(), "CodeCoverage"); - } - - private string GetCurrentAssemblyLocation() - { - return Path.GetDirectoryName(typeof(ProfilersLocationProvider).GetTypeInfo().Assembly.Location); - } - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/Vanguard.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/Vanguard.cs deleted file mode 100644 index 6e1e84cc84..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/Vanguard.cs +++ /dev/null @@ -1,373 +0,0 @@ -// 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.Coverage -{ - using System; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Runtime.InteropServices; - using System.Threading; - using Interfaces; - using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; - using Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection; - using Microsoft.VisualStudio.TraceCollector; - using TestPlatform.ObjectModel; - using TraceCollector.Interfaces; - using TraceDataCollector.Resources; - - /// - /// A managed wrapper for Vanguard - /// - internal class Vanguard : IVanguard - { - /// - /// Return value of WaitForSingleObject, which means the object is signaled. - /// - private const uint WaitObject0 = 0x00000000; - - /// - /// Time limit for vanguard process exit event - /// - private const int ProcessExitWaitLimit = 60000; - - /// - /// Prefix for creating event in global namespace - /// - private const string GlobalEventNamePrefix = "Global\\"; - - /// - /// Stop() will use this event to check whether the stop vanguard command - /// successful stop the collect command codecoverage.exe. - /// - private ManualResetEvent vanguardProcessExitEvent; - - /// - /// To monitor vanguard collect command CodeCoverage.exe process. - /// - private Process vanguardProcess; - - /// - /// Session name of the vanguard logger. - /// - private string sessionName; - - /// - /// Vanguard configuration file name. - /// - private string configurationFileName; - - /// - /// Vanguard output file name. - /// - private string outputName; - - /// - /// Helper object to manage child process lifetimes - /// - private IProcessJobObject processJobObject; - - /// - /// Data collection logger - /// - private IDataCollectionLogger logger; - - /// - /// Data collection context - /// - private DataCollectionContext context; - - private IProfilersLocationProvider vanguardLocationProvider; - - private IVanguardCommandBuilder vanguardCommandBuilder; - - public Vanguard() - : this(new ProfilersLocationProvider(), new VanguardCommandBuilder(), new ProcessJobObject()) - { - } - - internal Vanguard( - IProfilersLocationProvider vanguardLocationProvider, - IVanguardCommandBuilder commandBuilder, - IProcessJobObject processJobObject) - { - this.vanguardLocationProvider = vanguardLocationProvider; - this.vanguardCommandBuilder = commandBuilder; - this.processJobObject = processJobObject; - } - - /// - /// Gets a value indicating whether vanguard is running - /// - private bool IsRunning - { - get { return this.vanguardProcess != null && !this.vanguardProcess.HasExited; } - } - - /// - public void Initialize( - string sessionName, - string configurationFileName, - IDataCollectionLogger logger) - { - EqtTrace.Info("Vanguard.Initialize: Session name: {0}, config filename: {1}", sessionName, configurationFileName); - - this.sessionName = sessionName; - this.configurationFileName = configurationFileName; - this.logger = logger; - } - - /// - public virtual void Start(string outputName, DataCollectionContext context) - { - EqtTrace.Info("Vanguard.Start: Starting CodeCoverage.exe for output file: {0} datacollection session id: {1}", outputName, context.SessionId); - - this.vanguardProcessExitEvent = new ManualResetEvent(false); - this.outputName = outputName; - this.context = context; - var collectCommand = this.vanguardCommandBuilder.GenerateCommandLine( - VanguardCommand.Collect, - this.sessionName, - this.outputName, - this.configurationFileName); - - this.vanguardProcess = this.StartVanguardProcess(collectCommand, false, true); - this.WaitForRunningEvent(); - } - - /// - public virtual void Stop() - { - EqtTrace.Info("Vanguard.Stop: Stopping Vanguard."); - if (this.IsRunning) - { - var shutdownCommand = this.vanguardCommandBuilder.GenerateCommandLine( - VanguardCommand.Shutdown, - this.sessionName, - null, - null); - this.StartVanguardProcess(shutdownCommand, true); - - if (this.vanguardProcessExitEvent.WaitOne(ProcessExitWaitLimit) == false) - { - EqtTrace.Warning("Vanguard.Stop: Vanguard process not exited in {0} ms", ProcessExitWaitLimit); - } - - if (this.processJobObject != null) - { - this.processJobObject.Dispose(); - this.processJobObject = null; - } - } - } - - /// - public virtual void Dispose() - { - EqtTrace.Info("Vanguard.Dispose: Disposing vanguard process."); - if (this.vanguardProcess != null) - { - this.vanguardProcess.Dispose(); - this.vanguardProcess = null; - } - } - - /// - /// CreateEvent API - /// - /// A point to SECURITY_ATTRIBUTES structure - /// Whether the event needs manual reset - /// Initial state of the event - /// Name of the event - /// Event handle - [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] - private static extern IntPtr CreateEvent( - IntPtr lpEventAttributes, - bool bManualReset, - bool bInitialState, - string lpName); - - /// - /// Waits until one or all of the specified objects are in the signaled state or the time-out interval elapses. - /// - /// Number of handles - /// Object handles - /// Whether to wait all handles - /// Time-out interval - /// Wait result - [DllImport("kernel32.dll")] - private static extern uint WaitForMultipleObjects( - uint nCount, - IntPtr[] lpHandles, - bool bWaitAll, - uint dwMilliseconds); - - /// - /// Close a handle - /// - /// Object handle - /// True if succeeded - [DllImport("kernel32.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool CloseHandle(IntPtr hObject); - - private static int GetProcessId(Process process) - { - var id = 0; - try - { - id = process.Id; - } - catch (Exception ex) - { - EqtTrace.Info("Vanguard.GetProcessId: Fail to get process id with exception: {0}", ex); - } - - return id; - } - - /// - /// Start a vanguard process - /// - /// VanguardCommand line options - /// Whether to wait until the process exits - /// The standardErrorAsynchronousCall. - /// Process instance of vanguard - private Process StartVanguardProcess( - string commandLine, - bool wait, - bool standardErrorAsynchronousCall = false) - { - string vanguardPath = this.vanguardLocationProvider.GetVanguardPath(); - EqtTrace.Info( - "Vanguard.StartVanguardProcess: Starting {0} with command line: {1}, wait for exit:{2}, Read stderr: {3}", - vanguardPath, - commandLine, - wait, - standardErrorAsynchronousCall); - ProcessStartInfo info = new ProcessStartInfo(vanguardPath, commandLine); - info.WorkingDirectory = Directory.GetCurrentDirectory(); - info.UseShellExecute = false; - info.CreateNoWindow = true; - info.RedirectStandardError = true; - - Process process = new Process(); - process.StartInfo = info; - process.EnableRaisingEvents = true; - - if (standardErrorAsynchronousCall) - { - process.ErrorDataReceived += this.LoggerProcessErrorDataReceived; - process.Exited += this.LoggerProcessExited; - } - - process.Start(); - - if (standardErrorAsynchronousCall) - { - process.BeginErrorReadLine(); - } - - if (wait) - { - process.WaitForExit(); - } - else if (this.processJobObject != null) - { - EqtTrace.Info("Vanguard.StartVanguardProcess: Add Vanguard process to the project object"); - this.processJobObject.AddProcess(process.SafeHandle.DangerousGetHandle()); - } - - EqtTrace.Info( - "Vanguard.StartVanguardProcess: Started Vanguard process id :{0}", - Vanguard.GetProcessId(process)); - - return process; - } - - /// - /// WaitForRunningEvent until vanguard initialization is finished - /// - private void WaitForRunningEvent() - { - EqtTrace.Info("Vanguard.WaitForRunningEvent: Waiting for CodeCoverage.exe initialization."); - IntPtr runningEvent = CreateEvent( - IntPtr.Zero, - true, - false, - GlobalEventNamePrefix + this.sessionName + "_RUNNING"); - var timeout = EnvironmentHelper.GetConnectionTimeout(); - if (runningEvent != IntPtr.Zero) - { - uint waitTimeout = (uint)timeout * 1000; // Time limit for waiting for vanguard running event. - - IntPtr[] handles = new IntPtr[] { runningEvent, this.vanguardProcess.SafeHandle.DangerousGetHandle() }; - uint result = WaitForMultipleObjects((uint)handles.Length, handles, false, waitTimeout); - CloseHandle(runningEvent); - switch (result) - { - case WaitObject0: - EqtTrace.Info("Vanguard.WaitForRunningEvent: Running event received from CodeCoverage.exe."); - return; - case WaitObject0 + 1: - // Process exited, something wrong happened - // we have already set to read messages asynchronously, so calling this.vanguardProcess.StandardError.ReadToEnd() which is synchronous is wrong. - // throw new VanguardException(string.Format(CultureInfo.CurrentCulture, Resources.ErrorLaunchVanguard, this.vanguardProcess.StandardError.ReadToEnd())); - EqtTrace.Error("Vanguard.WaitForRunningEvent: From CodeCoverage.exe failed to receive running event in {0} seconds", timeout); - throw new VanguardException(string.Format(CultureInfo.CurrentUICulture, Resources.NoRunningEventFromVanguard)); - } - } - - // No running event received from code coverage.exe and not exited. Kill the CodeCoverage.exe. - try - { - EqtTrace.Error("Vanguard.WaitForRunningEvent: Fail to create running event. Killing CodeCoverage.exe. "); - this.vanguardProcess.Kill(); - } - catch (Exception ex) - { - EqtTrace.Warning("Vanguard.WaitForRunningEvent: Fail to kill CodeCoverage.exe. process with exception: {0}", ex); - } - - throw new VanguardException(string.Format(CultureInfo.CurrentUICulture, Resources.VanguardConnectionTimeout, timeout, EnvironmentHelper.VstestConnectionTimeout)); - } - - /// - /// Handler for vanguard process exit event - /// - /// The sender. - /// Event args. - private void LoggerProcessExited(object sender, EventArgs e) - { - EqtTrace.Info("Vanguard.LoggerProcessExited: Vanguard process exit callback started."); - if (this.vanguardProcess != null) - { - if (this.vanguardProcess.HasExited == true && this.vanguardProcess.ExitCode != 0) - { - EqtTrace.Warning("Vanguard.LoggerProcessExited: An error occurred in Code Coverage process. Error code = {0}", this.vanguardProcess.ExitCode); - } - - this.vanguardProcess.Exited -= this.LoggerProcessExited; - this.vanguardProcess.ErrorDataReceived -= this.LoggerProcessErrorDataReceived; - - this.vanguardProcessExitEvent.Set(); - } - } - - /// - /// Handler for vanguard process error stream - /// - /// The sender - /// Event args - private void LoggerProcessErrorDataReceived(object sender, DataReceivedEventArgs e) - { - EqtTrace.Warning("Vanguard.LoggerProcessErrorDataReceived: received error data: {0}", e.Data); - - if (this.logger != null && this.context != null && !string.IsNullOrWhiteSpace(e.Data)) - { - this.logger.LogWarning(this.context, e.Data); - } - } - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/VanguardCommandBuilder.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/VanguardCommandBuilder.cs deleted file mode 100644 index 562975f88f..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/VanguardCommandBuilder.cs +++ /dev/null @@ -1,47 +0,0 @@ -// 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.Coverage -{ - using System.Globalization; - using System.Text; - using Interfaces; - using TestPlatform.ObjectModel; - - /// - /// The VanguardCommandBuilder class. - /// - internal class VanguardCommandBuilder : IVanguardCommandBuilder - { - /// - public string GenerateCommandLine( - VanguardCommand vanguardCommand, - string sessionName, - string outputName, - string configurationFileName) - { - StringBuilder builder = new StringBuilder(); - switch (vanguardCommand) - { - case VanguardCommand.Collect: - builder.AppendFormat( - CultureInfo.InvariantCulture, - "collect /session:{0} /output:\"{1}\"", - sessionName, - outputName); - if (!string.IsNullOrEmpty(configurationFileName)) - { - builder.AppendFormat(CultureInfo.InvariantCulture, " /config:\"{0}\"", configurationFileName); - } - - break; - case VanguardCommand.Shutdown: - builder.AppendFormat(CultureInfo.InvariantCulture, "shutdown /session:{0}", sessionName); - break; - } - - EqtTrace.Info("VanguardCommandBuilder.GenerateCommandLine: Created the vanguardCommand: {0}", builder); - return builder.ToString(); - } - } -} \ No newline at end of file diff --git a/src/DataCollectors/TraceDataCollector/VanguardCollector/VanguardException.cs b/src/DataCollectors/TraceDataCollector/VanguardCollector/VanguardException.cs deleted file mode 100644 index 6e0b0efa09..0000000000 --- a/src/DataCollectors/TraceDataCollector/VanguardCollector/VanguardException.cs +++ /dev/null @@ -1,23 +0,0 @@ -// 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.Coverage -{ - using System; - - /// - /// VanguardException class - /// - internal class VanguardException : Exception - { - /// - /// Initializes a new instance of the class. - /// Constructor - /// - /// Error message - internal VanguardException(string message) - : base(message) - { - } - } -} \ No newline at end of file diff --git a/src/package/nuspec/Microsoft.CodeCoverage.nuspec b/src/package/nuspec/Microsoft.CodeCoverage.nuspec index 7028c2f603..9974431155 100644 --- a/src/package/nuspec/Microsoft.CodeCoverage.nuspec +++ b/src/package/nuspec/Microsoft.CodeCoverage.nuspec @@ -19,7 +19,7 @@ - + @@ -51,19 +51,19 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/src/package/nuspec/Microsoft.TestPlatform.nuspec b/src/package/nuspec/Microsoft.TestPlatform.nuspec index cf8b50f0d3..4a5168f3f5 100644 --- a/src/package/nuspec/Microsoft.TestPlatform.nuspec +++ b/src/package/nuspec/Microsoft.TestPlatform.nuspec @@ -266,7 +266,20 @@ - + + + + + + + + + + + + + + diff --git a/src/package/sign/sign.proj b/src/package/sign/sign.proj index fc155e16ef..ee7aae7ba3 100644 --- a/src/package/sign/sign.proj +++ b/src/package/sign/sign.proj @@ -369,20 +369,6 @@ - - - - - - - - - - - - - - diff --git a/test/DataCollectors/TraceDataCollector.UnitTests/DefaultCodeCoverageConfig.xml b/test/DataCollectors/TraceDataCollector.UnitTests/DefaultCodeCoverageConfig.xml deleted file mode 100644 index 619819d6d3..0000000000 --- a/test/DataCollectors/TraceDataCollector.UnitTests/DefaultCodeCoverageConfig.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - .*CPPUnitTestFramework.* - .*vstest.console.* - .*microsoft.intellitrace.* - .*testhost.* - .*datacollector.* - .*microsoft.teamfoundation.testplatform.* - .*microsoft.visualstudio.testplatform.* - .*microsoft.visualstudio.testwindow.* - .*microsoft.visualstudio.mstest.* - .*microsoft.visualstudio.qualitytools.* - .*microsoft.vssdk.testhostadapter.* - .*microsoft.vssdk.testhostframework.* - .*qtagent32.* - .*msvcr.*dll$ - .*msvcp.*dll$ - .*clr.dll$ - .*clr.ni.dll$ - .*clrjit.dll$ - .*clrjit.ni.dll$ - .*mscoree.dll$ - .*mscoreei.dll$ - .*mscoreei.ni.dll$ - .*mscorlib.dll$ - .*mscorlib.ni.dll$ - .*cryptbase.dll$ - .*bcryptPrimitives.dll$ - - - True - True - True - false - - - - ^std::.* - ^ATL::.* - .*::__GetTestMethodInfo.* - .*__CxxPureMSILEntry.* - ^Microsoft::VisualStudio::CppCodeCoverageFramework::.* - ^Microsoft::VisualStudio::CppUnitTestFramework::.* - .*::YOU_CAN_ONLY_DESIGNATE_ONE_.* - ^__.* - .*::__.* - - - - - ^System.Diagnostics.DebuggerHiddenAttribute$ - ^System.Diagnostics.DebuggerNonUserCodeAttribute$ - System.Runtime.CompilerServices.CompilerGeneratedAttribute$ - ^System.CodeDom.Compiler.GeneratedCodeAttribute$ - ^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$ - ^Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode.* - - - - - .*\\atlmfc\\.* - .*\\vctools\\.* - .*\\public\\sdk\\.* - .*\\externalapis\\.* - .*\\microsoft sdks\\.* - .*\\vc\\include\\.* - .*\\msclr\\.* - .*\\ucrt\\.* - - - - - diff --git a/test/DataCollectors/TraceDataCollector.UnitTests/DynamicCoverageDataCollectorImplTests.cs b/test/DataCollectors/TraceDataCollector.UnitTests/DynamicCoverageDataCollectorImplTests.cs deleted file mode 100644 index 4b1b3f182f..0000000000 --- a/test/DataCollectors/TraceDataCollector.UnitTests/DynamicCoverageDataCollectorImplTests.cs +++ /dev/null @@ -1,489 +0,0 @@ -// 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.TraceDataCollector.UnitTests -{ - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.Globalization; - using System.IO; - using System.Xml; - using Coverage; - using Coverage.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using Newtonsoft.Json; - using Newtonsoft.Json.Linq; - using TestPlatform.ObjectModel.DataCollection; - using TraceCollector; - using TraceCollector.Interfaces; - - [TestClass] - public class DynamicCoverageDataCollectorImplTests - { - private const string DefaultConfigFileName = "CodeCoverage.config"; - private const string DefaultCoverageFileName = "abc.coverage"; - - private static XmlElement sampleConfigurationElement = - DynamicCoverageDataCollectorImplTests.CreateXmlElement($@" - {DefaultCoverageFileName} - - - "); - - private DynamicCoverageDataCollectorImpl collectorImpl; - private Mock vanguardMock; - private Mock dataCollectionSinkMock; - private Mock dataCollectionLoggerMock; - private Mock directoryHelperMock; - private Mock fileHelperMock; - private Mock profilersLocationProviderMock; - - private string aConfigFileName; - private string atempDirectory; - private string tempSessionDir; - - public DynamicCoverageDataCollectorImplTests() - { - this.vanguardMock = new Mock(); - this.dataCollectionSinkMock = new Mock(); - this.dataCollectionLoggerMock = new Mock(); - this.directoryHelperMock = new Mock(); - this.fileHelperMock = new Mock(); - this.profilersLocationProviderMock = new Mock(); - this.tempSessionDir = null; - this.collectorImpl = new DynamicCoverageDataCollectorImpl(this.vanguardMock.Object, this.directoryHelperMock.Object, this.fileHelperMock.Object, this.profilersLocationProviderMock.Object); - this.SetupForInitialize(); - this.collectorImpl.Initialize(DynamicCoverageDataCollectorImplTests.sampleConfigurationElement, this.dataCollectionSinkMock.Object, this.dataCollectionLoggerMock.Object); - } - - [TestCleanup] - public void Cleanup() - { - if (this.tempSessionDir != null) - { - if (Directory.Exists(this.tempSessionDir)) - { - Directory.Delete(this.tempSessionDir, true); - } - } - } - - #region Initialize Tests - [TestMethod] - public void InitializeShouldCreateDefaultCodeCoverageSettingsIfConfigElementIsNull() - { - this.directoryHelperMock.Setup(d => d.CreateDirectory(It.IsAny())) - .Callback((path) => Directory.CreateDirectory(path)); - - this.fileHelperMock.Setup(f => f.WriteAllText(It.IsAny(), It.IsAny())) - .Callback((path, content) => { File.WriteAllText(path, content); }); - - this.collectorImpl.Initialize(null, this.dataCollectionSinkMock.Object, this.dataCollectionLoggerMock.Object); - - Assert.AreEqual(DynamicCoverageDataCollectorImplTests.DefaultConfigFileName, Path.GetFileName(this.aConfigFileName)); - StringAssert.Contains(this.aConfigFileName, Path.GetTempPath()); - this.CompareWithDefaultConfig(); - } - - [TestMethod] - public void InitializeShouldGenerateCodeCoverageDepsJsonFile() - { - this.directoryHelperMock.Setup(d => d.CreateDirectory(It.IsAny())) - .Callback((path) => Directory.CreateDirectory(path)); - - this.fileHelperMock.Setup(f => f.WriteAllText(It.IsAny(), It.IsAny())) - .Callback((path, content) => { File.WriteAllText(path, content); }); - - this.profilersLocationProviderMock.Setup(lp => lp.GetCodeCoverageShimPath()).Returns(@"C:\aaa\bbb\Microsoft.VisualStudio.CodeCoverage.Shim.dll"); - - this.collectorImpl.Initialize(null, this.dataCollectionSinkMock.Object, this.dataCollectionLoggerMock.Object); - - var obj = JObject.Parse(File.ReadAllText(this.collectorImpl.CodeCoverageDepsJsonFilePath)); - - var expected = @" -{ - ""runtimeTarget"": { - ""name"": ""codecoverage"", - ""signature"": """" - }, - ""targets"": { - ""codecoverage"": { - ""Microsoft.VisualStudio.CodeCoverage.Shim/15.0.0.0"": { - ""runtime"": { - ""C:/aaa/bbb/Microsoft.VisualStudio.CodeCoverage.Shim.dll"": { } - } - } - } - }, - ""libraries"": { - ""Microsoft.VisualStudio.CodeCoverage.Shim/15.0.0.0"": { - ""type"": ""reference"", - ""serviceable"": false, - ""sha512"": """" - } - } -}"; - - Assert.AreEqual(expected.Trim(), File.ReadAllText(this.collectorImpl.CodeCoverageDepsJsonFilePath).Trim()); - } - - [TestMethod] - public void InitializeShouldInitializeVanguardWithRightCoverageSettings() - { - XmlElement configElement = - DynamicCoverageDataCollectorImplTests.CreateXmlElement(@""); - - this.directoryHelperMock.Setup(d => d.CreateDirectory(It.IsAny())) - .Callback((path) => - { - this.tempSessionDir = path; - Directory.CreateDirectory(path); - }); - - this.fileHelperMock.Setup(f => f.WriteAllText(It.IsAny(), It.IsAny())) - .Callback((path, content) => { File.WriteAllText(path, content); }); - - this.collectorImpl.Initialize(configElement, this.dataCollectionSinkMock.Object, this.dataCollectionLoggerMock.Object); - - XmlDocument defaultDocument = new XmlDocument(); - defaultDocument.LoadXml(DynamicCoverageDataCollectorImplTests.GetDefaultCodeCoverageConfig()); - - Assert.AreEqual(DynamicCoverageDataCollectorImplTests.DefaultConfigFileName, Path.GetFileName(this.aConfigFileName)); - - XmlDocument currentDocument = new XmlDocument(); - currentDocument.LoadXml(File.ReadAllText(this.aConfigFileName)); - - var codeCoverageNodes = new Tuple(currentDocument.DocumentElement, defaultDocument.DocumentElement); - - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./ModulePaths/Exclude"); - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Functions/Exclude"); - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Attributes/Exclude"); - this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Sources/Exclude"); - } - - [TestMethod] - public void InitializeShouldInitializeDefaultConfigIfNoCodeCoverageConfigExists() - { - XmlElement configElement = - DynamicCoverageDataCollectorImplTests.CreateXmlElement($".NETCoreApp,Version=v1.1"); - - this.directoryHelperMock.Setup(d => d.CreateDirectory(It.IsAny())) - .Callback((path) => - { - this.tempSessionDir = path; - Directory.CreateDirectory(path); - }); - - this.fileHelperMock.Setup(f => f.WriteAllText(It.IsAny(), It.IsAny())) - .Callback((path, content) => { File.WriteAllText(path, content); }); - - this.collectorImpl.Initialize(configElement, this.dataCollectionSinkMock.Object, this.dataCollectionLoggerMock.Object); - - this.CompareWithDefaultConfig(); - } - - [TestMethod] - public void InitializeShouldRegisterForSendFileCompleteEvent() - { - this.directoryHelperMock.Setup(d => d.Exists(this.atempDirectory)).Returns(true); - this.dataCollectionSinkMock.Raise(s => s.SendFileCompleted += null, new AsyncCompletedEventArgs(null, false, null)); - this.directoryHelperMock.Verify(d => d.Exists(this.atempDirectory)); - this.directoryHelperMock.Verify(d => d.Delete(this.atempDirectory, true)); - } - - [TestMethod] - public void InitializeShouldCreateTempDirectoryForSession() - { - this.directoryHelperMock.Verify(d => d.CreateDirectory(this.atempDirectory)); - } - - #endregion - - #region Dispose Tests - [TestMethod] - public void DisposeShouldStopVanguard() - { - this.collectorImpl.Dispose(); - this.vanguardMock.Verify(v => v.Stop()); - } - - [TestMethod] - public void DisposeShouldDisposeVanguard() - { - this.collectorImpl.Dispose(); - this.vanguardMock.Verify(v => v.Dispose()); - } - - [TestMethod] - public void DisposeShouldDeleteTempDirectory() - { - this.directoryHelperMock.Setup(d => d.Exists(this.atempDirectory)).Returns(true); - this.collectorImpl.Dispose(); - this.directoryHelperMock.Verify(d => d.Delete(this.atempDirectory, true)); - } - - [TestMethod] - public void DisposeShouldNotDeleteTempDirectoryIfNotExists() - { - this.directoryHelperMock.Setup(d => d.Exists(this.atempDirectory)).Returns(false); - this.collectorImpl.Dispose(); - this.directoryHelperMock.Verify(d => d.Delete(this.atempDirectory, true), Times.Never); - } - - [TestMethod] - public void DisposeShouldUnregisterFileCompleteEvent() - { - this.collectorImpl.Dispose(); - this.dataCollectionSinkMock.Raise(s => s.SendFileCompleted += null, new AsyncCompletedEventArgs(null, false, null)); - this.directoryHelperMock.Verify(d => d.Exists(this.atempDirectory), Times.Once); - } - - #endregion - - #region SessionStart Tests - - [TestMethod] - public void SessionStartShouldCreateDirectoryForCoverageFile() - { - var sessionStartEventArgs = new SessionStartEventArgs(); - var coverageFilePath = string.Empty; - - this.vanguardMock.Setup(v => v.Start(It.IsAny(), It.IsAny())) - .Callback((filePath, dcContext) => - { - coverageFilePath = filePath; - }); - this.collectorImpl.SessionStart(null, sessionStartEventArgs); - - StringAssert.StartsWith(Path.GetDirectoryName(coverageFilePath), this.atempDirectory); - StringAssert.EndsWith(coverageFilePath, DynamicCoverageDataCollectorImplTests.DefaultCoverageFileName); - } - - [TestMethod] - public void SessionStartShouldUseAutoGenrateCoverageFileNameIfNotSpecified() - { - var sessionStartEventArgs = new SessionStartEventArgs(); - var coverageFilePath = string.Empty; - - this.collectorImpl.Initialize(null, this.dataCollectionSinkMock.Object, this.dataCollectionLoggerMock.Object); - this.vanguardMock.Setup(v => v.Start(It.IsAny(), It.IsAny())) - .Callback((filePath, dcContext) => - { - coverageFilePath = filePath; - }); - this.collectorImpl.SessionStart(null, sessionStartEventArgs); - - StringAssert.StartsWith(Path.GetDirectoryName(coverageFilePath), this.atempDirectory); - StringAssert.Contains(coverageFilePath, DynamicCoverageDataCollectorImplTests.GetAutoGenerageCodeCoverageFileNamePrefix()); - } - - [TestMethod] - public void SessionStartShouldLogWarningOnFailToCreateDirectory() - { - var sessionStartEventArgs = new SessionStartEventArgs(); - - var expectedErrorMessage = "Failed to create directory"; - var directoryPath = string.Empty; - - this.directoryHelperMock.Setup(d => d.CreateDirectory(It.IsAny())) - .Callback((d) => { directoryPath = d; }) - .Throws(new Exception(expectedErrorMessage)); - - var actualLoggedMessage = string.Empty; - this.dataCollectionLoggerMock.Setup(l => l.LogError(It.IsAny(), It.IsAny())) - .Callback((c, m) => { actualLoggedMessage = m; }); - - var actualErrorMessage = Assert.ThrowsException(() => this.collectorImpl.SessionStart(null, sessionStartEventArgs)).Message; - - Assert.AreEqual(expectedErrorMessage, actualErrorMessage); - - var expectedLogMessage = string.Format("Failed to create directory: {0} with error:System.Exception: {1}", directoryPath, expectedErrorMessage); - - StringAssert.StartsWith(actualLoggedMessage, expectedLogMessage); - } - - [TestMethod] - public void SessionStartShouldStartVanguard() - { - var sessionStartEventArgs = new SessionStartEventArgs(); - - this.collectorImpl.SessionStart(null, sessionStartEventArgs); - - this.vanguardMock.Verify(v => v.Start(It.IsAny(), It.IsAny())); - } - - [TestMethod] - public void SessionStartShouldLogErrorOnException() - { - var sessionStartEventArgs = new SessionStartEventArgs(); - var exceptionMessage = "Vanguard not found"; - Exception expectedEx = null; - this.vanguardMock.Setup(d => d.Start(It.IsAny(), It.IsAny())) - .Throws(new VanguardException(exceptionMessage)); - this.dataCollectionLoggerMock - .Setup(l => l.LogError(It.IsAny(), It.IsAny())) - .Callback((context, ex) => - { - expectedEx = ex; - }); - var actualEx = Assert.ThrowsException(() => this.collectorImpl.SessionStart(null, sessionStartEventArgs)); - - this.vanguardMock.Verify(v => v.Start(It.IsAny(), It.IsAny())); - Assert.AreEqual(expectedEx, actualEx); - StringAssert.Contains(actualEx.Message, exceptionMessage); - } - - #endregion - - #region SessionStart Tests - - [TestMethod] - public void SessionEndShouldStopVanguard() - { - var sessionEndEventArgs = new SessionEndEventArgs(); - - this.collectorImpl.SessionEnd(null, sessionEndEventArgs); - - this.vanguardMock.Verify(v => v.Stop()); - } - - [TestMethod] - public void SessionEndShouldSendCoverageFile() - { - string tempFile = Path.GetTempFileName(); - var sessionEndEventArgs = new SessionEndEventArgs(); - this.fileHelperMock.Setup(f => f.Exists(It.IsAny())).Returns(true); - this.collectorImpl.SessionEnd(null, sessionEndEventArgs); - - this.dataCollectionSinkMock.Verify(s => s.SendFileAsync(It.IsAny(), It.IsAny(), false)); - } - - #endregion - - internal static XmlElement CreateXmlElement(string xmlString) - { - var doc = new XmlDocument(); - using ( - var xmlReader = XmlReader.Create( - new StringReader(xmlString), - new XmlReaderSettings() { CloseInput = true, DtdProcessing = DtdProcessing.Prohibit })) - { - doc.Load(xmlReader); - } - - return doc.DocumentElement; - } - - #region private methods - - private static string GetAutoGenerageCodeCoverageFileNamePrefix() - { - string GetUserName() - { - return Environment.GetEnvironmentVariable("USERNAME") ?? Environment.GetEnvironmentVariable("USER"); - } - - return string.Format( - CultureInfo.InvariantCulture, - "{0}_{1}", - GetUserName(), - Environment.MachineName); - } - - private static string GetDefaultCodeCoverageConfig() - { - string result = string.Empty; - - using (Stream stream = typeof(DynamicCoverageDataCollectorImplTests).Assembly. - GetManifestResourceStream("Microsoft.VisualStudio.TraceDataCollector.UnitTests.DefaultCodeCoverageConfig.xml")) - { - using (StreamReader sr = new StreamReader(stream)) - { - result = sr.ReadToEnd(); - } - } - - return result; - } - - private void SetupForInitialize() - { - this.vanguardMock.Setup(v => v.Initialize( - It.IsAny(), - It.IsAny(), - It.IsAny())) - .Callback( - (sessionName, configFileName, logger) => - { - this.aConfigFileName = configFileName; - }); - - this.directoryHelperMock.Setup(d => d.CreateDirectory(It.IsAny())).Callback( - (directoryPath) => { this.atempDirectory = directoryPath; }); - } - - private void CompareWithDefaultConfig() - { - Assert.AreEqual( - DynamicCoverageDataCollectorImplTests.GetDefaultCodeCoverageConfig().Replace(" ", string.Empty) - .Replace("\r", string.Empty).Replace("\n", string.Empty), - File.ReadAllText(this.aConfigFileName).Replace(" ", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty)); - } - - private XmlNode ExtractNode(XmlNode node, string path) - { - try - { - return node.SelectSingleNode(path); - } - catch - { - } - - return null; - } - - private Tuple ExtractNodes(XmlNode currentSettingsRoot, XmlNode defaultSettingsRoot, string path) - { - var currentNode = this.ExtractNode(currentSettingsRoot, path); - var defaultNode = this.ExtractNode(defaultSettingsRoot, path); - Assert.IsNotNull(currentNode); - Assert.IsNotNull(defaultNode); - - return new Tuple(currentNode, defaultNode); - } - - private void CompareResults(XmlNode currentSettingsRoot, XmlNode defaultSettingsRoot, string path) - { - var nodes = this.ExtractNodes(currentSettingsRoot, defaultSettingsRoot, path); - - Assert.AreEqual(nodes.Item1.ChildNodes.Count, nodes.Item2.ChildNodes.Count); - - var set = new HashSet(); - foreach (XmlNode child in nodes.Item1.ChildNodes) - { - if (!set.Contains(child.OuterXml)) - { - set.Add(child.OuterXml); - } - } - - foreach (XmlNode child in nodes.Item2.ChildNodes) - { - if (!set.Contains(child.OuterXml)) - { - set.Add(child.OuterXml); - continue; - } - - set.Remove(child.OuterXml); - } - - Assert.AreEqual(set.Count, 0); - } - - #endregion - } -} diff --git a/test/DataCollectors/TraceDataCollector.UnitTests/DynamicCoverageDataCollectorTests.cs b/test/DataCollectors/TraceDataCollector.UnitTests/DynamicCoverageDataCollectorTests.cs deleted file mode 100644 index a30769e1d1..0000000000 --- a/test/DataCollectors/TraceDataCollector.UnitTests/DynamicCoverageDataCollectorTests.cs +++ /dev/null @@ -1,412 +0,0 @@ -// 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.TraceDataCollector.UnitTests -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Linq; - using System.Xml; - using Coverage; - using Coverage.Interfaces; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using TestPlatform.ObjectModel.DataCollection; - using TraceCollector; - using TraceCollector.Interfaces; - using IDataCollectionSink = TraceCollector.IDataCollectionSink; - - [TestClass] - public class DynamicCoverageDataCollectorTests - { - private const string DefaultConfig = - ".NETCoreApp,Version=v2.0x64"; - - private const string ConfigWithClrIeEnabledForNetCore = - @" - .NETCoreApp,Version=v2.0 - x64 - true - false - false - "; - - private const string ConfigWithClrIeEnabled = - @" - .NETCoreApp,Version=v2.0 - x64 - true - true - true - "; - - private TestableDynamicCoverageDataCollector collector; - private Mock vanguardLocationProviderMock; - private Mock implMock; - private Mock eventsMock; - private Mock sinkMock; - private Mock loggerMock; - private Mock agentContextMock; - private Mock environmentMock; - - public DynamicCoverageDataCollectorTests() - { - this.vanguardLocationProviderMock = new Mock(); - this.implMock = new Mock(); - this.eventsMock = new Mock(); - this.sinkMock = new Mock(); - this.loggerMock = new Mock(); - this.agentContextMock = new Mock(); - this.environmentMock = new Mock(); - this.collector = new TestableDynamicCoverageDataCollector(this.vanguardLocationProviderMock.Object, this.implMock.Object, this.environmentMock.Object); - - this.vanguardLocationProviderMock.Setup(u => u.GetVanguardProfilerX86Path()).Returns(@"covrun86"); - this.vanguardLocationProviderMock.Setup(u => u.GetVanguardProfilerX64Path()).Returns(@"covrun64"); - this.vanguardLocationProviderMock.Setup(u => u.GetVanguardProfilerConfigX86Path()).Returns(@"config86"); - this.vanguardLocationProviderMock.Setup(u => u.GetVanguardProfilerConfigX64Path()).Returns(@"config64"); - this.vanguardLocationProviderMock.Setup(u => u.GetClrInstrumentationEngineX86Path()).Returns(@"clrie86"); - this.vanguardLocationProviderMock.Setup(u => u.GetClrInstrumentationEngineX64Path()).Returns(@"clrie64"); - - this.implMock.Setup(i => i.CodeCoverageDepsJsonFilePath).Returns(@"C:\temp\codecoverage.deps.json"); - - this.environmentMock.Setup(e => e.OperatingSystem).Returns(PlatformOperatingSystem.Windows); - var configElement = DynamicCoverageDataCollectorImplTests.CreateXmlElement(DynamicCoverageDataCollectorTests.DefaultConfig); - this.collector.Initialize(configElement, this.eventsMock.Object, this.sinkMock.Object, this.loggerMock.Object, this.agentContextMock.Object); - } - - [TestCleanup] - public void CleanEnvVariables() - { - Environment.SetEnvironmentVariable("VANGUARD_CLR_IE_INSTRUMENTATION_NETCORE", null); - Environment.SetEnvironmentVariable("VANGUARD_CLR_IE_INSTRUMENTATION_NETFRAMEWORK", null); - } - - [TestMethod] - public void InitializeShouldNotThrowOnNullConfig() - { - XmlElement actualConfig = null; - this.implMock.Setup(i => i.Initialize( - It.IsAny(), - It.IsAny(), - It.IsAny())) - .Callback((config, sink, logger) => - { - actualConfig = config; - }); - - this.collector.Initialize(null, this.eventsMock.Object, this.sinkMock.Object, this.loggerMock.Object, this.agentContextMock.Object); - - Assert.IsNull(actualConfig); - } - - [TestMethod] - public void InitializeShouldLogWarningIfCurrentOperatingSystemIsUnix() - { - this.environmentMock.Setup(e => e.OperatingSystem).Returns(PlatformOperatingSystem.Unix); - this.collector = new TestableDynamicCoverageDataCollector(this.vanguardLocationProviderMock.Object, null, this.environmentMock.Object); - - this.collector.Initialize( - null, - this.eventsMock.Object, - this.sinkMock.Object, - this.loggerMock.Object, - this.agentContextMock.Object); - - var expectedExMsg = - "No code coverage data available. Code coverage is currently supported only on Windows."; - - this.loggerMock.Verify(l => l.LogWarning(It.IsAny(), expectedExMsg)); - } - - [TestMethod] - public void InitializeShouldNotRegisterForSessionEvents() - { - this.implMock = new Mock(); - this.environmentMock.Setup(e => e.OperatingSystem).Returns(PlatformOperatingSystem.Unix); - this.collector = new TestableDynamicCoverageDataCollector(this.vanguardLocationProviderMock.Object, null, this.environmentMock.Object); - - this.collector.Initialize( - null, - this.eventsMock.Object, - this.sinkMock.Object, - this.loggerMock.Object, - this.agentContextMock.Object); - - this.eventsMock.Raise(e => e.SessionStart += null, new SessionStartEventArgs()); - this.eventsMock.Raise(e => e.SessionEnd += null, new SessionEndEventArgs()); - - this.implMock.Verify(i => i.SessionStart(It.IsAny(), It.IsAny()), Times.Never); - this.implMock.Verify(i => i.SessionEnd(It.IsAny(), It.IsAny()), Times.Never); - } - - [TestMethod] - public void InitializeShouldRegisterForSessionStartEvent() - { - this.eventsMock.Raise(e => e.SessionStart += null, new SessionStartEventArgs()); - - this.implMock.Verify(i => i.SessionStart(It.IsAny(), It.IsAny())); - } - - [TestMethod] - public void InitializeShouldRegisterForSessionEndEvent() - { - this.eventsMock.Raise(e => e.SessionEnd += null, new SessionEndEventArgs()); - - this.implMock.Verify(i => i.SessionEnd(It.IsAny(), It.IsAny())); - } - - [TestMethod] - public void InitializeShouldNotLogMessageOnException() - { - var exceptionReason = "Failed to create directory"; - this.implMock.Setup(i => i.Initialize( - It.IsAny(), - It.IsAny(), - It.IsAny())) - .Throws(new Exception(exceptionReason)); - - var actualErrorMessage = string.Empty; - this.loggerMock.Setup(l => l.LogError(It.IsAny(), It.IsAny())) - .Callback((c, m) => { actualErrorMessage = m; }); - Assert.ThrowsException(() => this.collector.Initialize(null, this.eventsMock.Object, this.sinkMock.Object, this.loggerMock.Object, this.agentContextMock.Object)); - - this.loggerMock.Verify(l => l.LogError(It.IsAny(), It.IsAny()), Times.Once()); - - var expectedMessagePrefix = "Failed to initialize code coverage datacollector with error:"; - StringAssert.StartsWith(actualErrorMessage, expectedMessagePrefix); - StringAssert.Contains(actualErrorMessage, exceptionReason); - } - - [TestMethod] - public void GetEnvironmentVariablesShouldReturnRightEnvVaribles() - { - var expectedEnvVariables = new Dictionary - { - { "CORECLR_ENABLE_PROFILING", "1" }, - { "CORECLR_PROFILER_PATH_32", "covrun86" }, - { "CORECLR_PROFILER_PATH_64", "covrun64" }, - { "CORECLR_PROFILER", "{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}" }, - { "CODE_COVERAGE_SESSION_NAME", "MTM_123" }, - { "COR_PROFILER_PATH_32", "covrun86" }, - { "COR_PROFILER_PATH_64", "covrun64" }, - { "COR_ENABLE_PROFILING", "1" }, - { "COR_PROFILER", "{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}" }, - { "MicrosoftInstrumentationEngine_ConfigPath32_VanguardInstrumentationProfiler", "config86" }, - { "MicrosoftInstrumentationEngine_ConfigPath64_VanguardInstrumentationProfiler", "config64" }, - { "VANGUARD_DOTNET_ADDITIONAL_DEPS", @"C:\temp\codecoverage.deps.json" }, - }; - - this.implMock.Setup(i => i.GetSessionName()).Returns("MTM_123"); - - var envVars = this.collector.GetEnvironmentVariables(); - - VerifyEnvironmentVariables(expectedEnvVariables, envVars); - } - - [TestMethod] - public void GetEnvironmentVariablesShouldReturnRightEnvVariblesClrInstrumentationEngineEnabled() - { - var configElement = DynamicCoverageDataCollectorImplTests.CreateXmlElement(DynamicCoverageDataCollectorTests.ConfigWithClrIeEnabled); - this.collector.Initialize(configElement, this.eventsMock.Object, this.sinkMock.Object, this.loggerMock.Object, this.agentContextMock.Object); - - var expectedEnvVariables = new Dictionary - { - { "CORECLR_ENABLE_PROFILING", "1" }, - { "CORECLR_PROFILER_PATH_32", "clrie86" }, - { "CORECLR_PROFILER_PATH_64", "clrie64" }, - { "CORECLR_PROFILER", "{324F817A-7420-4E6D-B3C1-143FBED6D855}" }, - { "CODE_COVERAGE_SESSION_NAME", "MTM_123" }, - { "COR_PROFILER_PATH_32", "clrie86" }, - { "COR_PROFILER_PATH_64", "clrie64" }, - { "COR_ENABLE_PROFILING", "1" }, - { "COR_PROFILER", "{324F817A-7420-4E6D-B3C1-143FBED6D855}" }, - { "MicrosoftInstrumentationEngine_ConfigPath32_VanguardInstrumentationProfiler", "config86" }, - { "MicrosoftInstrumentationEngine_ConfigPath64_VanguardInstrumentationProfiler", "config64" }, - { "MicrosoftInstrumentationEngine_LogLevel", "Errors" }, - { "MicrosoftInstrumentationEngine_LogLevel_{2A1F2A34-8192-44AC-A9D8-4FCC03DCBAA8}", "Errors" }, - { "MicrosoftInstrumentationEngine_DisableCodeSignatureValidation", "1" }, - { "MicrosoftInstrumentationEngine_FileLogPath", @"GENERATED" }, - { "VANGUARD_DOTNET_ADDITIONAL_DEPS", @"C:\temp\codecoverage.deps.json" } - }; - - this.implMock.Setup(i => i.GetSessionName()).Returns("MTM_123"); - - var envVars = this.collector.GetEnvironmentVariables(); - - VerifyEnvironmentVariables(expectedEnvVariables, envVars); - } - - [TestMethod] - public void GetEnvironmentVariablesShouldReturnRightEnvVariblesClrInstrumentationEngineEnabledThroughEnvVars() - { - Environment.SetEnvironmentVariable("VANGUARD_CLR_IE_INSTRUMENTATION_NETCORE", "1"); - Environment.SetEnvironmentVariable("VANGUARD_CLR_IE_INSTRUMENTATION_NETFRAMEWORK", "1"); - - var configElement = DynamicCoverageDataCollectorImplTests.CreateXmlElement(DynamicCoverageDataCollectorTests.DefaultConfig); - this.collector.Initialize(configElement, this.eventsMock.Object, this.sinkMock.Object, this.loggerMock.Object, this.agentContextMock.Object); - - var expectedEnvVariables = new Dictionary - { - { "CORECLR_ENABLE_PROFILING", "1" }, - { "CORECLR_PROFILER_PATH_32", "clrie86" }, - { "CORECLR_PROFILER_PATH_64", "clrie64" }, - { "CORECLR_PROFILER", "{324F817A-7420-4E6D-B3C1-143FBED6D855}" }, - { "CODE_COVERAGE_SESSION_NAME", "MTM_123" }, - { "COR_PROFILER_PATH_32", "clrie86" }, - { "COR_PROFILER_PATH_64", "clrie64" }, - { "COR_ENABLE_PROFILING", "1" }, - { "COR_PROFILER", "{324F817A-7420-4E6D-B3C1-143FBED6D855}" }, - { "MicrosoftInstrumentationEngine_ConfigPath32_VanguardInstrumentationProfiler", "config86" }, - { "MicrosoftInstrumentationEngine_ConfigPath64_VanguardInstrumentationProfiler", "config64" }, - { "MicrosoftInstrumentationEngine_LogLevel", "Errors" }, - { "MicrosoftInstrumentationEngine_LogLevel_{2A1F2A34-8192-44AC-A9D8-4FCC03DCBAA8}", "Errors" }, - { "MicrosoftInstrumentationEngine_DisableCodeSignatureValidation", "1" }, - { "MicrosoftInstrumentationEngine_FileLogPath", @"GENERATED" }, - { "VANGUARD_DOTNET_ADDITIONAL_DEPS", @"C:\temp\codecoverage.deps.json" } - }; - - this.implMock.Setup(i => i.GetSessionName()).Returns("MTM_123"); - - var envVars = this.collector.GetEnvironmentVariables(); - - VerifyEnvironmentVariables(expectedEnvVariables, envVars); - } - - [TestMethod] - public void GetEnvironmentVariablesShouldReturnRightEnvVariblesClrInstrumentationEngineEnabledForNetCore() - { - var configElement = DynamicCoverageDataCollectorImplTests.CreateXmlElement(DynamicCoverageDataCollectorTests.ConfigWithClrIeEnabledForNetCore); - this.collector.Initialize(configElement, this.eventsMock.Object, this.sinkMock.Object, this.loggerMock.Object, this.agentContextMock.Object); - - var expectedEnvVariables = new Dictionary - { - { "CORECLR_ENABLE_PROFILING", "1" }, - { "CORECLR_PROFILER_PATH_32", "clrie86" }, - { "CORECLR_PROFILER_PATH_64", "clrie64" }, - { "CORECLR_PROFILER", "{324F817A-7420-4E6D-B3C1-143FBED6D855}" }, - { "CODE_COVERAGE_SESSION_NAME", "MTM_123" }, - { "COR_PROFILER_PATH_32", "covrun86" }, - { "COR_PROFILER_PATH_64", "covrun64" }, - { "COR_ENABLE_PROFILING", "1" }, - { "COR_PROFILER", "{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}" }, - { "MicrosoftInstrumentationEngine_ConfigPath32_VanguardInstrumentationProfiler", "config86" }, - { "MicrosoftInstrumentationEngine_ConfigPath64_VanguardInstrumentationProfiler", "config64" }, - { "MicrosoftInstrumentationEngine_LogLevel", "Errors" }, - { "MicrosoftInstrumentationEngine_LogLevel_{2A1F2A34-8192-44AC-A9D8-4FCC03DCBAA8}", "Errors" }, - { "MicrosoftInstrumentationEngine_DisableCodeSignatureValidation", "1" }, - { "MicrosoftInstrumentationEngine_FileLogPath", @"GENERATED" } - }; - - this.implMock.Setup(i => i.GetSessionName()).Returns("MTM_123"); - - var envVars = this.collector.GetEnvironmentVariables(); - - VerifyEnvironmentVariables(expectedEnvVariables, envVars); - } - - [TestMethod] - public void GetEnvironmentVariablesShouldReturnRightEnvVariblesClrInstrumentationEngineEnabledForNetCoreThroughEnvVar() - { - Environment.SetEnvironmentVariable("VANGUARD_CLR_IE_INSTRUMENTATION_NETCORE", "1"); - Environment.SetEnvironmentVariable("VANGUARD_CLR_IE_INSTRUMENTATION_NETFRAMEWORK", "0"); - - var configElement = DynamicCoverageDataCollectorImplTests.CreateXmlElement(DynamicCoverageDataCollectorTests.DefaultConfig); - this.collector.Initialize(configElement, this.eventsMock.Object, this.sinkMock.Object, this.loggerMock.Object, this.agentContextMock.Object); - - var expectedEnvVariables = new Dictionary - { - { "CORECLR_ENABLE_PROFILING", "1" }, - { "CORECLR_PROFILER_PATH_32", "clrie86" }, - { "CORECLR_PROFILER_PATH_64", "clrie64" }, - { "CORECLR_PROFILER", "{324F817A-7420-4E6D-B3C1-143FBED6D855}" }, - { "CODE_COVERAGE_SESSION_NAME", "MTM_123" }, - { "COR_PROFILER_PATH_32", "covrun86" }, - { "COR_PROFILER_PATH_64", "covrun64" }, - { "COR_ENABLE_PROFILING", "1" }, - { "COR_PROFILER", "{E5F256DC-7959-4DD6-8E4F-C11150AB28E0}" }, - { "MicrosoftInstrumentationEngine_ConfigPath32_VanguardInstrumentationProfiler", "config86" }, - { "MicrosoftInstrumentationEngine_ConfigPath64_VanguardInstrumentationProfiler", "config64" }, - { "MicrosoftInstrumentationEngine_LogLevel", "Errors" }, - { "MicrosoftInstrumentationEngine_LogLevel_{2A1F2A34-8192-44AC-A9D8-4FCC03DCBAA8}", "Errors" }, - { "MicrosoftInstrumentationEngine_DisableCodeSignatureValidation", "1" }, - { "MicrosoftInstrumentationEngine_FileLogPath", @"GENERATED" }, - { "VANGUARD_DOTNET_ADDITIONAL_DEPS", @"C:\temp\codecoverage.deps.json" } - }; - - this.implMock.Setup(i => i.GetSessionName()).Returns("MTM_123"); - - var envVars = this.collector.GetEnvironmentVariables(); - - VerifyEnvironmentVariables(expectedEnvVariables, envVars); - } - - [TestMethod] - public void GetEnvironmentVariablesShouldReturnNoEnvVaribles() - { - this.implMock = new Mock(); - this.environmentMock.Setup(e => e.OperatingSystem).Returns(PlatformOperatingSystem.Unix); - this.collector = new TestableDynamicCoverageDataCollector(this.vanguardLocationProviderMock.Object, null, this.environmentMock.Object); - - this.collector.Initialize( - null, - this.eventsMock.Object, - this.sinkMock.Object, - this.loggerMock.Object, - this.agentContextMock.Object); - var envVars = this.collector.GetEnvironmentVariables(); - - Assert.IsFalse(envVars.Any(), "No environment variables set on unix."); - } - - [TestMethod] - public void DisposeShouldDisposeImpl() - { - this.collector.Dispose(); - this.implMock.Verify(i => i.Dispose()); - } - - [TestMethod] - public void DisposeShouldUnsubcribeEvents() - { - this.collector.Dispose(); - this.eventsMock.Raise(e => e.SessionStart += null, new SessionStartEventArgs()); - this.eventsMock.Raise(e => e.SessionEnd += null, new SessionEndEventArgs()); - - this.implMock.Verify(i => i.SessionStart(It.IsAny(), It.IsAny()), Times.Never); - this.implMock.Verify(i => i.SessionEnd(It.IsAny(), It.IsAny()), Times.Never); - } - - private static void VerifyEnvironmentVariables(Dictionary expectedEnvVariables, IEnumerable> envVars) - { - foreach (var pair in envVars) - { - Console.WriteLine(pair.Key + " ==> " + pair.Value); - } - - Assert.AreEqual(expectedEnvVariables.Count, envVars.Count()); - - foreach (var pair in envVars) - { - Assert.IsTrue(expectedEnvVariables.ContainsKey(pair.Key), $"unexpected env variable {pair}"); - Assert.IsTrue(pair.Key == "MicrosoftInstrumentationEngine_FileLogPath" || expectedEnvVariables[pair.Key].Equals(pair.Value), $"unexpected env variable {pair}"); - } - } - - private class TestableDynamicCoverageDataCollector : DynamicCoverageDataCollector - { - public TestableDynamicCoverageDataCollector( - IProfilersLocationProvider vanguardLocationProvider, - IDynamicCoverageDataCollectorImpl impl, - IEnvironment environment) - : base(vanguardLocationProvider, impl, environment) - { - } - - public new IEnumerable> GetEnvironmentVariables() - { - return base.GetEnvironmentVariables(); - } - } - } -} diff --git a/test/DataCollectors/TraceDataCollector.UnitTests/Microsoft.TestPlatform.TraceDataCollector.UnitTests.csproj b/test/DataCollectors/TraceDataCollector.UnitTests/Microsoft.TestPlatform.TraceDataCollector.UnitTests.csproj deleted file mode 100644 index c38d997b27..0000000000 --- a/test/DataCollectors/TraceDataCollector.UnitTests/Microsoft.TestPlatform.TraceDataCollector.UnitTests.csproj +++ /dev/null @@ -1,30 +0,0 @@ - - - - ..\..\..\ - true - true - - - - Microsoft.VisualStudio.TraceDataCollector.UnitTests - - - netcoreapp2.1 - true - true - Exe - Microsoft.TestPlatform.TraceDataCollector.UnitTests - - - - - - - - - - - - - diff --git a/test/DataCollectors/TraceDataCollector.UnitTests/ProfilersLocationProviderTests.cs b/test/DataCollectors/TraceDataCollector.UnitTests/ProfilersLocationProviderTests.cs deleted file mode 100644 index 74a3c46ac1..0000000000 --- a/test/DataCollectors/TraceDataCollector.UnitTests/ProfilersLocationProviderTests.cs +++ /dev/null @@ -1,119 +0,0 @@ -// 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.TraceDataCollector.UnitTests -{ - using System; - using System.IO; - using System.Reflection; - using TestTools.UnitTesting; - using TraceCollector; - - [TestClass] - [TestCategory("Windows")] - public class ProfilersLocationProviderTests - { - private ProfilersLocationProvider vanguardLocationProvider; - - public ProfilersLocationProviderTests() - { - this.vanguardLocationProvider = new ProfilersLocationProvider(); - } - - [TestCleanup] - public void CleanEnvVariables() - { - Environment.SetEnvironmentVariable("CLRIEX86InstallDir", null); - Environment.SetEnvironmentVariable("CLRIEX64InstallDir", null); - } - - [TestMethod] - public void GetVanguardPathShouldReturnRightPath() - { - var actualPath = this.vanguardLocationProvider.GetVanguardPath(); - - Assert.AreEqual(Path.Join(this.GetCurrentAssemblyLocation(), @"CodeCoverage\CodeCoverage.exe"), actualPath); - } - - [TestMethod] - public void GetVanguardProfilerX86PathShouldReturnRightDirectory() - { - var actualPath = this.vanguardLocationProvider.GetVanguardProfilerX86Path(); - - Assert.AreEqual(Path.Join(this.GetCurrentAssemblyLocation(), @"CodeCoverage\covrun32.dll"), actualPath); - } - - [TestMethod] - public void GetVanguardProfilerX64PathShouldReturnRightDirectory() - { - var actualPath = this.vanguardLocationProvider.GetVanguardProfilerX64Path(); - - Assert.AreEqual(Path.Join(this.GetCurrentAssemblyLocation(), @"CodeCoverage\amd64\covrun64.dll"), actualPath); - } - - [TestMethod] - public void GetVanguardProfilerConfigX86PathShouldReturnRightDirectory() - { - var actualPath = this.vanguardLocationProvider.GetVanguardProfilerConfigX86Path(); - - Assert.AreEqual(Path.Join(this.GetCurrentAssemblyLocation(), @"CodeCoverage\VanguardInstrumentationProfiler_x86.config"), actualPath); - } - - [TestMethod] - public void GetVanguardProfilerConfigX64PathShouldReturnRightDirectory() - { - var actualPath = this.vanguardLocationProvider.GetVanguardProfilerConfigX64Path(); - - Assert.AreEqual(Path.Join(this.GetCurrentAssemblyLocation(), @"CodeCoverage\amd64\VanguardInstrumentationProfiler_x64.config"), actualPath); - } - - [TestMethod] - public void GetCodeCoverageShimPathShouldReturnRightDirectory() - { - var actualPath = this.vanguardLocationProvider.GetCodeCoverageShimPath(); - - Assert.AreEqual(Path.Join(this.GetCurrentAssemblyLocation(), @"CodeCoverage\coreclr\Microsoft.VisualStudio.CodeCoverage.Shim.dll"), actualPath); - } - - [TestMethod] - public void GetClrInstrumentationEngineX86PathShouldReturnRightDirectory() - { - var actualDir = this.vanguardLocationProvider.GetClrInstrumentationEngineX86Path(); - - Assert.AreEqual(Path.Join(this.GetCurrentAssemblyLocation(), @"InstrumentationEngine\x86\MicrosoftInstrumentationEngine_x86.dll"), actualDir); - } - - [TestMethod] - public void GetClrInstrumentationEngineX64PathShouldReturnRightDirectory() - { - var actualDir = this.vanguardLocationProvider.GetClrInstrumentationEngineX64Path(); - - Assert.AreEqual(Path.Join(this.GetCurrentAssemblyLocation(), @"InstrumentationEngine\x64\MicrosoftInstrumentationEngine_x64.dll"), actualDir); - } - - [TestMethod] - public void GetClrInstrumentationEngineX86PathShouldReturnRightDirectoryIfEnvVariableSet() - { - Environment.SetEnvironmentVariable("CLRIEX86InstallDir", @"C:\temp"); - - var actualDir = this.vanguardLocationProvider.GetClrInstrumentationEngineX86Path(); - - Assert.AreEqual(@"C:\temp\MicrosoftInstrumentationEngine_x86.dll", actualDir); - } - - [TestMethod] - public void GetClrInstrumentationEngineX64PathShouldReturnRightDirectoryIfEnvVariableSet() - { - Environment.SetEnvironmentVariable("CLRIEX64InstallDir", @"C:\temp"); - - var actualDir = this.vanguardLocationProvider.GetClrInstrumentationEngineX64Path(); - - Assert.AreEqual(@"C:\temp\MicrosoftInstrumentationEngine_x64.dll", actualDir); - } - - private string GetCurrentAssemblyLocation() - { - return Path.GetDirectoryName(typeof(ProfilersLocationProviderTests).GetTypeInfo().Assembly.Location); - } - } -} diff --git a/test/DataCollectors/TraceDataCollector.UnitTests/Program.cs b/test/DataCollectors/TraceDataCollector.UnitTests/Program.cs deleted file mode 100644 index 7f39953476..0000000000 --- a/test/DataCollectors/TraceDataCollector.UnitTests/Program.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -namespace Microsoft.VisualStudio.TestPlatform.Common.DataCollector.UnitTests -{ - /// - /// Main entry point for the command line runner. - /// - public static class Program - { - public static void Main(string[] args) - { - } - } -} \ No newline at end of file diff --git a/test/DataCollectors/TraceDataCollector.UnitTests/Properties/AssemblyInfo.cs b/test/DataCollectors/TraceDataCollector.UnitTests/Properties/AssemblyInfo.cs deleted file mode 100644 index fb892d21e1..0000000000 --- a/test/DataCollectors/TraceDataCollector.UnitTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("datacollector.UnitTests")] -[assembly: AssemblyTrademark("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("00aa21f3-31e4-4748-ac0b-c4eadb41ca24")] diff --git a/test/DataCollectors/TraceDataCollector.UnitTests/VanguardCommandBuilderTests.cs b/test/DataCollectors/TraceDataCollector.UnitTests/VanguardCommandBuilderTests.cs deleted file mode 100644 index 26b9e6ec94..0000000000 --- a/test/DataCollectors/TraceDataCollector.UnitTests/VanguardCommandBuilderTests.cs +++ /dev/null @@ -1,50 +0,0 @@ -// 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.TraceDataCollector.UnitTests -{ - using Coverage; - using Coverage.Interfaces; - using TestTools.UnitTesting; - - [TestClass] - public class VanguardCommandBuilderTests - { - private VanguardCommandBuilder vanguardCommandBuilder; - - public VanguardCommandBuilderTests() - { - this.vanguardCommandBuilder = new VanguardCommandBuilder(); - } - - [TestMethod] - public void GenerateCommandLineShouldReturnCommandForCollectCommand() - { - string sessionName = "session1", outputName = "output1", configFileName = "configFileName1"; - string expectedCommand = $"collect /session:{sessionName} /output:\"{outputName}\" /config:\"{configFileName}\""; - - var actualCommand = this.vanguardCommandBuilder.GenerateCommandLine( - VanguardCommand.Collect, - sessionName, - outputName, - configFileName); - - Assert.AreEqual(expectedCommand, actualCommand); - } - - [TestMethod] - public void GenerateCommandLineShouldReturnCommandForShutdownCommand() - { - string sessionName = "session1"; - string expectedCommand = $"shutdown /session:{sessionName}"; - - var actualCommand = this.vanguardCommandBuilder.GenerateCommandLine( - VanguardCommand.Shutdown, - sessionName, - null, - null); - - Assert.AreEqual(expectedCommand, actualCommand); - } - } -} diff --git a/test/DataCollectors/TraceDataCollector.UnitTests/VanguardTests.cs b/test/DataCollectors/TraceDataCollector.UnitTests/VanguardTests.cs deleted file mode 100644 index e4d567e866..0000000000 --- a/test/DataCollectors/TraceDataCollector.UnitTests/VanguardTests.cs +++ /dev/null @@ -1,204 +0,0 @@ -// 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.TraceDataCollector.UnitTests -{ - using System; - using System.ComponentModel; - using System.Globalization; - using System.IO; - using System.Text; - using System.Threading; - using Coverage; - using Coverage.Interfaces; - using global::TestPlatform.TestUtilities; - using Microsoft.VisualStudio.TestTools.UnitTesting; - using Moq; - using TestPlatform.CoreUtilities.Helpers; - using TestPlatform.ObjectModel; - using TestPlatform.ObjectModel.DataCollection; - using TraceCollector; - using TraceCollector.Interfaces; - - [TestClass] - [TestCategory("Windows")] - public class VanguardTests - { - private const string CodeCoverageExeFileName = "CodeCoverage"; - private const string ConfigFileNameFormat = - @"{0}\{1}\CodeCoverage.config"; // {TempDirPath}\{Session_GUID}\CodeCoverage.config - - private const string ConfigXml = - @" - - - .*Tests.dll - - - True - True - True - False - - "; - - private Vanguard vanguard; - private string sessionName; - private string configFileName; - private Mock dataCollectionLoggerMock; - private Mock vanguardLocationProviderMock; - private string outputFileName; - private string outputDir; - private DataCollectionContext dataCollectionContext; - private Mock vanguardCommandBuilderMock; - private IProcessJobObject processJobObject; - - public VanguardTests() - { - TestCase testcase = new TestCase { Id = Guid.NewGuid() }; - this.dataCollectionContext = new DataCollectionContext(testcase); - this.dataCollectionLoggerMock = new Mock(); - this.processJobObject = new ProcessJobObject(); - this.vanguardCommandBuilderMock = new Mock(); - this.vanguardLocationProviderMock = new Mock(); - - this.vanguard = new Vanguard(this.vanguardLocationProviderMock.Object, this.vanguardCommandBuilderMock.Object, this.processJobObject); - this.sessionName = Guid.NewGuid().ToString(); - this.configFileName = string.Format(VanguardTests.ConfigFileNameFormat, Path.GetTempPath(), this.sessionName); - this.outputDir = Path.GetDirectoryName(this.configFileName); - Directory.CreateDirectory(this.outputDir); - File.WriteAllText(this.configFileName, VanguardTests.ConfigXml); - this.outputFileName = Path.Combine(this.outputDir, Guid.NewGuid() + ".coverage"); - this.vanguardCommandBuilderMock.Setup(c => - c.GenerateCommandLine(VanguardCommand.Shutdown, this.sessionName, It.IsAny(), It.IsAny())) - .Returns(VanguardTests.GetShutdownCommand(this.sessionName)); - this.vanguard.Initialize(this.sessionName, this.configFileName, this.dataCollectionLoggerMock.Object); - this.vanguardLocationProviderMock.Setup(c => c.GetVanguardPath()).Returns(Path.Combine(Directory.GetCurrentDirectory(), "CodeCoverage", "CodeCoverage.exe")); - } - - [TestCleanup] - public void Cleanup() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, string.Empty); - this.vanguard.Stop(); - File.Delete(this.configFileName); - Directory.Delete(this.outputDir, true); - } - - [TestMethod] - public void InitializeShouldCreateConfigFile() - { - Assert.IsTrue(File.Exists(this.configFileName)); - StringAssert.Contains( - VanguardTests.ConfigXml.Replace(" ", string.Empty).Replace(Environment.NewLine, string.Empty), - File.ReadAllText(this.configFileName).Replace(" ", string.Empty).Replace(Environment.NewLine, string.Empty)); - } - - [Ignore] - [TestMethod] - public void StartShouldStartVanguardProcessWithCollectCommand() - { - var cts = new CancellationTokenSource(); - var numOfProcessCreatedTask = NumberOfProcessLaunchedUtility.NumberOfProcessCreated( - cts, - VanguardTests.CodeCoverageExeFileName); - - this.vanguardCommandBuilderMock.Setup(c => - c.GenerateCommandLine(VanguardCommand.Collect, It.IsAny(), It.IsAny(), It.IsAny())) - .Returns(VanguardTests.GetCollectCommand(this.sessionName, this.outputFileName, this.configFileName)); - - this.vanguard.Start(this.outputFileName, this.dataCollectionContext); - cts.Cancel(); - - var numOfProcessCreated = numOfProcessCreatedTask.Result.Count; - - // TODO find the reason why additional process launched when collecting code coverage. - Assert.IsTrue(numOfProcessCreated == 1 || numOfProcessCreated == 2, $"Number of process created:{numOfProcessCreated} expected is 1 or 2."); - } - - [TestMethod] - [ExpectedException(typeof(Win32Exception))] - public void StartShouldThrowOnInvalidVarguardPath() - { - this.vanguardLocationProviderMock.Setup(c => c.GetVanguardPath()).Returns(Path.Combine(Directory.GetCurrentDirectory(), "WrongExePath.exe")); - this.vanguard.Start(this.outputFileName, this.dataCollectionContext); - } - - [TestMethod] - public void StartShouldThrowOnInvalidCommandLine() - { - var expectedErrorMessage = - "Running event not received from CodeCoverage.exe. Check eventlogs for failure reason."; - this.vanguardCommandBuilderMock - .Setup(c => c.GenerateCommandLine( - VanguardCommand.Collect, - It.IsAny(), - It.IsAny(), - It.IsAny())).Returns("invalid command"); - var exception = Assert.ThrowsException(() => this.vanguard.Start(this.outputFileName, this.dataCollectionContext)); - Assert.AreEqual(expectedErrorMessage, exception.Message); - } - - [TestMethod] - [Ignore("This test is flaky")] - public void StartShouldThrowOnTimeout() - { - Environment.SetEnvironmentVariable(EnvironmentHelper.VstestConnectionTimeout, "0"); - var expectedErrorMessage = - "Failed to receive running event from CodeCoverage.exe in 0 seconds, This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout."; - this.vanguardCommandBuilderMock - .Setup(c => c.GenerateCommandLine( - VanguardCommand.Collect, - It.IsAny(), - It.IsAny(), - It.IsAny())).Returns(VanguardTests.GetCollectCommand(this.sessionName, this.outputFileName, this.configFileName)); - var exception = Assert.ThrowsException(() => this.vanguard.Start(this.outputFileName, this.dataCollectionContext)); - Assert.AreEqual(expectedErrorMessage, exception.Message); - } - - [Ignore] - [TestMethod] - public void StopShouldLaunchVarguardWithShutdownCommand() - { - var cts = new CancellationTokenSource(); - var numOfProcessCreatedTask = NumberOfProcessLaunchedUtility.NumberOfProcessCreated( - cts, - VanguardTests.CodeCoverageExeFileName); - this.vanguardCommandBuilderMock - .Setup(c => c.GenerateCommandLine( - VanguardCommand.Collect, - It.IsAny(), - It.IsAny(), - It.IsAny())).Returns(VanguardTests.GetCollectCommand(this.sessionName, this.outputFileName, this.configFileName)); - this.vanguard.Start(this.outputFileName, this.dataCollectionContext); - this.vanguard.Stop(); - cts.Cancel(); - - var numOfProcessCreated = numOfProcessCreatedTask.Result.Count; - - // TODO find the reason why additional process launched when collecting code coverage. - Assert.IsTrue(numOfProcessCreated == 2 || numOfProcessCreated == 4, $"Number of process created:{numOfProcessCreated} expected is 2 or 4."); - } - - private static string GetCollectCommand(string sessionName, string outputName, string configurationFileName) - { - StringBuilder builder = new StringBuilder(); - builder.AppendFormat( - CultureInfo.InvariantCulture, - "collect /session:{0} /output:\"{1}\" /config:\"{2}\"", - sessionName, - outputName, - configurationFileName); - - return builder.ToString(); - } - - private static string GetShutdownCommand(string sessionName) - { - StringBuilder builder = new StringBuilder(); - builder.AppendFormat(CultureInfo.InvariantCulture, "shutdown /session:{0}", sessionName); - - return builder.ToString(); - } - } -} diff --git a/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageTests.cs b/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageTests.cs index 06f6038722..53c191bc10 100644 --- a/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageTests.cs +++ b/test/Microsoft.TestPlatform.AcceptanceTests/CodeCoverageTests.cs @@ -204,7 +204,7 @@ private string CreateArguments( var assemblyPaths = this.GetAssetFullPath(testParameters.AssemblyName); string traceDataCollectorDir = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, - "src", "DataCollectors", "TraceDataCollector", "bin", IntegrationTestEnvironment.BuildConfiguration, "netstandard2.0"); + "artifacts", IntegrationTestEnvironment.BuildConfiguration, "Microsoft.CodeCoverage"); string diagFileName = Path.Combine(this.resultsDirectory, "diaglog.txt"); var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty,