public ITestResult Execute(CancellationToken cancellationToken) { // todo: implement cancellation if (!RunTargets.Any()) { throw new InvalidOperationException("No run targets were specified!"); } var xTestResult = new TestResult(); OutputHandler.ExecutionStart(); foreach (var xConfig in GetRunConfigurations()) { OutputHandler.RunConfigurationStart(xConfig); foreach (var xKernelAssembly in KernelsAssembliesToRun) { var xKernelName = Path.GetFileNameWithoutExtension(xKernelAssembly); var xKernelTestResult = new KernelTestResult(xKernelName, xConfig); var xWorkingDirectory = Path.Combine(WorkingDirectoryBase, xKernelName); if (Directory.Exists(xWorkingDirectory)) { Directory.Delete(xWorkingDirectory, true); } Directory.CreateDirectory(xWorkingDirectory); try { xKernelTestResult.Result = ExecuteKernel( xKernelAssembly, xWorkingDirectory, xConfig, xKernelTestResult); } catch (Exception e) { OutputHandler.UnhandledException(e); } xKernelTestResult.TestLog = mTestResultOutputHandler.TestLog; xTestResult.AddKernelTestResult(xKernelTestResult); } OutputHandler.RunConfigurationEnd(xConfig); } OutputHandler.ExecutionEnd(); var xPassedTestsCount = xTestResult.KernelTestResults.Count(r => r.Result); var xFailedTestsCount = xTestResult.KernelTestResults.Count(r => !r.Result); OutputHandler.LogMessage($"Done executing: {xPassedTestsCount} test(s) passed, {xFailedTestsCount} test(s) failed."); return(xTestResult); }
public bool Execute() { if (OutputHandler == null) { throw new InvalidOperationException("No OutputHandler set!"); } if (!RunTargets.Any()) { throw new InvalidOperationException("No run targets were specified!"); } OutputHandler.ExecutionStart(); try { var xResult = true; foreach (var xConfig in GetRunConfigurations()) { OutputHandler.RunConfigurationStart(xConfig); try { foreach (var xKernelType in KernelsToRun) { var xAssemblyPath = xKernelType.Assembly.Location; var xWorkingDirectory = Path.Combine( WorkingDirectoryBase, Path.GetFileNameWithoutExtension(xAssemblyPath)); if (Directory.Exists(xWorkingDirectory)) { Directory.Delete(xWorkingDirectory, true); } Directory.CreateDirectory(xWorkingDirectory); xResult &= ExecuteKernel(xAssemblyPath, xWorkingDirectory, xConfig); } } catch (Exception e) { if (!mKernelResultSet) { OutputHandler.SetKernelTestResult(false, e.ToString()); mKernelResult = false; xResult = false; } OutputHandler.UnhandledException(e); } finally { OutputHandler.RunConfigurationEnd(xConfig); } } return(xResult); } catch (Exception E) { OutputHandler.UnhandledException(E); return(false); } finally { OutputHandler.ExecutionEnd(); } // todo: now report summary //DoLog("NotImplemented, summary?"); }