public async Task <TestResult> RunTestAsync(string assemblyPath, CancellationToken cancellationToken) { var contentFile = _contentUtil.GetTestResultContentFile(assemblyPath); var builder = new StringBuilder(); builder.AppendLine($"{Path.GetFileName(assemblyPath)} - {contentFile.Checksum}"); builder.AppendLine("==="); builder.AppendLine(contentFile.Content); builder.AppendLine("==="); Logger.Log(builder.ToString()); try { var cachedTestResult = await _dataStorage.TryGetCachedTestResult(contentFile.Checksum); if (cachedTestResult.HasValue) { Logger.Log($"{Path.GetFileName(assemblyPath)} - cache hit"); return(Migrate(assemblyPath, cachedTestResult.Value)); } } catch (Exception ex) { Logger.Log($"Error reading cache {ex}"); } Logger.Log($"{Path.GetFileName(assemblyPath)} - running"); var testResult = await _testExecutor.RunTestAsync(assemblyPath, cancellationToken); await CacheTestResult(contentFile, testResult).ConfigureAwait(true); return(testResult); }
public async Task <TestResult> RunTestAsync(AssemblyInfo assemblyInfo, CancellationToken cancellationToken) { ContentFile contentFile; try { contentFile = _contentUtil.GetTestResultContentFile(assemblyInfo); } catch (Exception ex) { var msg = $"Unable to calculate content file for {assemblyInfo.AssemblyPath}"; Console.WriteLine(msg); Logger.LogError(ex, msg + Environment.NewLine + ex.Message); contentFile = null; var testResult = await _testExecutor.RunTestAsync(assemblyInfo, cancellationToken); return(new TestResult( testResult.AssemblyInfo, testResult.TestResultInfo, testResult.CommandLine, isFromCache: false, diagnostics: msg)); } return(await RunTestWithCachingAsync(assemblyInfo, contentFile, cancellationToken)); }
public async Task <TestResult> RunTestAsync(string assemblyPath, CancellationToken cancellationToken) { var contentFile = _contentUtil.GetTestResultContentFile(assemblyPath); var builder = new StringBuilder(); builder.AppendLine($"{Path.GetFileName(assemblyPath)} - {contentFile.Checksum}"); builder.AppendLine("==="); builder.AppendLine(contentFile.Content); builder.AppendLine("==="); Logger.Log(builder.ToString()); TestResult testResult; if (!_dataStorage.TryGetTestResult(contentFile.Checksum, out testResult)) { Logger.Log($"{Path.GetFileName(assemblyPath)} - running"); testResult = await _testExecutor.RunTestAsync(assemblyPath, cancellationToken); Logger.Log($"{Path.GetFileName(assemblyPath)} - caching"); _dataStorage.AddTestResult(contentFile, testResult); } else { testResult = Migrate(testResult); Logger.Log($"{Path.GetFileName(assemblyPath)} - cache hit"); } return(testResult); }