From 091b80c1a6c454a864e014f16048fe631c371ccd Mon Sep 17 00:00:00 2001 From: Spencer Bloom Date: Thu, 16 Apr 2020 17:34:53 -0700 Subject: [PATCH] update working dir --- GoogleTestAdapter/Core/Settings/SettingsWrapper.cs | 6 +++++- GoogleTestAdapter/Core/TestCases/TestCaseFactory.cs | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/GoogleTestAdapter/Core/Settings/SettingsWrapper.cs b/GoogleTestAdapter/Core/Settings/SettingsWrapper.cs index 018aa8bad..9134762a5 100644 --- a/GoogleTestAdapter/Core/Settings/SettingsWrapper.cs +++ b/GoogleTestAdapter/Core/Settings/SettingsWrapper.cs @@ -176,7 +176,11 @@ public string GetBatchForTestTeardown(string solutionDirectory, string testDirec => ReplacePlaceholders(BatchForTestTeardown, solutionDirectory, testDirectory, threadId); public string GetWorkingDir(string solutionDirectory, string testDirectory, int threadId) - => ReplacePlaceholders(WorkingDir, solutionDirectory, testDirectory, threadId); + { + return string.IsNullOrWhiteSpace(WorkingDir) + ? OptionWorkingDirDefaultValue + : ReplacePlaceholders(WorkingDir, solutionDirectory, testDirectory, threadId); + } private string ReplacePlaceholders(string theString, string solutionDirectory, string testDirectory, int threadId) diff --git a/GoogleTestAdapter/Core/TestCases/TestCaseFactory.cs b/GoogleTestAdapter/Core/TestCases/TestCaseFactory.cs index 34638102b..6edaa47d9 100644 --- a/GoogleTestAdapter/Core/TestCases/TestCaseFactory.cs +++ b/GoogleTestAdapter/Core/TestCases/TestCaseFactory.cs @@ -45,7 +45,8 @@ public IList CreateTestCases(Action reportTestCase = null) { var launcher = new ProcessLauncher(_logger, _settings.GetPathExtension(_executable), null); int processExitCode; - standardOutput = launcher.GetOutputOfCommand("", null, _executable, GoogleTestConstants.ListTestsOption, + string workingDir = new FileInfo(_executable).DirectoryName; + standardOutput = launcher.GetOutputOfCommand(workingDir, null, _executable, GoogleTestConstants.ListTestsOption, false, false, out processExitCode); if (!CheckProcessExitCode(processExitCode, standardOutput)) @@ -129,6 +130,7 @@ private IList NewCreateTestcases(Action reportTestCase, List try { + string workingDir = new FileInfo(_executable).DirectoryName; int processExitCode = ProcessExecutor.ExecutionFailed; ProcessExecutor executor = null; var listAndParseTestsTask = new Task(() => @@ -137,7 +139,7 @@ private IList NewCreateTestcases(Action reportTestCase, List processExitCode = executor.ExecuteCommandBlocking( _executable, GoogleTestConstants.ListTestsOption, - "", + workingDir, null, _settings.GetPathExtension(_executable), lineAction);