From 21f83c503644f40aae67a20e757d73db44bde772 Mon Sep 17 00:00:00 2001 From: David Raygoza Date: Thu, 8 Aug 2024 10:45:55 -0700 Subject: [PATCH] Enable UTF Output for new test framework discoveryy and execution to fix GB18030 bug --- GoogleTestAdapter/Core/GoogleTestConstants.cs | 1 + GoogleTestAdapter/Core/Runners/CommandLineGenerator.cs | 2 +- GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs | 4 ++++ GoogleTestAdapter/Core/TestCases/TestCaseFactory.cs | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/GoogleTestAdapter/Core/GoogleTestConstants.cs b/GoogleTestAdapter/Core/GoogleTestConstants.cs index 5a93406fe..fe49e1daf 100644 --- a/GoogleTestAdapter/Core/GoogleTestConstants.cs +++ b/GoogleTestAdapter/Core/GoogleTestConstants.cs @@ -18,6 +18,7 @@ public static class GoogleTestConstants public const string NrOfRepetitionsOption = " --gtest_repeat"; public const string CatchExceptions = " --gtest_catch_exceptions"; public const string BreakOnFailure = " --gtest_break_on_failure"; + public const string Utf8OutputOption = " --gtest_print_utf8=1"; public const int ShuffleTestsSeedDefaultValue = 0; public const string ShuffleTestsSeedMaxValueAsString = "99999"; diff --git a/GoogleTestAdapter/Core/Runners/CommandLineGenerator.cs b/GoogleTestAdapter/Core/Runners/CommandLineGenerator.cs index 849e29596..21c37a22d 100644 --- a/GoogleTestAdapter/Core/Runners/CommandLineGenerator.cs +++ b/GoogleTestAdapter/Core/Runners/CommandLineGenerator.cs @@ -15,7 +15,7 @@ public class CommandLineGenerator public class Args { public IList TestCases { get; } - public string CommandLine { get; } + public string CommandLine { get; set; } internal Args(IList testCases, string commandLine) { diff --git a/GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs b/GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs index 370a4cc82..23fa07a98 100644 --- a/GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs +++ b/GoogleTestAdapter/Core/Runners/SequentialTestRunner.cs @@ -128,6 +128,10 @@ private void RunTestsFromExecutable(string executable, string workingDir, IDicti { break; } + + // Enable UTF-8 output for Google Test. + arguments.CommandLine += " --gtest_print_utf8=1"; + var streamingParser = new StreamingStandardOutputTestResultParser(arguments.TestCases, _logger, _frameworkReporter); var results = RunTests(executable, workingDir, envVars, isBeingDebugged, debuggedLauncher, arguments, executor, streamingParser).ToArray(); diff --git a/GoogleTestAdapter/Core/TestCases/TestCaseFactory.cs b/GoogleTestAdapter/Core/TestCases/TestCaseFactory.cs index 912756bd4..4f5cf965d 100644 --- a/GoogleTestAdapter/Core/TestCases/TestCaseFactory.cs +++ b/GoogleTestAdapter/Core/TestCases/TestCaseFactory.cs @@ -135,7 +135,7 @@ private IList NewCreateTestcases(Action reportTestCase, List parser.ReportLine(s); }; - string cmdLine = GoogleTestConstants.ListTestsOption; + string cmdLine = GoogleTestConstants.ListTestsOption + GoogleTestContants.Utf8OutputOption; if (!string.IsNullOrEmpty(_settings.AdditionalTestDiscoveryParam)) { cmdLine = string.Format("{0} {1}", _settings.AdditionalTestDiscoveryParam, cmdLine);