提交 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() {
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) {
......
......@@ -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;
......
......@@ -63,14 +63,14 @@ internal class Options
/// </summary>
public TimeSpan? Timeout { get; set; }
public string ProcDumpPath { get; set; }
public string ProcDumpDirectory { get; set; }
public string XunitPath { get; set; }
/// <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>
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
......
......@@ -85,10 +85,6 @@ public async Task<TestResult> RunTestAsync(AssemblyInfo assemblyInfo, Cancellati
var environmentVariables = new Dictionary<string, string>();
_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)
......
......@@ -128,12 +128,7 @@ private static async Task<int> 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,
......
......@@ -153,9 +153,8 @@ private void Print(List<TestResult> 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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册