提交 4ddd2be5 编写于 作者: J Jared Parsons

Merge pull request #11448 from jaredpar/runtests

Error logging support
...@@ -38,7 +38,7 @@ public async Task AddCachedTestResult(AssemblyInfo assemblyInfo, ContentFile con ...@@ -38,7 +38,7 @@ public async Task AddCachedTestResult(AssemblyInfo assemblyInfo, ContentFile con
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log($"Exception adding web cached result: {ex}"); Logger.LogError(ex, "Exception uploading cached test result");
} }
} }
...@@ -74,7 +74,7 @@ public async Task AddCachedTestResult(AssemblyInfo assemblyInfo, ContentFile con ...@@ -74,7 +74,7 @@ public async Task AddCachedTestResult(AssemblyInfo assemblyInfo, ContentFile con
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log($"Exception retrieving cached test result {checksum}: {ex}"); Logger.LogError(ex, $"Exception downloading cached test result for {checksum}");
return null; return null;
} }
} }
...@@ -137,7 +137,7 @@ private static TestSourceData CreateTestSourceData(AssemblyInfo assemblyInfo) ...@@ -137,7 +137,7 @@ private static TestSourceData CreateTestSourceData(AssemblyInfo assemblyInfo)
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Log($"Exception reading test numbers: {ex}"); Logger.LogError(ex, $"Error reading test numbers");
return null; return null;
} }
} }
......
...@@ -12,7 +12,9 @@ internal static class Constants ...@@ -12,7 +12,9 @@ internal static class Constants
{ {
internal static string ResultsDirectoryName => "xUnitResults"; internal static string ResultsDirectoryName => "xUnitResults";
internal static bool IsJenkinsRun => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("JENKINS_URL")); internal static string JenkinsUrl => Environment.GetEnvironmentVariable("JENKINS_URL");
internal static bool IsJenkinsRun => !string.IsNullOrEmpty(JenkinsUrl);
internal static string EnlistmentRoot = IsJenkinsRun internal static string EnlistmentRoot = IsJenkinsRun
? Environment.GetEnvironmentVariable("WORKSPACE") ? Environment.GetEnvironmentVariable("WORKSPACE")
......
...@@ -12,6 +12,19 @@ namespace RunTests ...@@ -12,6 +12,19 @@ namespace RunTests
internal static class Logger internal static class Logger
{ {
private static readonly List<string> s_lines = new List<string>(); private static readonly List<string> s_lines = new List<string>();
private static bool s_hasErrors;
internal static bool HasErrors => s_hasErrors;
internal static void LogError(Exception ex, string line)
{
lock (s_lines)
{
s_hasErrors = true;
s_lines.Add($"Error {ex.Message}: {line}");
s_lines.Add(ex.StackTrace);
}
}
internal static void Log(string line) internal static void Log(string line)
{ {
......
...@@ -18,6 +18,8 @@ internal sealed class TestRunData ...@@ -18,6 +18,8 @@ internal sealed class TestRunData
public int AssemblyCount { get; set; } public int AssemblyCount { get; set; }
public int CacheCount { get; set; } public int CacheCount { get; set; }
public int ChunkCount { get; set; } public int ChunkCount { get; set; }
public string JenkinsUrl { get; set; }
public bool HasErrors { get; set; }
} }
} }
} }
...@@ -218,12 +218,14 @@ private static async Task SendRunStats(Options options, IDataStorage dataStorage ...@@ -218,12 +218,14 @@ private static async Task SendRunStats(Options options, IDataStorage dataStorage
{ {
Cache = dataStorage.Name, Cache = dataStorage.Name,
ElapsedSeconds = (int)elapsed.TotalSeconds, ElapsedSeconds = (int)elapsed.TotalSeconds,
JenkinsUrl = Constants.JenkinsUrl,
IsJenkins = Constants.IsJenkinsRun, IsJenkins = Constants.IsJenkinsRun,
Is32Bit = !options.Test64, Is32Bit = !options.Test64,
AssemblyCount = options.Assemblies.Count, AssemblyCount = options.Assemblies.Count,
ChunkCount = partitionCount, ChunkCount = partitionCount,
CacheCount = result.CacheCount, CacheCount = result.CacheCount,
Succeeded = result.Succeeded Succeeded = result.Succeeded,
HasErrors = Logger.HasErrors
}; };
var request = new RestRequest("api/testData/run", Method.POST); var request = new RestRequest("api/testData/run", Method.POST);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册