提交 e19dbad3 编写于 作者: J Jared Parsons 提交者: Jared Parsons

Move xunit output to diagnostic log folder

This change moves the captured xunit standard output file into the
standard log folder.

closes #25602
上级 c56fc206
...@@ -444,12 +444,11 @@ function Test-XUnit() { ...@@ -444,12 +444,11 @@ function Test-XUnit() {
Deploy-VsixViaTool Deploy-VsixViaTool
} }
$logFilePath = Join-Path $logsDir "runtests.log"
$unitDir = Join-Path $configDir "UnitTests" $unitDir = Join-Path $configDir "UnitTests"
$runTests = Join-Path $configDir "Exes\RunTests\RunTests.exe" $runTests = Join-Path $configDir "Exes\RunTests\RunTests.exe"
$xunitDir = Join-Path (Get-PackageDir "xunit.runner.console") "tools\net452" $xunitDir = Join-Path (Get-PackageDir "xunit.runner.console") "tools\net452"
$args = "$xunitDir" $args = "$xunitDir"
$args += " -log:$logFilePath" $args += " -logpath:$logsDir"
$args += " -nocache" $args += " -nocache"
if ($testDesktop) { if ($testDesktop) {
......
...@@ -12,18 +12,18 @@ internal struct TestExecutionOptions ...@@ -12,18 +12,18 @@ internal struct TestExecutionOptions
{ {
internal string XunitPath { get; } internal string XunitPath { get; }
internal ProcDumpInfo? ProcDumpInfo { get; } internal ProcDumpInfo? ProcDumpInfo { get; }
internal string LogFilePath { get; } internal string LogsDirectory { get; }
internal string Trait { get; } internal string Trait { get; }
internal string NoTrait { get; } internal string NoTrait { get; }
internal bool UseHtml { get; } internal bool UseHtml { get; }
internal bool Test64 { get; } internal bool Test64 { get; }
internal bool TestVsi { 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; XunitPath = xunitPath;
ProcDumpInfo = procDumpInfo; ProcDumpInfo = procDumpInfo;
LogFilePath = logFilePath; LogsDirectory = logsDirectory;
Trait = trait; Trait = trait;
NoTrait = noTrait; NoTrait = noTrait;
UseHtml = useHtml; UseHtml = useHtml;
......
...@@ -63,14 +63,14 @@ internal class Options ...@@ -63,14 +63,14 @@ internal class Options
/// </summary> /// </summary>
public TimeSpan? Timeout { get; set; } public TimeSpan? Timeout { get; set; }
public string ProcDumpPath { get; set; } public string ProcDumpDirectory { get; set; }
public string XunitPath { get; set; } public string XunitPath { get; set; }
/// <summary> /// <summary>
/// When set the log file for executing tests will be written to the prescribed location. /// Directory to hold all of our test logging information.
/// </summary> /// </summary>
public string LogFilePath { get; set; } public string LogsDirectory { get; set; }
internal static Options Parse(string[] args) internal static Options Parse(string[] args)
{ {
...@@ -93,7 +93,7 @@ bool isOption(string argument, string optionName, out string value) ...@@ -93,7 +93,7 @@ bool isOption(string argument, string optionName, out string value)
return false; 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 index = 1;
var allGood = true; var allGood = true;
while (index < args.Length) while (index < args.Length)
...@@ -120,9 +120,9 @@ bool isOption(string argument, string optionName, out string value) ...@@ -120,9 +120,9 @@ bool isOption(string argument, string optionName, out string value)
opt.UseCachedResults = false; opt.UseCachedResults = false;
index++; index++;
} }
else if (isOption(current, "-log", out string value)) else if (isOption(current, "-logpath", out string value))
{ {
opt.LogFilePath = value; opt.LogsDirectory = value;
index++; index++;
} }
else if (isOption(current, "-display", out value)) else if (isOption(current, "-display", out value))
...@@ -165,7 +165,7 @@ bool isOption(string argument, string optionName, out string value) ...@@ -165,7 +165,7 @@ bool isOption(string argument, string optionName, out string value)
} }
else if (isOption(current, "-procdumpPath", out value)) else if (isOption(current, "-procdumpPath", out value))
{ {
opt.ProcDumpPath = value; opt.ProcDumpDirectory = value;
index++; index++;
} }
else else
......
...@@ -85,10 +85,6 @@ public async Task<TestResult> RunTestAsync(AssemblyInfo assemblyInfo, Cancellati ...@@ -85,10 +85,6 @@ public async Task<TestResult> RunTestAsync(AssemblyInfo assemblyInfo, Cancellati
var environmentVariables = new Dictionary<string, string>(); var environmentVariables = new Dictionary<string, string>();
_options.ProcDumpInfo?.WriteEnvironmentVariables(environmentVariables); _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 // Attach procDump to processes when the are started so we can watch for
// unexepected crashes. // unexepected crashes.
void onProcessStart(Process process) void onProcessStart(Process process)
......
...@@ -128,12 +128,7 @@ private static async Task<int> RunCore(Options options, CancellationToken cancel ...@@ -128,12 +128,7 @@ private static async Task<int> RunCore(Options options, CancellationToken cancel
private static void WriteLogFile(Options options) private static void WriteLogFile(Options options)
{ {
var logFilePath = options.LogFilePath; var logFilePath = Path.Combine(options.LogsDirectory, "runtests.log");
if (string.IsNullOrEmpty(logFilePath))
{
return;
}
try try
{ {
using (var writer = new StreamWriter(logFilePath, append: false)) using (var writer = new StreamWriter(logFilePath, append: false))
...@@ -212,12 +207,9 @@ async Task DumpProcess(Process targetProcess, string dumpFilePath) ...@@ -212,12 +207,9 @@ async Task DumpProcess(Process targetProcess, string dumpFilePath)
private static ProcDumpInfo? GetProcDumpInfo(Options options) private static ProcDumpInfo? GetProcDumpInfo(Options options)
{ {
if (!string.IsNullOrEmpty(options.ProcDumpPath)) if (!string.IsNullOrEmpty(options.ProcDumpDirectory))
{ {
var dumpDir = options.LogFilePath != null return new ProcDumpInfo(Path.Combine(options.ProcDumpDirectory, "procdump.exe"), options.LogsDirectory);
? Path.GetDirectoryName(options.LogFilePath)
: Directory.GetCurrentDirectory();
return new ProcDumpInfo(Path.Combine(options.ProcDumpPath, "procdump.exe"), dumpDir);
} }
return null; return null;
...@@ -325,7 +317,7 @@ private static ITestExecutor CreateTestExecutor(Options options) ...@@ -325,7 +317,7 @@ private static ITestExecutor CreateTestExecutor(Options options)
var testExecutionOptions = new TestExecutionOptions( var testExecutionOptions = new TestExecutionOptions(
xunitPath: options.XunitPath, xunitPath: options.XunitPath,
procDumpInfo: GetProcDumpInfo(options), procDumpInfo: GetProcDumpInfo(options),
logFilePath: options.LogFilePath, logsDirectory: options.LogsDirectory,
trait: options.Trait, trait: options.Trait,
noTrait: options.NoTrait, noTrait: options.NoTrait,
useHtml: options.UseHtml, useHtml: options.UseHtml,
......
...@@ -153,9 +153,8 @@ private void Print(List<TestResult> testResults) ...@@ -153,9 +153,8 @@ private void Print(List<TestResult> testResults)
private void PrintFailedTestResult(TestResult testResult) private void PrintFailedTestResult(TestResult testResult)
{ {
// Save out the error output for easy artifact inspecting // Save out the error output for easy artifact inspecting
var resultsDir = testResult.ResultsDirectory; var outputLogPath = Path.Combine(_options.LogsDirectory, $"{testResult.DisplayName}.out.log");
var outputLogPath = Path.Combine(resultsDir, $"{testResult.DisplayName}.out.log"); File.WriteAllText(outputLogPath, testResult.StandardOutput ?? "");
File.WriteAllText(outputLogPath, testResult.StandardOutput);
Console.WriteLine("Errors {0}: ", testResult.AssemblyName); Console.WriteLine("Errors {0}: ", testResult.AssemblyName);
Console.WriteLine(testResult.ErrorOutput); Console.WriteLine(testResult.ErrorOutput);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册