private static void NoteTestFailureInfo(PerDocumentLocationTestFailureInfo pdtfi, XTestResult tr) { LogInfo("Noting Test Failure Info: {0} - {1}", tr.DisplayName, tr.Outcome); TestFailureInfoExtensions.create(tr) .Aggregate( pdtfi, (acc, e) => { acc .GetOrAdd(e.Item1, _ => new ConcurrentBag <TestFailureInfo>()) .Add(e.Item2); return(acc); }); }
private static RunStepResult RunTests(IRunExecutorHost host, RunStartParams rsp, RunStepInfo rsi) { if (!host.CanContinue()) { throw new OperationCanceledException(); } var output = RunTestHost("execute", rsp); RunStepStatus rss = RunStepStatus.Succeeded; if (output.Item1 != 0) { rss = RunStepStatus.Failed; } var testResults = PerTestIdDResults.Deserialize(FilePath.NewFilePath(rsp.DataFiles.TestResultsStore.Item)); var coverageSession = PerSequencePointIdTestRunId.Deserialize(FilePath.NewFilePath(rsp.DataFiles.CoverageSessionStore.Item)); var testFailureInfo = PerDocumentLocationTestFailureInfo.Deserialize(FilePath.NewFilePath(rsp.DataFiles.TestFailureInfoStore.Item)); return(rss.ToRSR(RunData.NewTestRunOutput(testResults, testFailureInfo, coverageSession), output.Item2)); }
private static bool RunTests(IEnumerable <IXTestExecutor> tes, string slnPath, string slnSnapPath, string buildRoot, string testResultsStore, string testFailureInfoStore, PerDocumentLocationXTestCases discoveredUnitTests) { Stopwatch stopWatch = new Stopwatch(); LogInfo("TestHost executing tests..."); stopWatch.Start(); var testResults = new PerTestIdDResults(); var testFailureInfo = new PerDocumentLocationTestFailureInfo(); var tests = from dc in discoveredUnitTests.Keys from t in discoveredUnitTests[dc] group t by t.Source; Parallel.ForEach( tests, new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, test => { LogInfo("Executing tests in {0}: Start.", test.Key); var exec = new XUnitTestExecutor(); exec.TestExecuted.AddHandler( new FSharpHandler <XTestResult>( (o, ea) => { Func <string, string> rebaseCFP = cfp => { if (cfp == null) { return(null); } return(PathBuilder.rebaseCodeFilePath(FilePath.NewFilePath(slnPath), FilePath.NewFilePath(slnSnapPath), FilePath.NewFilePath(cfp)).ToString()); }; ea.TestCase.CodeFilePath = rebaseCFP(ea.TestCase.CodeFilePath); RebaseCallStackDocumentReferences(rebaseCFP, ea); NoteTestResults(testResults, ea, rebaseCFP); NoteTestFailureInfo(testFailureInfo, ea); })); exec.ExecuteTests(tes, test); LogInfo("Executing tests in {0}: Done.", test.Key); }); if (!_debuggerAttached) { testResults.Serialize(FilePath.NewFilePath(testResultsStore)); testFailureInfo.Serialize(FilePath.NewFilePath(testFailureInfoStore)); } stopWatch.Stop(); var ts = stopWatch.Elapsed; var elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); LogInfo("Done TestHost executing tests! [" + elapsedTime + "]"); LogInfo(""); var rrs = from tr in testResults from rr in tr.Value where rr.Outcome == DTestOutcome.TOFailed select rr; return(!rrs.Any()); }