diff --git a/build/scripts/build.ps1 b/build/scripts/build.ps1 index 1a911ab62a9d8927e5e3231799e7120fe7f99744..2441d118ef15e7e3efd6ae10b5b5b116ff6e4800 100644 --- a/build/scripts/build.ps1 +++ b/build/scripts/build.ps1 @@ -444,12 +444,11 @@ function Test-XUnit() { Deploy-VsixViaTool } - $logFilePath = Join-Path $logsDir "runtests.log" $unitDir = Join-Path $configDir "UnitTests" $runTests = Join-Path $configDir "Exes\RunTests\RunTests.exe" $xunitDir = Join-Path (Get-PackageDir "xunit.runner.console") "tools\net452" $args = "$xunitDir" - $args += " -log:$logFilePath" + $args += " -logpath:$logsDir" $args += " -nocache" if ($testDesktop) { diff --git a/src/Tools/Source/RunTests/ITestExecutor.cs b/src/Tools/Source/RunTests/ITestExecutor.cs index 38def79f5fc95ad4bd883c3d6779353877d9e3e7..d931c0127d82a689b6f8365a83bcccaebda92a5a 100644 --- a/src/Tools/Source/RunTests/ITestExecutor.cs +++ b/src/Tools/Source/RunTests/ITestExecutor.cs @@ -12,18 +12,18 @@ internal struct TestExecutionOptions { internal string XunitPath { get; } internal ProcDumpInfo? ProcDumpInfo { get; } - internal string LogFilePath { get; } + internal string LogsDirectory { get; } internal string Trait { get; } internal string NoTrait { get; } internal bool UseHtml { get; } internal bool Test64 { get; } internal bool TestVsi { get; } - internal TestExecutionOptions(string xunitPath, ProcDumpInfo? procDumpInfo, string logFilePath, string trait, string noTrait, bool useHtml, bool test64, bool testVsi) + internal TestExecutionOptions(string xunitPath, ProcDumpInfo? procDumpInfo, string logsDirectory, string trait, string noTrait, bool useHtml, bool test64, bool testVsi) { XunitPath = xunitPath; ProcDumpInfo = procDumpInfo; - LogFilePath = logFilePath; + LogsDirectory = logsDirectory; Trait = trait; NoTrait = noTrait; UseHtml = useHtml; diff --git a/src/Tools/Source/RunTests/Options.cs b/src/Tools/Source/RunTests/Options.cs index 2f93d9f382e72e16fb0da36e8c3e7bc63ebf4728..9259f5827df9df65f474677147973113b0e5f8b9 100644 --- a/src/Tools/Source/RunTests/Options.cs +++ b/src/Tools/Source/RunTests/Options.cs @@ -63,14 +63,14 @@ internal class Options /// public TimeSpan? Timeout { get; set; } - public string ProcDumpPath { get; set; } + public string ProcDumpDirectory { get; set; } public string XunitPath { get; set; } /// - /// When set the log file for executing tests will be written to the prescribed location. + /// Directory to hold all of our test logging information. /// - public string LogFilePath { get; set; } + public string LogsDirectory { get; set; } internal static Options Parse(string[] args) { @@ -93,7 +93,7 @@ bool isOption(string argument, string optionName, out string value) return false; } - var opt = new Options { XunitPath = args[0], UseHtml = true, UseCachedResults = true }; + var opt = new Options { XunitPath = args[0], UseHtml = true, UseCachedResults = true, LogsDirectory = Directory.GetCurrentDirectory() }; var index = 1; var allGood = true; while (index < args.Length) @@ -120,9 +120,9 @@ bool isOption(string argument, string optionName, out string value) opt.UseCachedResults = false; index++; } - else if (isOption(current, "-log", out string value)) + else if (isOption(current, "-logpath", out string value)) { - opt.LogFilePath = value; + opt.LogsDirectory = value; index++; } else if (isOption(current, "-display", out value)) @@ -165,7 +165,7 @@ bool isOption(string argument, string optionName, out string value) } else if (isOption(current, "-procdumpPath", out value)) { - opt.ProcDumpPath = value; + opt.ProcDumpDirectory = value; index++; } else diff --git a/src/Tools/Source/RunTests/ProcessTestExecutor.cs b/src/Tools/Source/RunTests/ProcessTestExecutor.cs index 66c3eb1f5e3c6edd5732853a6ba4e06f694ad1f5..5fc415e49614415447e3fdec245d21b0d7488316 100644 --- a/src/Tools/Source/RunTests/ProcessTestExecutor.cs +++ b/src/Tools/Source/RunTests/ProcessTestExecutor.cs @@ -85,10 +85,6 @@ public async Task RunTestAsync(AssemblyInfo assemblyInfo, Cancellati var environmentVariables = new Dictionary(); _options.ProcDumpInfo?.WriteEnvironmentVariables(environmentVariables); - var outputDirectory = _options.LogFilePath != null - ? Path.GetDirectoryName(_options.LogFilePath) - : Directory.GetCurrentDirectory(); - // Attach procDump to processes when the are started so we can watch for // unexepected crashes. void onProcessStart(Process process) diff --git a/src/Tools/Source/RunTests/Program.cs b/src/Tools/Source/RunTests/Program.cs index 949566189e52c763b94a4f3b1a0cda39c511bcf4..eba3fefc1e1c517e7043044960c08e9612b45e17 100644 --- a/src/Tools/Source/RunTests/Program.cs +++ b/src/Tools/Source/RunTests/Program.cs @@ -128,12 +128,7 @@ private static async Task RunCore(Options options, CancellationToken cancel private static void WriteLogFile(Options options) { - var logFilePath = options.LogFilePath; - if (string.IsNullOrEmpty(logFilePath)) - { - return; - } - + var logFilePath = Path.Combine(options.LogsDirectory, "runtests.log"); try { using (var writer = new StreamWriter(logFilePath, append: false)) @@ -212,12 +207,9 @@ async Task DumpProcess(Process targetProcess, string dumpFilePath) private static ProcDumpInfo? GetProcDumpInfo(Options options) { - if (!string.IsNullOrEmpty(options.ProcDumpPath)) + if (!string.IsNullOrEmpty(options.ProcDumpDirectory)) { - var dumpDir = options.LogFilePath != null - ? Path.GetDirectoryName(options.LogFilePath) - : Directory.GetCurrentDirectory(); - return new ProcDumpInfo(Path.Combine(options.ProcDumpPath, "procdump.exe"), dumpDir); + return new ProcDumpInfo(Path.Combine(options.ProcDumpDirectory, "procdump.exe"), options.LogsDirectory); } return null; @@ -325,7 +317,7 @@ private static ITestExecutor CreateTestExecutor(Options options) var testExecutionOptions = new TestExecutionOptions( xunitPath: options.XunitPath, procDumpInfo: GetProcDumpInfo(options), - logFilePath: options.LogFilePath, + logsDirectory: options.LogsDirectory, trait: options.Trait, noTrait: options.NoTrait, useHtml: options.UseHtml, diff --git a/src/Tools/Source/RunTests/TestRunner.cs b/src/Tools/Source/RunTests/TestRunner.cs index 22db658365bc4f4a16e67acf21b383c558fb61dd..033ca2659b2efc0120b78ad3d6ae85d867921a67 100644 --- a/src/Tools/Source/RunTests/TestRunner.cs +++ b/src/Tools/Source/RunTests/TestRunner.cs @@ -153,9 +153,8 @@ private void Print(List testResults) private void PrintFailedTestResult(TestResult testResult) { // Save out the error output for easy artifact inspecting - var resultsDir = testResult.ResultsDirectory; - var outputLogPath = Path.Combine(resultsDir, $"{testResult.DisplayName}.out.log"); - File.WriteAllText(outputLogPath, testResult.StandardOutput); + var outputLogPath = Path.Combine(_options.LogsDirectory, $"{testResult.DisplayName}.out.log"); + File.WriteAllText(outputLogPath, testResult.StandardOutput ?? ""); Console.WriteLine("Errors {0}: ", testResult.AssemblyName); Console.WriteLine(testResult.ErrorOutput);