Ejemplo n.º 1
0
        private void PerformTeardown(IExecutionStrategy strategy, ICakeContext context, Stopwatch stopWatch, CakeReport report, bool exceptionWasThrown, Exception thrownException)
        {
            stopWatch.Restart();

            var teardownContext = new TeardownContext(context, thrownException);

            PublishEvent(Teardown, new TeardownEventArgs(teardownContext));
            if (_actions.Teardown != null)
            {
                try
                {
                    strategy.PerformTeardown(_actions.Teardown, teardownContext);
                }
                catch (Exception ex)
                {
                    _log.Error("An error occurred in the custom teardown action.");
                    if (!exceptionWasThrown)
                    {
                        // If no other exception was thrown, we throw this one.
                        throw;
                    }

                    _log.Error("Teardown error: {0}", ex.ToString());
                }
                finally
                {
                    report.Add("**Teardown**", stopWatch.Elapsed);
                }
            }
        }
Ejemplo n.º 2
0
        private void PerformTeardown(IExecutionStrategy strategy, ICakeContext context, Stopwatch stopWatch,
                                     CakeReport report, bool exceptionWasThrown, Exception thrownException)
        {
            stopWatch.Restart();

            var teardownContext = new TeardownContext(context, thrownException);

            PublishEvent(BeforeTeardown, new BeforeTeardownEventArgs(teardownContext));
#pragma warning disable 618
            PublishEvent(Teardown, new TeardownEventArgs(teardownContext));
#pragma warning restore 618

            try
            {
                if (_actions.Teardowns.Count > 0)
                {
                    var exceptions = new List <Exception>();

                    try
                    {
                        foreach (var teardown in _actions.Teardowns)
                        {
                            try
                            {
                                strategy.PerformTeardown(teardown, teardownContext);
                            }
                            catch (Exception ex)
                            {
                                // No other exceptions were thrown and this is the only teardown?
                                if (!exceptionWasThrown && _actions.Teardowns.Count == 1)
                                {
                                    // If no other exception was thrown, we throw this one.
                                    // By doing this we preserve the original stack trace which is always nice.
                                    _log.Error("An error occurred in a custom teardown action.");
                                    throw;
                                }

                                // Add this exception to the list.
                                exceptions.Add(ex);
                            }
                        }
                    }
                    finally
                    {
                        report.Add("Teardown", CakeReportEntryCategory.Teardown, stopWatch.Elapsed);
                    }

                    // If, any exceptions occurred, process them now.
                    if (exceptions.Count > 0)
                    {
                        ProcessTeardownExceptions(exceptions, exceptionWasThrown);
                    }
                }
            }
            finally
            {
                PublishEvent(AfterTeardown, new AfterTeardownEventArgs(teardownContext));
            }
        }
Ejemplo n.º 3
0
 private void PerformTeardown(IExecutionStrategy strategy, bool exceptionWasThrown)
 {
     if (_teardownAction != null)
     {
         try
         {
             strategy.PerformTeardown(_teardownAction);
         }
         catch (Exception ex)
         {
             _log.Error("An error occured in the custom teardown action.");
             if (!exceptionWasThrown)
             {
                 // If no other exception was thrown, we throw this one.
                 throw;
             }
             _log.Error("Teardown error: {0}", ex.ToString());
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Performs the build teardown.
        /// </summary>
        /// <param name="strategy">The <see cref="IExecutionStrategy"/> use to execute the teardown.</param>
        /// <param name="exceptionWasThrown">True if an exception was thrown on execution; otherwise false.</param>
        protected virtual void PerformTeardown(IExecutionStrategy strategy, bool exceptionWasThrown)
        {
            if (TeardownAction == null)
            {
                return;
            }

            try
            {
                strategy.PerformTeardown(TeardownAction);
            }
            catch (Exception ex)
            {
                Log.Error("An error occured in the custom teardown action.");
                if (!exceptionWasThrown)
                {
                    // If no other exception was thrown, we throw this one.
                    throw;
                }
                Log.Error("Teardown error: {0}", ex.ToString());
            }
        }
Ejemplo n.º 5
0
        private void PerformTeardown(IExecutionStrategy strategy, ICakeContext context, bool exceptionWasThrown, Exception thrownException)
        {
            var teardownContext = new TeardownContext(context, thrownException);

            PublishEvent(Teardown, new TeardownEventArgs(teardownContext));
            if (_teardownAction != null)
            {
                try
                {
                    strategy.PerformTeardown(_teardownAction, teardownContext);
                }
                catch (Exception ex)
                {
                    _log.Error("An error occurred in the custom teardown action.");
                    if (!exceptionWasThrown)
                    {
                        // If no other exception was thrown, we throw this one.
                        throw;
                    }
                    _log.Error("Teardown error: {0}", ex.ToString());
                }
            }
        }
 /// <summary>
 /// Performs the teardown.
 /// </summary>
 /// <param name="action">The action.</param>
 /// <param name="teardownContext">The context.</param>
 public void PerformTeardown(Action <ITeardownContext> action, ITeardownContext teardownContext)
 {
     _default.PerformTeardown(action, teardownContext);
 }