From 39912c7bcd3a381c06833ef6bb3fb58f8ae3f794 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 7 Oct 2022 17:34:34 +0200 Subject: [PATCH 1/6] search prod dump using environment variables --- ...ft.TestPlatform.Execution.Shared.projitems | 1 + .../ProcDumpExecutableHelper.cs | 117 ++++++++++++++++++ .../ProcDumpDumper.cs | 98 ++------------- .../PublicAPI/PublicAPI.Shipped.txt | 2 +- .../Processors/AeDebuggerArgumentProcessor.cs | 74 +++++++---- .../Resources/Resources.Designer.cs | 2 +- src/vstest.console/Resources/Resources.resx | 2 +- .../Resources/xlf/Resources.cs.xlf | 2 +- .../Resources/xlf/Resources.de.xlf | 2 +- .../Resources/xlf/Resources.es.xlf | 2 +- .../Resources/xlf/Resources.fr.xlf | 2 +- .../Resources/xlf/Resources.it.xlf | 2 +- .../Resources/xlf/Resources.ja.xlf | 2 +- .../Resources/xlf/Resources.ko.xlf | 2 +- .../Resources/xlf/Resources.pl.xlf | 2 +- .../Resources/xlf/Resources.pt-BR.xlf | 2 +- .../Resources/xlf/Resources.ru.xlf | 2 +- .../Resources/xlf/Resources.tr.xlf | 2 +- .../Resources/xlf/Resources.xlf | 2 +- .../Resources/xlf/Resources.zh-Hans.xlf | 2 +- .../Resources/xlf/Resources.zh-Hant.xlf | 2 +- .../AeDebuggerArgumentProcessorTest.cs | 28 ++++- 22 files changed, 217 insertions(+), 135 deletions(-) create mode 100644 src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs diff --git a/src/Microsoft.TestPlatform.Execution.Shared/Microsoft.TestPlatform.Execution.Shared.projitems b/src/Microsoft.TestPlatform.Execution.Shared/Microsoft.TestPlatform.Execution.Shared.projitems index de0ddc3ab4..2269ef03d4 100644 --- a/src/Microsoft.TestPlatform.Execution.Shared/Microsoft.TestPlatform.Execution.Shared.projitems +++ b/src/Microsoft.TestPlatform.Execution.Shared/Microsoft.TestPlatform.Execution.Shared.projitems @@ -10,6 +10,7 @@ + diff --git a/src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs b/src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs new file mode 100644 index 0000000000..7baaa1b33f --- /dev/null +++ b/src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs @@ -0,0 +1,117 @@ +// 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; +using System.IO; + +using Microsoft.VisualStudio.TestPlatform.CoreUtilities; +using Microsoft.VisualStudio.TestPlatform.ObjectModel; +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; + +using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; +using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; + +namespace Microsoft.VisualStudio.TestPlatform.Execution; + +internal class ProcDumpExecutableHelper +{ + private const string ProcdumpUnixProcess = "procdump"; + + private readonly IProcessHelper _processHelper; + private readonly IFileHelper _fileHelper; + private readonly IEnvironment _environment; + private readonly IEnvironmentVariableHelper _environmentVariableHelper; + + public ProcDumpExecutableHelper(IProcessHelper processHelper, IFileHelper fileHelper, IEnvironment environment, IEnvironmentVariableHelper environmentVariableHelper) + { + _processHelper = processHelper; + _fileHelper = fileHelper; + _environment = environment; + _environmentVariableHelper = environmentVariableHelper; + } + + public static string ProcDumpFileName(PlatformArchitecture architecture) => + architecture switch + { + PlatformArchitecture.X86 => "procdump.exe", + PlatformArchitecture.ARM64 => "procdump64a.exe", + _ => "procdump64.exe", + }; + + public bool TryGetProcDumpExecutable(out string path) + { + // Use machien architecture + var targetProcessArchitecture = _environment.Architecture; + return TryGetProcDumpExecutable(targetProcessArchitecture, out path); + } + + public bool TryGetProcDumpExecutable(int processId, out string path) + { + // Launch proc dump according to process architecture + var targetProcessArchitecture = _processHelper.GetProcessArchitecture(processId); + return TryGetProcDumpExecutable(targetProcessArchitecture, out path); + } + + public bool TryGetProcDumpExecutable(PlatformArchitecture architecture, out string path) + { + var procdumpDirectory = _environmentVariableHelper.GetEnvironmentVariable("PROCDUMP_PATH"); + var searchPath = false; + if (procdumpDirectory.IsNullOrWhiteSpace()) + { + EqtTrace.Verbose("ProcDumpExecutableHelper.GetProcDumpExecutable: PROCDUMP_PATH env variable is empty will try to run ProcDump from PATH."); + searchPath = true; + } + else if (!_fileHelper.DirectoryExists(procdumpDirectory)) + { + EqtTrace.Verbose($"ProcDumpExecutableHelper.GetProcDumpExecutable: PROCDUMP_PATH env variable '{procdumpDirectory}' is not a directory, or the directory does not exist. Will try to run ProcDump from PATH."); + searchPath = true; + } + + string filename = _environment.OperatingSystem == PlatformOperatingSystem.Windows + ? ProcDumpFileName(architecture) + : _environment.OperatingSystem is PlatformOperatingSystem.Unix or PlatformOperatingSystem.OSX + ? ProcdumpUnixProcess + : throw new NotSupportedException($"Not supported platform {_environment.OperatingSystem}"); + + if (!searchPath) + { + var candidatePath = Path.Combine(procdumpDirectory!, filename); + if (_fileHelper.Exists(candidatePath)) + { + EqtTrace.Verbose($"ProcDumpExecutableHelper.GetProcDumpExecutable: Path to ProcDump '{candidatePath}' exists, using that."); + path = candidatePath; + return true; + } + + EqtTrace.Verbose($"ProcDumpExecutableHelper.GetProcDumpExecutable: Path '{candidatePath}' does not exist will try to run {filename} from PATH."); + } + + if (TryGetExecutablePath(filename, out var p)) + { + EqtTrace.Verbose($"ProcDumpExecutableHelper.GetProcDumpExecutable: Resolved {filename} to {p} from PATH."); + path = p; + return true; + } + + EqtTrace.Verbose($"ProcDumpExecutableHelper.GetProcDumpExecutable: Could not find {filename} on PATH."); + path = filename; + return false; + } + + private bool TryGetExecutablePath(string executable, out string executablePath) + { + executablePath = string.Empty; + var pathString = _environmentVariableHelper.GetEnvironmentVariable("PATH") ?? string.Empty; + foreach (string path in pathString.Split(Path.PathSeparator)) + { + string exeFullPath = Path.Combine(path.Trim(), executable); + if (_fileHelper.Exists(exeFullPath)) + { + executablePath = exeFullPath; + return true; + } + } + + return false; + } +} diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs index 0752e9a95a..451c635a77 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs @@ -9,6 +9,8 @@ using System.IO; using System.Linq; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Execution; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; @@ -29,6 +31,7 @@ public class ProcDumpDumper : ICrashDumper, IHangDumper private readonly IProcessHelper _processHelper; private readonly IFileHelper _fileHelper; private readonly IEnvironment _environment; + private readonly IEnvironmentVariableHelper _environmentVariableHelper; private Process? _procDumpProcess; private string? _tempDirectory; private string? _dumpFileName; @@ -38,15 +41,16 @@ public class ProcDumpDumper : ICrashDumper, IHangDumper private string? _outputFilePrefix; public ProcDumpDumper() - : this(new ProcessHelper(), new FileHelper(), new PlatformEnvironment()) + : this(new ProcessHelper(), new FileHelper(), new PlatformEnvironment(), new EnvironmentVariableHelper()) { } - public ProcDumpDumper(IProcessHelper processHelper, IFileHelper fileHelper, IEnvironment environment) + public ProcDumpDumper(IProcessHelper processHelper, IFileHelper fileHelper, IEnvironment environment, IEnvironmentVariableHelper environmentVariableHelper) { _processHelper = processHelper; _fileHelper = fileHelper; _environment = environment; + _environmentVariableHelper = environmentVariableHelper; } [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Part of the public API")] @@ -86,7 +90,7 @@ public void AttachToTargetProcess(int processId, string outputDirectory, DumpTyp throw new InvalidOperationException("Procdump crash dump file must end with .dmp extension."); } - if (!TryGetProcDumpExecutable(processId, out var procDumpPath)) + if (!new ProcDumpExecutableHelper(_processHelper, _fileHelper, _environment, _environmentVariableHelper).TryGetProcDumpExecutable(processId, out var procDumpPath)) { var procdumpNotFound = string.Format(CultureInfo.CurrentCulture, Resources.Resources.ProcDumpNotFound, procDumpPath); logWarning(procdumpNotFound); @@ -205,7 +209,7 @@ public void Dump(int processId, string outputDirectory, DumpTypeOption dumpType) throw new InvalidOperationException("Procdump crash dump file must end with .dmp extension."); } - if (!TryGetProcDumpExecutable(processId, out var procDumpPath)) + if (!new ProcDumpExecutableHelper(_processHelper, _fileHelper, _environment, _environmentVariableHelper).TryGetProcDumpExecutable(processId, out var procDumpPath)) { var err = $"{procDumpPath} could not be found, please set PROCDUMP_PATH environment variable to a directory that contains {procDumpPath} executable, or make sure that the executable is available on PATH."; ConsoleOutput.Instance.Warning(false, err); @@ -237,90 +241,4 @@ public void Dump(int processId, string outputDirectory, DumpTypeOption dumpType) EqtTrace.Info($"ProcDumpDumper.Dump: ProcDump finished hang dumping process with id '{processId}'."); } - - /// - /// Try get proc dump executable path from env variable or PATH, if it does not success the result is false, and the name of the exe we tried to find. - /// - /// - /// Process Id to determine the bittness - /// - /// - /// Path to procdump or the name of the executable we tried to resolve when we don't find it - /// - /// proc dump executable path - private bool TryGetProcDumpExecutable(int processId, out string path) - { - var procdumpDirectory = Environment.GetEnvironmentVariable("PROCDUMP_PATH"); - var searchPath = false; - if (procdumpDirectory.IsNullOrWhiteSpace()) - { - EqtTrace.Verbose("ProcDumpDumper.GetProcDumpExecutable: PROCDUMP_PATH env variable is empty will try to run ProcDump from PATH."); - searchPath = true; - } - else if (!Directory.Exists(procdumpDirectory)) - { - EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: PROCDUMP_PATH env variable '{procdumpDirectory}' is not a directory, or the directory does not exist. Will try to run ProcDump from PATH."); - searchPath = true; - } - - string filename; - if (_environment.OperatingSystem == PlatformOperatingSystem.Windows) - { - // Launch proc dump according to process architecture - var targetProcessArchitecture = _processHelper.GetProcessArchitecture(processId); - filename = targetProcessArchitecture switch - { - PlatformArchitecture.X86 => "procdump.exe", - PlatformArchitecture.ARM64 => "procdump64a.exe", - _ => "procdump64.exe", - }; - } - else - { - filename = _environment.OperatingSystem is PlatformOperatingSystem.Unix or PlatformOperatingSystem.OSX - ? Constants.ProcdumpUnixProcess - : throw new NotSupportedException($"Not supported platform {_environment.OperatingSystem}"); - } - - if (!searchPath) - { - var candidatePath = Path.Combine(procdumpDirectory!, filename); - if (File.Exists(candidatePath)) - { - EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Path to ProcDump '{candidatePath}' exists, using that."); - path = candidatePath; - return true; - } - - EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Path '{candidatePath}' does not exist will try to run {filename} from PATH."); - } - - if (TryGetExecutablePath(filename, out var p)) - { - EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Resolved {filename} to {p} from PATH."); - path = p; - return true; - } - - EqtTrace.Verbose($"ProcDumpDumper.GetProcDumpExecutable: Could not find {filename} on PATH."); - path = filename; - return false; - } - - private bool TryGetExecutablePath(string executable, out string executablePath) - { - executablePath = string.Empty; - var pathString = Environment.GetEnvironmentVariable("PATH") ?? string.Empty; - foreach (string path in pathString.Split(Path.PathSeparator)) - { - string exeFullPath = Path.Combine(path.Trim(), executable); - if (_fileHelper.Exists(exeFullPath)) - { - executablePath = exeFullPath; - return true; - } - } - - return false; - } } diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/PublicAPI/PublicAPI.Shipped.txt b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/PublicAPI/PublicAPI.Shipped.txt index a5ac44b058..f60f15447c 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/PublicAPI/PublicAPI.Shipped.txt +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/PublicAPI/PublicAPI.Shipped.txt @@ -71,7 +71,7 @@ Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.Dump(int pro Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.GetDumpFiles(bool processCrashed) -> System.Collections.Generic.IEnumerable! Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.OutputReceivedCallback.get -> System.Action! Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.ProcDumpDumper() -> void -Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.ProcDumpDumper(Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces.IProcessHelper! processHelper, Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces.IFileHelper! fileHelper, Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces.IEnvironment! environment) -> void +Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.ProcDumpDumper(Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces.IProcessHelper! processHelper, Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces.IFileHelper! fileHelper, Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces.IEnvironment! environment, Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces.IEnvironmentVariableHelper! environmentVariableHelper) -> void Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.WaitForDumpToFinish() -> void Microsoft.TestPlatform.Extensions.BlameDataCollector.Win32NamedEvent Microsoft.TestPlatform.Extensions.BlameDataCollector.Win32NamedEvent.Set() -> void diff --git a/src/vstest.console/Processors/AeDebuggerArgumentProcessor.cs b/src/vstest.console/Processors/AeDebuggerArgumentProcessor.cs index c76cd78234..f743f516c9 100644 --- a/src/vstest.console/Processors/AeDebuggerArgumentProcessor.cs +++ b/src/vstest.console/Processors/AeDebuggerArgumentProcessor.cs @@ -10,6 +10,8 @@ using System.Linq; using Microsoft.VisualStudio.TestPlatform.CommandLine.Processors.Utilities; +using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers; +using Microsoft.VisualStudio.TestPlatform.Execution; using Microsoft.VisualStudio.TestPlatform.ObjectModel.Utilities; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; @@ -31,7 +33,7 @@ internal class AeDebuggerArgumentProcessor : IArgumentProcessor public Lazy? Executor { get => _executor ??= new Lazy(() => - new AeDebuggerArgumentExecutor(new PlatformEnvironment(), new FileHelper(), new ProcessHelper(), ConsoleOutput.Instance)); + new AeDebuggerArgumentExecutor(new PlatformEnvironment(), new FileHelper(), new ProcessHelper(), ConsoleOutput.Instance, new EnvironmentVariableHelper())); set => _executor = value; } @@ -67,15 +69,17 @@ internal class AeDebuggerArgumentExecutor : IArgumentExecutor private readonly IFileHelper _fileHelper; private readonly IProcessHelper _processHelper; private readonly IOutput _output; + private readonly IEnvironmentVariableHelper _environmentVariableHelper; private string? _argument; private Dictionary? _collectDumpParameters; - public AeDebuggerArgumentExecutor(IEnvironment environment, IFileHelper fileHelper, IProcessHelper processHelper, IOutput output) + public AeDebuggerArgumentExecutor(IEnvironment environment, IFileHelper fileHelper, IProcessHelper processHelper, IOutput output, IEnvironmentVariableHelper environmentVariableHelper) { _environment = environment ?? throw new ArgumentNullException(nameof(environment)); _fileHelper = fileHelper ?? throw new ArgumentNullException(nameof(fileHelper)); _processHelper = processHelper ?? throw new ArgumentNullException(nameof(processHelper)); _output = output ?? throw new ArgumentNullException(nameof(output)); + _environmentVariableHelper = environmentVariableHelper ?? throw new ArgumentNullException(nameof(environmentVariableHelper)); } public void Initialize(string? argument) => _argument = argument; @@ -123,21 +127,31 @@ private ArgumentProcessorResult InstallUnistallPostmortemDebugger(bool install) return ArgumentProcessorResult.Fail; } - // Validate ProcDumpToolDirectoryPath - if (!TryGetDirectoryInfo(_collectDumpParameters, - "ProcDumpToolDirectoryPath", - CommandLineResources.ProcDumpToolDirectoryPathArgumenNotFound, - CommandLineResources.InvalidProcDumpToolDirectoryPath, - out DirectoryInfo? procDumpToolDirectoryPath)) + // Look for procdump + string? procDumpPath = null; + if (!TryGetDirectoryInfo(_collectDumpParameters, "ProcDumpToolDirectoryPath", out DirectoryInfo? procDumpToolDirectoryPath) && + !new ProcDumpExecutableHelper(_processHelper, _fileHelper, _environment, _environmentVariableHelper).TryGetProcDumpExecutable(out procDumpPath) + ) { + _output.Error(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidProcDumpToolDirectoryPath)); + return ArgumentProcessorResult.Fail; + } + + if (procDumpPath is null && procDumpToolDirectoryPath is not null) + { + procDumpPath = Path.Combine(procDumpToolDirectoryPath.FullName, ProcDumpExecutableHelper.ProcDumpFileName(_environment.Architecture)); + } + + if (procDumpPath is null) + { + _output.Error(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.ProcDumpFileNameNotFound, procDumpPath)); return ArgumentProcessorResult.Fail; } // Looking for procdump*.exe - FileInfo procDumpFileName = new(Path.Combine(procDumpToolDirectoryPath.FullName, ProcDumpFileName())); - if (!_fileHelper.Exists(procDumpFileName.FullName)) + if (!_fileHelper.Exists(procDumpPath)) { - _output.Error(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.ProcDumpFileNameNotFound, procDumpFileName.FullName)); + _output.Error(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.ProcDumpFileNameNotFound, procDumpPath)); return ArgumentProcessorResult.Fail; } @@ -145,7 +159,7 @@ private ArgumentProcessorResult InstallUnistallPostmortemDebugger(bool install) if (install) { // Validate ProcDumpDirectoryPath - if (!TryGetDirectoryInfo(_collectDumpParameters, + if (!TryGetDirectoryInfoAndReportToOutput(_collectDumpParameters, "DumpDirectoryPath", CommandLineResources.ProcDumpDirectoryPathArgumenNotFound, CommandLineResources.InvalidProcDumpDirectoryPath, @@ -157,7 +171,7 @@ private ArgumentProcessorResult InstallUnistallPostmortemDebugger(bool install) procDumpInstallUnistallArgument = dumpDirectoryPath.FullName; } - if (_processHelper.LaunchProcess(procDumpFileName.FullName, install ? "-ma -i" : "-u", procDumpInstallUnistallArgument, null, + if (_processHelper.LaunchProcess(procDumpPath, install ? "-ma -i" : "-u", procDumpInstallUnistallArgument, null, (_, data) => { if (data is not null && !StringUtilities.IsNullOrWhiteSpace(data)) @@ -183,15 +197,7 @@ private ArgumentProcessorResult InstallUnistallPostmortemDebugger(bool install) // We suppose a success if the object returned by the LaunchProcess is not a Process object. return ArgumentProcessorResult.Success; - string ProcDumpFileName() => - _processHelper.GetCurrentProcessArchitecture() switch - { - PlatformArchitecture.X86 => "procdump.exe", - PlatformArchitecture.ARM64 => "procdump64a.exe", - _ => "procdump64.exe", - }; - - bool TryGetDirectoryInfo(Dictionary collectDumpParameters, + bool TryGetDirectoryInfoAndReportToOutput(Dictionary collectDumpParameters, string directoryArgumentName, string invalidArgumentErrorMessage, string invalidDirectoryErrorMessage, @@ -221,6 +227,30 @@ bool TryGetDirectoryInfo(Dictionary collectDumpParameters, return true; } + + bool TryGetDirectoryInfo(Dictionary collectDumpParameters, string directoryArgumentName, [NotNullWhen(true)] out DirectoryInfo? directoryInfo) + { + directoryInfo = null; + + if (!collectDumpParameters.TryGetValue(directoryArgumentName, out string? directoryPath)) + { + return false; + } + + if (directoryPath is null) + { + return false; + } + + directoryInfo = new(directoryPath); + if (!_fileHelper.DirectoryExists(directoryInfo.FullName)) + { + directoryInfo = null; + return false; + } + + return true; + } } } diff --git a/src/vstest.console/Resources/Resources.Designer.cs b/src/vstest.console/Resources/Resources.Designer.cs index 1b5aa9870b..61cecdd3c2 100644 --- a/src/vstest.console/Resources/Resources.Designer.cs +++ b/src/vstest.console/Resources/Resources.Designer.cs @@ -859,7 +859,7 @@ internal static string InvalidProcDumpDirectoryPath { } /// - /// Looks up a localized string similar to The directory specified is not valid: '{0}'. + /// Looks up a localized string similar to The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH). /// internal static string InvalidProcDumpToolDirectoryPath { get { diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index f4638cc23c..413a01b927 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -761,7 +761,7 @@ Postmortem debugger is not supported in the current OS. - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index 3aee9ba8e5..dbdaac1a38 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -1210,7 +1210,7 @@ - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index d749440907..e127b7a939 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -1210,7 +1210,7 @@ - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index 26a64b43ad..90c7ee7dfe 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -1213,7 +1213,7 @@ - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index 5fabb61fc3..3148f61b8b 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -1210,7 +1210,7 @@ Comportements actuellement pris en charge : - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index da3099dbba..649b626b1c 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -1210,7 +1210,7 @@ - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index a2af9460dd..b13b4f6002 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -1210,7 +1210,7 @@ - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index 8765fe950b..c395d779fe 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -1210,7 +1210,7 @@ - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index 2bad9edd7c..b95288bb09 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -1210,7 +1210,7 @@ - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index 52ed3b9f76..0f6fd645c4 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -1210,7 +1210,7 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index f6576ade2a..1823e62c51 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -1210,7 +1210,7 @@ - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index 781772ec4b..a6d839616a 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -1210,7 +1210,7 @@ Günlükler için izleme düzeyini aşağıda gösterildiği gibi değiştirin - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index e3c822c1b0..18fafb5188 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -1004,7 +1004,7 @@ Format : TestRunParameters.Parameter(name="<name>", value="<value>") - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index c4c28ba139..f619a54ea8 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -1210,7 +1210,7 @@ - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index 851944d827..9ff75ea0c9 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -1210,7 +1210,7 @@ - The directory specified is not valid: '{0}' + The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/test/vstest.console.UnitTests/Processors/AeDebuggerArgumentProcessorTest.cs b/test/vstest.console.UnitTests/Processors/AeDebuggerArgumentProcessorTest.cs index 41daddbd58..8fb031ca0d 100644 --- a/test/vstest.console.UnitTests/Processors/AeDebuggerArgumentProcessorTest.cs +++ b/test/vstest.console.UnitTests/Processors/AeDebuggerArgumentProcessorTest.cs @@ -25,11 +25,12 @@ public class AeDebuggerArgumentProcessorTest private readonly Mock _fileHelper = new(); private readonly Mock _processHelper = new(); private readonly Mock _output = new(); + private readonly Mock _environmentVariableHelper = new(); private readonly AeDebuggerArgumentExecutor _executor; public AeDebuggerArgumentProcessorTest() { - _executor = new AeDebuggerArgumentExecutor(_environment.Object, _fileHelper.Object, _processHelper.Object, _output.Object); + _executor = new AeDebuggerArgumentExecutor(_environment.Object, _fileHelper.Object, _processHelper.Object, _output.Object, _environmentVariableHelper.Object); } [TestMethod] @@ -58,10 +59,11 @@ public void AeDebuggerArgumentProcessorReturnsCorrectTypes() [TestMethod] public void AeDebuggerArgumentExecutor_InvalidCtor() { - Assert.ThrowsException(() => new AeDebuggerArgumentExecutor(_environment.Object, _fileHelper.Object, _processHelper.Object, null!)); - Assert.ThrowsException(() => new AeDebuggerArgumentExecutor(_environment.Object, _fileHelper.Object, null!, _output.Object)); - Assert.ThrowsException(() => new AeDebuggerArgumentExecutor(_environment.Object, null!, _processHelper.Object, _output.Object)); - Assert.ThrowsException(() => new AeDebuggerArgumentExecutor(null!, _fileHelper.Object, _processHelper.Object, _output.Object)); + Assert.ThrowsException(() => new AeDebuggerArgumentExecutor(_environment.Object, _fileHelper.Object, _processHelper.Object, _output.Object, null!)); + Assert.ThrowsException(() => new AeDebuggerArgumentExecutor(_environment.Object, _fileHelper.Object, _processHelper.Object, null!, _environmentVariableHelper.Object)); + Assert.ThrowsException(() => new AeDebuggerArgumentExecutor(_environment.Object, _fileHelper.Object, null!, _output.Object, _environmentVariableHelper.Object)); + Assert.ThrowsException(() => new AeDebuggerArgumentExecutor(_environment.Object, null!, _processHelper.Object, _output.Object, _environmentVariableHelper.Object)); + Assert.ThrowsException(() => new AeDebuggerArgumentExecutor(null!, _fileHelper.Object, _processHelper.Object, _output.Object, _environmentVariableHelper.Object)); } [TestMethod] @@ -100,11 +102,25 @@ public void AeDebuggerArgumentExecutor_WrongDirectoryPaths(string command, strin _fileHelper.Setup(x => x.DirectoryExists(It.IsAny())) .Returns((string path) => directoryPath is null || !directoryPath.EndsWith(path)); _fileHelper.Setup(x => x.Exists(It.IsAny())) - .Returns((string path) => path.EndsWith("procdump.exe")); + .Returns((string path) => path.EndsWith("procdump.exe") && path != "procdump.exe"); _executor.Initialize(string.Format(CultureInfo.InvariantCulture, command, directoryPath)); Assert.AreEqual(ArgumentProcessorResult.Fail, _executor.Execute()); } + [TestMethod] + [DataRow("Install;DumpDirectoryPath=c:\\DumpDirectoryPath", "PROCDUMP_PATH", "c:\\procDump")] + [DataRow("Install;DumpDirectoryPath=c:\\DumpDirectoryPath", "PATH", "c:\\procDump;")] + + public void AeDebuggerArgumentExecutor_ShouldUseEnvironmentVariables(string command, string environmentVariablesKey, string environmentVariableValue) + { + _environmentVariableHelper.Setup(x => x.GetEnvironmentVariable(environmentVariablesKey)).Returns(environmentVariableValue); + _fileHelper.Setup(x => x.DirectoryExists("c:\\procDump")).Returns(true); + _fileHelper.Setup(x => x.DirectoryExists("c:\\DumpDirectoryPath")).Returns(true); + _fileHelper.Setup(x => x.Exists(It.IsAny())).Returns((string fileName) => fileName == "c:\\procDump\\procdump.exe"); + _executor.Initialize(command); + Assert.AreEqual(ArgumentProcessorResult.Success, _executor.Execute()); + } + [TestMethod] [DataRow("Install;ProcDumpToolDirectoryPath=c:\\ProcDumpToolDirectoryPath;DumpDirectoryPath=c:\\DumpDirectoryPath", true)] [DataRow("Uninstall;ProcDumpToolDirectoryPath=c:\\ProcDumpToolDirectoryPath;DumpDirectoryPath=c:\\DumpDirectoryPath", false)] From 8c46e725ddf2f5c175ba236e3b436a06980e8621 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 7 Oct 2022 17:43:44 +0200 Subject: [PATCH 2/6] fix build --- .../ProcDumpDumper.cs | 10 +++++++++- .../PublicAPI/PublicAPI.Shipped.txt | 2 +- src/vstest.console/Resources/xlf/Resources.cs.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.de.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.es.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.fr.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.it.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.ja.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.ko.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.pl.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.pt-BR.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.ru.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.tr.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf | 2 +- src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf | 2 +- 16 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs index 451c635a77..5d371c29e1 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs @@ -45,7 +45,15 @@ public ProcDumpDumper() { } - public ProcDumpDumper(IProcessHelper processHelper, IFileHelper fileHelper, IEnvironment environment, IEnvironmentVariableHelper environmentVariableHelper) + public ProcDumpDumper(IProcessHelper processHelper, IFileHelper fileHelper, IEnvironment environment) : + this(processHelper, fileHelper, environment, new EnvironmentVariableHelper()) + { + _processHelper = processHelper; + _fileHelper = fileHelper; + _environment = environment; + } + + internal ProcDumpDumper(IProcessHelper processHelper, IFileHelper fileHelper, IEnvironment environment, IEnvironmentVariableHelper environmentVariableHelper) { _processHelper = processHelper; _fileHelper = fileHelper; diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/PublicAPI/PublicAPI.Shipped.txt b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/PublicAPI/PublicAPI.Shipped.txt index f60f15447c..a5ac44b058 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/PublicAPI/PublicAPI.Shipped.txt +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/PublicAPI/PublicAPI.Shipped.txt @@ -71,7 +71,7 @@ Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.Dump(int pro Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.GetDumpFiles(bool processCrashed) -> System.Collections.Generic.IEnumerable! Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.OutputReceivedCallback.get -> System.Action! Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.ProcDumpDumper() -> void -Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.ProcDumpDumper(Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces.IProcessHelper! processHelper, Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces.IFileHelper! fileHelper, Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces.IEnvironment! environment, Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces.IEnvironmentVariableHelper! environmentVariableHelper) -> void +Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.ProcDumpDumper(Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces.IProcessHelper! processHelper, Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces.IFileHelper! fileHelper, Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces.IEnvironment! environment) -> void Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcDumpDumper.WaitForDumpToFinish() -> void Microsoft.TestPlatform.Extensions.BlameDataCollector.Win32NamedEvent Microsoft.TestPlatform.Extensions.BlameDataCollector.Win32NamedEvent.Set() -> void diff --git a/src/vstest.console/Resources/xlf/Resources.cs.xlf b/src/vstest.console/Resources/xlf/Resources.cs.xlf index dbdaac1a38..50df0ff5a3 100644 --- a/src/vstest.console/Resources/xlf/Resources.cs.xlf +++ b/src/vstest.console/Resources/xlf/Resources.cs.xlf @@ -1210,7 +1210,7 @@ - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.de.xlf b/src/vstest.console/Resources/xlf/Resources.de.xlf index e127b7a939..af86ba3247 100644 --- a/src/vstest.console/Resources/xlf/Resources.de.xlf +++ b/src/vstest.console/Resources/xlf/Resources.de.xlf @@ -1210,7 +1210,7 @@ - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.es.xlf b/src/vstest.console/Resources/xlf/Resources.es.xlf index 90c7ee7dfe..3c1bc19b54 100644 --- a/src/vstest.console/Resources/xlf/Resources.es.xlf +++ b/src/vstest.console/Resources/xlf/Resources.es.xlf @@ -1213,7 +1213,7 @@ - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.fr.xlf b/src/vstest.console/Resources/xlf/Resources.fr.xlf index 3148f61b8b..acbb40d86b 100644 --- a/src/vstest.console/Resources/xlf/Resources.fr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.fr.xlf @@ -1210,7 +1210,7 @@ Comportements actuellement pris en charge : - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.it.xlf b/src/vstest.console/Resources/xlf/Resources.it.xlf index 649b626b1c..cec2b186d6 100644 --- a/src/vstest.console/Resources/xlf/Resources.it.xlf +++ b/src/vstest.console/Resources/xlf/Resources.it.xlf @@ -1210,7 +1210,7 @@ - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.ja.xlf b/src/vstest.console/Resources/xlf/Resources.ja.xlf index b13b4f6002..5d4b0a19e5 100644 --- a/src/vstest.console/Resources/xlf/Resources.ja.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ja.xlf @@ -1210,7 +1210,7 @@ - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.ko.xlf b/src/vstest.console/Resources/xlf/Resources.ko.xlf index c395d779fe..151d3c02fc 100644 --- a/src/vstest.console/Resources/xlf/Resources.ko.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ko.xlf @@ -1210,7 +1210,7 @@ - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.pl.xlf b/src/vstest.console/Resources/xlf/Resources.pl.xlf index b95288bb09..dd988e71a2 100644 --- a/src/vstest.console/Resources/xlf/Resources.pl.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pl.xlf @@ -1210,7 +1210,7 @@ - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf index 0f6fd645c4..00e0557076 100644 --- a/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf +++ b/src/vstest.console/Resources/xlf/Resources.pt-BR.xlf @@ -1210,7 +1210,7 @@ Altere o prefixo de nível de diagnóstico do agente de console, como mostrado a - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.ru.xlf b/src/vstest.console/Resources/xlf/Resources.ru.xlf index 1823e62c51..963f1612ee 100644 --- a/src/vstest.console/Resources/xlf/Resources.ru.xlf +++ b/src/vstest.console/Resources/xlf/Resources.ru.xlf @@ -1210,7 +1210,7 @@ - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.tr.xlf b/src/vstest.console/Resources/xlf/Resources.tr.xlf index a6d839616a..66980721c6 100644 --- a/src/vstest.console/Resources/xlf/Resources.tr.xlf +++ b/src/vstest.console/Resources/xlf/Resources.tr.xlf @@ -1210,7 +1210,7 @@ Günlükler için izleme düzeyini aşağıda gösterildiği gibi değiştirin - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.xlf b/src/vstest.console/Resources/xlf/Resources.xlf index 18fafb5188..d11bcd4780 100644 --- a/src/vstest.console/Resources/xlf/Resources.xlf +++ b/src/vstest.console/Resources/xlf/Resources.xlf @@ -1004,7 +1004,7 @@ Format : TestRunParameters.Parameter(name="<name>", value="<value>") - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf index f619a54ea8..2e95f0195f 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hans.xlf @@ -1210,7 +1210,7 @@ - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' diff --git a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf index 9ff75ea0c9..c8950503c2 100644 --- a/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf +++ b/src/vstest.console/Resources/xlf/Resources.zh-Hant.xlf @@ -1210,7 +1210,7 @@ - The directory specified for the procdump executable is not valid: '{0}' and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}' From 4d45ee42eb3bd6136608a1e5e009687b74e775f1 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 7 Oct 2022 17:45:35 +0200 Subject: [PATCH 3/6] fix type --- .../ProcDumpExecutableHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs b/src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs index 7baaa1b33f..f9c723a009 100644 --- a/src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs +++ b/src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs @@ -40,7 +40,7 @@ public static string ProcDumpFileName(PlatformArchitecture architecture) => public bool TryGetProcDumpExecutable(out string path) { - // Use machien architecture + // Use machine architecture var targetProcessArchitecture = _environment.Architecture; return TryGetProcDumpExecutable(targetProcessArchitecture, out path); } From 5e9c58e01c88935269630dfd9fb08039ed5089f4 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 7 Oct 2022 18:45:30 +0200 Subject: [PATCH 4/6] address PR feedback --- .../ProcDumpDumper.cs | 6 ++++-- .../Processors/AeDebuggerArgumentProcessor.cs | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs index 5d371c29e1..4436f79ff1 100644 --- a/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs +++ b/src/Microsoft.TestPlatform.Extensions.BlameDataCollector/ProcDumpDumper.cs @@ -39,6 +39,7 @@ public class ProcDumpDumper : ICrashDumper, IHangDumper private string? _outputDirectory; private Process? _process; private string? _outputFilePrefix; + private readonly ProcDumpExecutableHelper _procDumpExecutableHelper; public ProcDumpDumper() : this(new ProcessHelper(), new FileHelper(), new PlatformEnvironment(), new EnvironmentVariableHelper()) @@ -59,6 +60,7 @@ internal ProcDumpDumper(IProcessHelper processHelper, IFileHelper fileHelper, IE _fileHelper = fileHelper; _environment = environment; _environmentVariableHelper = environmentVariableHelper; + _procDumpExecutableHelper = new ProcDumpExecutableHelper(processHelper, fileHelper, environment, environmentVariableHelper); } [SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Part of the public API")] @@ -98,7 +100,7 @@ public void AttachToTargetProcess(int processId, string outputDirectory, DumpTyp throw new InvalidOperationException("Procdump crash dump file must end with .dmp extension."); } - if (!new ProcDumpExecutableHelper(_processHelper, _fileHelper, _environment, _environmentVariableHelper).TryGetProcDumpExecutable(processId, out var procDumpPath)) + if (!_procDumpExecutableHelper.TryGetProcDumpExecutable(processId, out var procDumpPath)) { var procdumpNotFound = string.Format(CultureInfo.CurrentCulture, Resources.Resources.ProcDumpNotFound, procDumpPath); logWarning(procdumpNotFound); @@ -217,7 +219,7 @@ public void Dump(int processId, string outputDirectory, DumpTypeOption dumpType) throw new InvalidOperationException("Procdump crash dump file must end with .dmp extension."); } - if (!new ProcDumpExecutableHelper(_processHelper, _fileHelper, _environment, _environmentVariableHelper).TryGetProcDumpExecutable(processId, out var procDumpPath)) + if (!_procDumpExecutableHelper.TryGetProcDumpExecutable(processId, out var procDumpPath)) { var err = $"{procDumpPath} could not be found, please set PROCDUMP_PATH environment variable to a directory that contains {procDumpPath} executable, or make sure that the executable is available on PATH."; ConsoleOutput.Instance.Warning(false, err); diff --git a/src/vstest.console/Processors/AeDebuggerArgumentProcessor.cs b/src/vstest.console/Processors/AeDebuggerArgumentProcessor.cs index f743f516c9..5f4b5ad9a6 100644 --- a/src/vstest.console/Processors/AeDebuggerArgumentProcessor.cs +++ b/src/vstest.console/Processors/AeDebuggerArgumentProcessor.cs @@ -72,7 +72,7 @@ internal class AeDebuggerArgumentExecutor : IArgumentExecutor private readonly IEnvironmentVariableHelper _environmentVariableHelper; private string? _argument; private Dictionary? _collectDumpParameters; - + private readonly ProcDumpExecutableHelper _procDumpExecutableHelper; public AeDebuggerArgumentExecutor(IEnvironment environment, IFileHelper fileHelper, IProcessHelper processHelper, IOutput output, IEnvironmentVariableHelper environmentVariableHelper) { _environment = environment ?? throw new ArgumentNullException(nameof(environment)); @@ -80,6 +80,7 @@ public AeDebuggerArgumentExecutor(IEnvironment environment, IFileHelper fileHelp _processHelper = processHelper ?? throw new ArgumentNullException(nameof(processHelper)); _output = output ?? throw new ArgumentNullException(nameof(output)); _environmentVariableHelper = environmentVariableHelper ?? throw new ArgumentNullException(nameof(environmentVariableHelper)); + _procDumpExecutableHelper = new ProcDumpExecutableHelper(processHelper, fileHelper, environment, environmentVariableHelper); } public void Initialize(string? argument) => _argument = argument; @@ -130,7 +131,7 @@ private ArgumentProcessorResult InstallUnistallPostmortemDebugger(bool install) // Look for procdump string? procDumpPath = null; if (!TryGetDirectoryInfo(_collectDumpParameters, "ProcDumpToolDirectoryPath", out DirectoryInfo? procDumpToolDirectoryPath) && - !new ProcDumpExecutableHelper(_processHelper, _fileHelper, _environment, _environmentVariableHelper).TryGetProcDumpExecutable(out procDumpPath) + !_procDumpExecutableHelper.TryGetProcDumpExecutable(out procDumpPath) ) { _output.Error(false, string.Format(CultureInfo.CurrentCulture, CommandLineResources.InvalidProcDumpToolDirectoryPath)); From 1cfcd9d41535cd9847b575655125ab84901c410e Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 7 Oct 2022 18:45:49 +0200 Subject: [PATCH 5/6] Update src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Amaury Levé --- .../ProcDumpExecutableHelper.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs b/src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs index f9c723a009..a81ff801c2 100644 --- a/src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs +++ b/src/Microsoft.TestPlatform.Execution.Shared/ProcDumpExecutableHelper.cs @@ -7,7 +7,6 @@ using Microsoft.VisualStudio.TestPlatform.CoreUtilities; using Microsoft.VisualStudio.TestPlatform.ObjectModel; using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions; - using Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.Interfaces; using Microsoft.VisualStudio.TestPlatform.Utilities.Helpers.Interfaces; From 082dd7fc252052df0c1fdfd5a56be3cad4f9ec17 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 7 Oct 2022 18:45:54 +0200 Subject: [PATCH 6/6] Update src/vstest.console/Resources/Resources.resx MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Amaury Levé --- src/vstest.console/Resources/Resources.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vstest.console/Resources/Resources.resx b/src/vstest.console/Resources/Resources.resx index 413a01b927..bf730bc653 100644 --- a/src/vstest.console/Resources/Resources.resx +++ b/src/vstest.console/Resources/Resources.resx @@ -761,7 +761,7 @@ Postmortem debugger is not supported in the current OS. - The directory specified for the procdump executable is not valid and the tool was not found inside environment variables(PROCDUMP_PATH, PATH) + The directory specified for the procdump executable is not valid and the tool was not found inside environment variables (PROCDUMP_PATH, PATH) The directory specified is not valid: '{0}'