public IStorageActionsAccessor CreateAccessor()
        {
            var snapshotReference = new Reference <SnapshotReader> {
                Value = tableStorage.CreateSnapshot()
            };
            var writeBatchReference = new Reference <WriteBatch> {
                Value = new WriteBatch()
            };

            var accessor = new StorageActionsAccessor(uuidGenerator, _documentCodecs,
                                                      documentCacher, writeBatchReference, snapshotReference, tableStorage, this, bufferPool);

            accessor.OnDispose += () =>
            {
                var exceptionAggregator = new ExceptionAggregator("Could not properly dispose StorageActionsAccessor");

                exceptionAggregator.Execute(() => snapshotReference.Value.Dispose());
                exceptionAggregator.Execute(() => writeBatchReference.Value.Dispose());

                exceptionAggregator.ThrowIfNeeded();
            };

            return(accessor);
        }
Esempio n. 2
0
 public WpfTheoryTestCaseRunner(
     WpfTestSharedData sharedData,
     IXunitTestCase testCase,
     string displayName,
     string skipReason,
     object[] constructorArguments,
     IMessageSink diagnosticMessageSink,
     IMessageBus messageBus,
     ExceptionAggregator aggregator,
     CancellationTokenSource cancellationTokenSource
     )
     : base(
         testCase,
         displayName,
         skipReason,
         constructorArguments,
         diagnosticMessageSink,
         messageBus,
         aggregator,
         cancellationTokenSource
         )
 {
     SharedData = sharedData;
 }
Esempio n. 3
0
        public void Dispose()
        {
            var aggregator = new ExceptionAggregator("ClusterManager disposal error.");

            aggregator.Execute(SaflyDisposeOfTimer);
            aggregator.Execute(() =>
            {
                if (Engine != null && disableReplicationStateChecks == false)
                {
                    Engine.StateChanged -= OnRaftEngineStateChanged;
                }
            });
            aggregator.Execute(() =>
            {
                Client?.Dispose();
            });

            aggregator.Execute(() =>
            {
                Engine?.Dispose();
            });

            aggregator.ThrowIfNeeded();
        }
Esempio n. 4
0
        public void Dispose()
        {
            var ea = new ExceptionAggregator("Failed during dispose of document replication loader");

            ea.Execute(() =>
            {
                using (var waitHandle = new ManualResetEvent(false))
                {
                    if (_reconnectAttemptTimer.Dispose(waitHandle))
                    {
                        waitHandle.WaitOne();
                    }
                }
            });

            ea.Execute(() => ConflictResolver?.ResolveConflictsTask.Wait());

            if (_log.IsInfoEnabled)
            {
                _log.Info("Closing and disposing document replication connections.");
            }

            foreach (var incoming in _incoming)
            {
                ea.Execute(incoming.Value.Dispose);
            }

            foreach (var outgoing in _outgoing)
            {
                ea.Execute(outgoing.Dispose);
            }

            Database.TombstoneCleaner?.Unsubscribe(this);

            ea.ThrowIfNeeded();
        }
 public BenchmarkTestInvoker(
     ITest test,
     IMetricCollector metricCollector,
     IMessageBus messageBus,
     Type testClass,
     object[] constructorArguments,
     MethodInfo testMethod,
     object[] testMethodArguments,
     IReadOnlyList <BeforeAfterTestAttribute> beforeAfterAttributes,
     ExceptionAggregator aggregator,
     CancellationTokenSource cancellationTokenSource)
     : base(
         test,
         messageBus,
         testClass,
         constructorArguments,
         testMethod,
         testMethodArguments,
         beforeAfterAttributes,
         aggregator,
         cancellationTokenSource)
 {
     _metricCollector = metricCollector;
 }
 public IntegrationTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList <BeforeAfterTestAttribute> beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, Action <Result <Option <object>, Exception> > resultCallback)
     : base(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource)
 {
     _resultCallback = resultCallback;
 }
Esempio n. 7
0
 public DependencyInjectionTestInvoker(IServiceProvider provider, ITest test, IMessageBus messageBus,
                                       Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments,
                                       IReadOnlyList <BeforeAfterTestAttribute> beforeAfterAttributes, ExceptionAggregator aggregator,
                                       CancellationTokenSource cancellationTokenSource)
     : base(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments,
            beforeAfterAttributes, aggregator, cancellationTokenSource) =>
Esempio n. 8
0
 public ExceptionRunner(IXunitTestCase testCase, Exception exception, string output, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
     : base(testCase, messageBus, aggregator, cancellationTokenSource)
 {
     this.exception = exception;
     this.output    = output;
 }
Esempio n. 9
0
        public override Task <RunSummary> RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
        {
            var runner = new WpfTestCaseRunner(WpfTestSharedData.Instance, this, DisplayName, SkipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource);

            return(runner.RunAsync());
        }
Esempio n. 10
0
 /// <summary>
 /// Override test run to use UserContextTestCaseRunner
 /// </summary>
 /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param>
 /// <param name="messageBus">The message bus to report run status to.</param>
 /// <param name="constructorArguments">The arguments to be passed to the test class constructor.</param>
 /// <param name="aggregator">The exception aggregator used to run code and collect exceptions.</param>
 /// <param name="cancellationTokenSource">The task cancellation token source, used to cancel the test run.</param>
 /// <returns></returns>
 public override Task <RunSummary> RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
 {
     return(new UserContextTestCaseRunner(this, DisplayName, SkipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource, _userContext).RunAsync());
 }
 protected override Task <decimal> InvokeTestMethodAsync(ExceptionAggregator aggregator)
 => InvokeTestMethodAsync(aggregator, null);
Esempio n. 12
0
 public DependencyInjectionTestCaseRunner(IServiceProvider provider, IXunitTestCase testCase,
                                          string displayName, string skipReason, object?[] constructorArguments, object[] testMethodArguments,
                                          IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
     : base(testCase, displayName, skipReason, constructorArguments, testMethodArguments, messageBus,
            aggregator, cancellationTokenSource) => _provider = provider;
Esempio n. 13
0
 public BenchmarkTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, IMessageSink msgSink)
     : base(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, aggregator, cancellationTokenSource)
 {
     diagnosticMessageSink = msgSink;
 }
Esempio n. 14
0
 public BenchmarkTestClassRunner(ITestClass testClass, IReflectionTypeInfo @class, IEnumerable <BenchmarkTestCase> testCases, IMessageSink diagnosticMessageSink, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
     : base(testClass, @class, testCases, diagnosticMessageSink, messageBus, testCaseOrderer, aggregator, cancellationTokenSource)
 {
 }
Esempio n. 15
0
 public AppDomainFixtureContainer(IEnumerable <Type> fixtureTypes, ExceptionAggregator aggregator)
 {
     _fixtureTypes = fixtureTypes;
     _aggregator   = aggregator;
 }
 public CollectionRunner(Dictionary <Type, object> assemblyFixtureMappings, ITestCollection testCollection, IEnumerable <IXunitTestCase> testCases, IMessageSink diagnosticMessageSink, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
     : base(testCollection, testCases, diagnosticMessageSink, messageBus, testCaseOrderer, aggregator, cancellationTokenSource)
 {
     _assemblyFixtureMappings = assemblyFixtureMappings;
 }
 public ExecutionContextFlowingClassRunner(ITestClass testClass, IReflectionTypeInfo @class, IEnumerable <IXunitTestCase> testCases, IMessageSink diagnosticMessageSink, IMessageBus messageBus, ITestCaseOrderer testCaseOrderer, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, IDictionary <Type, object> collectionFixtureMappings)
     : base(testClass, @class, testCases, diagnosticMessageSink, messageBus, testCaseOrderer, aggregator, cancellationTokenSource, collectionFixtureMappings)
 {
 }
Esempio n. 18
0
 public DependencyInjectionTheoryTestCaseRunner(IServiceProvider provider, IXunitTestCase testCase,
                                                string displayName, string skipReason, object?[] constructorArguments, IMessageSink diagnosticMessageSink,
                                                IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
     : base(testCase, displayName, skipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource) =>
Esempio n. 19
0
 public TestCaseRunner(IXunitTestCase testCase, string displayName, string skipReason, object[] constructorArguments, object[] testMethodArguments, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
     : base(testCase, displayName, skipReason, constructorArguments, testMethodArguments, messageBus, aggregator, cancellationTokenSource)
 {
 }
 public ScenarioReportingXunitTestRunner(Scenario scenario, ScenarioReport report, ITest test, IMessageBus messageBus, Type testClass,
                                         object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason,
                                         IReadOnlyList <BeforeAfterTestAttribute> beforeAfterAttributes, ExceptionAggregator aggregator,
                                         CancellationTokenSource cancellationTokenSource) : base(test, messageBus, testClass, constructorArguments,
                                                                                                 testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource)
 {
     _scenario = scenario;
     _report   = report;
 }
Esempio n. 21
0
        public void Dispose()
        {
            var tryEnterWriteLock = disposerLock.TryEnterWriteLock(TimeSpan.FromMinutes(2));

            try
            {
                if (tryEnterWriteLock == false)
                {
                    log.Warn("After waiting for 2 minutes, could not acquire disposal lock, will force disposal anyway, pending transactions will all error");
                }

                if (disposed)
                {
                    return;
                }

                var exceptionAggregator = new ExceptionAggregator(log, "Could not close database properly");
                disposed = true;
                exceptionAggregator.Execute(current.Dispose);
                if (documentCacher != null)
                {
                    exceptionAggregator.Execute(documentCacher.Dispose);
                }

                if (inFlightTransactionalState != null)
                {
                    exceptionAggregator.Execute(inFlightTransactionalState.Dispose);
                }

                exceptionAggregator.Execute(() =>
                {
                    try
                    {
                        Api.JetTerm2(instance, TermGrbit.Complete);
                    }
                    catch (Exception e1)
                    {
                        log.ErrorException(
                            "Unexpected error occurred while terminating Esent Storage. Ignoring this error to allow to shutdown RavenDB instance.",
                            e1);

                        try
                        {
                            log.Warn(
                                "Will now attempt to perform an abrupt shutdown, because asking nicely didn't work. You might need to run defrag on the database to recover potentially lost space (but no data will be lost).");
                            Api.JetTerm2(instance, TermGrbit.Abrupt);
                        }
                        catch (Exception e2)
                        {
                            log.FatalException(
                                "Couldn't shut down the database server even when using abrupt, something is probably wrong and you'll need to restart the server process to access the database",
                                e2);
                        }
                    }
                    finally
                    {
                        GC.SuppressFinalize(this);
                    }
                });

                exceptionAggregator.Execute(current.Dispose);
                exceptionAggregator.Execute(disableBatchNesting.Dispose);
                exceptionAggregator.Execute(dtcTransactionContext.Dispose);

                exceptionAggregator.ThrowIfNeeded();
            }
            catch (Exception e)
            {
                log.FatalException("Could not dispose of the transactional storage for " + path, e);
                throw;
            }
            finally
            {
                if (tryEnterWriteLock)
                {
                    disposerLock.ExitWriteLock();
                }
            }
        }
 protected override Task <decimal> InvokeTestMethodAsync(ExceptionAggregator aggregator)
 {
     return(new ScenarioReportingTestInvoker(_scenario, _report, Test, MessageBus, TestClass, ConstructorArguments,
                                             TestMethod, TestMethodArguments, BeforeAfterAttributes, aggregator,
                                             CancellationTokenSource).RunAsync());
 }
Esempio n. 23
0
        private static void UnloadServer(AssemblyLoadContext obj)
        {
            try
            {
                lock (ServerLocker)
                {
                    var copyGlobalServer = _globalServer;
                    _globalServer = null;
                    if (copyGlobalServer == null)
                    {
                        return;
                    }

                    try
                    {
                        using (copyGlobalServer.ServerStore.ContextPool.AllocateOperationContext(out TransactionOperationContext context))
                            using (context.OpenReadTransaction())
                            {
                                var databases = copyGlobalServer
                                                .ServerStore
                                                .Cluster
                                                .ItemsStartingWith(context, Constants.Documents.Prefix, 0, int.MaxValue)
                                                .ToList();

                                if (databases.Count > 0)
                                {
                                    var sb = new StringBuilder();
                                    sb.AppendLine("List of non-deleted databases:");

                                    foreach (var t in databases)
                                    {
                                        var databaseName = t.ItemName.Substring(Constants.Documents.Prefix.Length);

                                        try
                                        {
                                            AsyncHelpers.RunSync(() => copyGlobalServer.ServerStore.DeleteDatabaseAsync(databaseName, hardDelete: true, null, Guid.NewGuid().ToString()));
                                        }
                                        catch (Exception)
                                        {
                                            // ignored
                                        }

                                        sb
                                        .Append("- ")
                                        .AppendLine(databaseName);
                                    }

                                    Console.WriteLine(sb.ToString());
                                }
                            }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine($"Could not retrieve list of non-deleted databases. Exception: {e}");
                    }

                    copyGlobalServer.Dispose();

                    GC.Collect(2);
                    GC.WaitForPendingFinalizers();

                    var exceptionAggregator = new ExceptionAggregator("Failed to cleanup test databases");

                    RavenTestHelper.DeletePaths(GlobalPathsToDelete, exceptionAggregator);

                    exceptionAggregator.ThrowIfNeeded();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                CheckServerLeak();
            }
        }
Esempio n. 24
0
        void RunTestImpl(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, TaskCompletionSource <RunSummary> tcs)
        {
            // Run on the UI thread
            using (var h = new Handler(Looper.MainLooper))
            {
                h.Post(() =>
                {
                    try
                    {
                        var result = testCase.RunAsync(diagnosticMessageSink, messageBus, constructorArguments, aggregator, cancellationTokenSource);
                        result.ContinueWith(t =>
                        {
                            if (t.IsFaulted)
                            {
                                tcs.SetException(t.Exception);
                            }

                            tcs.SetResult(t.Result);
                        });
                    }
                    catch (Exception e)
                    {
                        tcs.SetException(e);
                    }
                });
            }
        }
Esempio n. 25
0
 public ExceptionRunner(IXunitTestCase testCase, string[] exceptionTypes, string[] exceptionMessages, string[] exceptionStackTraces, int[] exceptionParenIndices, string output, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
     : base(testCase, messageBus, aggregator, cancellationTokenSource)
 {
     this.exceptionTypes        = exceptionTypes;
     this.exceptionMessages     = exceptionMessages;
     this.exceptionStackTraces  = exceptionStackTraces;
     this.exceptionParenIndices = exceptionParenIndices;
     this.output = output;
 }
Esempio n. 26
0
        /// <inheritdoc/>
        /// <exception cref="ValidationException">Empty secondary key columns collection.</exception>
        protected override void ValidateState()
        {
            using (var ea = new ExceptionAggregator()) {
                ea.Execute(base.ValidateState);

                // Secondary key columns: empty set, duplicates
                var keyColumns = KeyColumns.Select(valueRef => valueRef.Value).ToList();
                if (keyColumns.Count == 0)
                {
                    ea.Execute(() => {
                        throw new ValidationException(Strings.ExEmptyKeyColumnsCollection, Path);
                    });
                }
                foreach (var group in keyColumns
                         .GroupBy(keyColumn => keyColumn)
                         .Where(group => group.Count() > 1))
                {
                    ea.Execute((_column) => {
                        throw new ValidationException(
                            string.Format(Strings.ExMoreThenOneKeyColumnReferenceToColumnX, _column.Name),
                            Path);
                    }, group.Key);
                }

                // Primary key columns
                if (PrimaryKeyColumns.Count != Parent.PrimaryIndex.KeyColumns.Count)
                {
                    ea.Execute(() => {
                        throw new ValidationException(Strings.ExInvalidPrimaryKeyColumnsCollection, Path);
                    });
                }
                for (int i = 0; i < PrimaryKeyColumns.Count; i++)
                {
                    var ref1 = PrimaryKeyColumns[i];
                    var ref2 = Parent.PrimaryIndex.KeyColumns[i];
                    if (ref1.Value != ref2.Value || ref1.Direction != ref2.Direction)
                    {
                        ea.Execute(() => {
                            throw new ValidationException(Strings.ExInvalidPrimaryKeyColumnsCollection, Path);
                        });
                    }
                }

                // Included columns
                var fullKeySet = EnumerableExtensions.ToHashSet(KeyColumns
                                                                .Select(cr => cr.Value)
                                                                .Concat(PrimaryKeyColumns.Select(cr => cr.Value)));

                foreach (var columnRef in IncludedColumns)
                {
                    if (fullKeySet.Contains(columnRef.Value))
                    {
                        ea.Execute(() => {
                            throw new ValidationException(Strings.ExInvalidIncludedColumnsCollection, Path);
                        });
                    }
                }

                foreach (var group in IncludedColumns
                         .GroupBy(keyColumn => keyColumn)
                         .Where(group => group.Count() > 1))
                {
                    ea.Execute((_column) => {
                        throw new ValidationException(
                            string.Format(Strings.ExMoreThenOneIncludedColumnReferenceToColumnX, _column.Name),
                            Path);
                    }, group.Key);
                }

                ea.Complete();
            }
        }
Esempio n. 27
0
 protected abstract void Dispose(ExceptionAggregator exceptionAggregator);
Esempio n. 28
0
        public void Dispose()
        {
            if (disposed)
            {
                return;
            }

            Log.Debug("Start shutdown the following database: {0}", Name ?? Constants.SystemDatabase);

            EventHandler onDisposing = Disposing;

            if (onDisposing != null)
            {
                try
                {
                    onDisposing(this, EventArgs.Empty);
                }
                catch (Exception e)
                {
                    Log.WarnException("Error when notifying about db disposal, ignoring error and continuing with disposal", e);
                }
            }

            var exceptionAggregator = new ExceptionAggregator(Log, "Could not properly dispose of DatabaseDocument");

            exceptionAggregator.Execute(() =>
            {
                if (lastCollectionEtags != null)
                {
                    lastCollectionEtags.Flush();
                }
            });

            exceptionAggregator.Execute(() =>
            {
                if (prefetcher != null)
                {
                    prefetcher.Dispose();
                }
            });

            exceptionAggregator.Execute(() =>
            {
                initializer.UnsubscribeToDomainUnloadOrProcessExit();
                disposed = true;

                if (workContext != null)
                {
                    workContext.StopWorkRude();
                }
            });

            if (initializer != null)
            {
                exceptionAggregator.Execute(initializer.Dispose);
            }

            exceptionAggregator.Execute(() =>
            {
                if (ExtensionsState == null)
                {
                    return;
                }

                foreach (IDisposable value in ExtensionsState.Values.OfType <IDisposable>())
                {
                    exceptionAggregator.Execute(value.Dispose);
                }
            });

            exceptionAggregator.Execute(() =>
            {
                if (toDispose == null)
                {
                    return;
                }

                foreach (IDisposable shouldDispose in toDispose)
                {
                    exceptionAggregator.Execute(shouldDispose.Dispose);
                }
            });

            exceptionAggregator.Execute(() =>
            {
                if (Tasks != null)
                {
                    Tasks.Dispose(exceptionAggregator);
                }
            });

            exceptionAggregator.Execute(() =>
            {
                if (indexingBackgroundTask != null)
                {
                    indexingBackgroundTask.Wait();
                }
            });
            exceptionAggregator.Execute(() =>
            {
                if (reducingBackgroundTask != null)
                {
                    reducingBackgroundTask.Wait();
                }
            });

            exceptionAggregator.Execute(() =>
            {
                var disposable = backgroundTaskScheduler as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            });

            if (TransactionalStorage != null)
            {
                exceptionAggregator.Execute(TransactionalStorage.Dispose);
            }

            if (IndexStorage != null)
            {
                exceptionAggregator.Execute(IndexStorage.Dispose);
            }

            if (Configuration != null)
            {
                exceptionAggregator.Execute(Configuration.Dispose);
            }

            exceptionAggregator.Execute(disableAllTriggers.Dispose);

            if (workContext != null)
            {
                exceptionAggregator.Execute(workContext.Dispose);
            }

            exceptionAggregator.ThrowIfNeeded();

            Log.Debug("Finished shutdown the following database: {0}", Name ?? Constants.SystemDatabase);
        }
 protected override Task <decimal> InvokeTestMethodAsync(ExceptionAggregator aggregator)
 => new IntegrationTestInvoker(Test, MessageBus, TestClass, ConstructorArguments, TestMethod, TestMethodArguments, BeforeAfterAttributes, aggregator, CancellationTokenSource, _resultCallback).RunAsync();
Esempio n. 30
0
        public static async Task <RunSummary> RunTestAsync(XunitTestRunner runner,
                                                           IMessageBus messageBus,
                                                           ExceptionAggregator aggregator,
                                                           bool disableRetry)
        {
            // defense in depth to avoid forever lock
            bool acquired = await _semaphore.WaitAsync(TimeSpan.FromHours(2));

            try
            {
                DelayedMessageBus delayedMessageBus = null;
                RunSummary        summary           = null;

                if (!acquired)
                {
                    throw new TimeoutException("Wait for thread to run the test timeout!");
                }

                // First run
                if (!disableRetry)
                {
                    // This is really the only tricky bit: we need to capture and delay messages (since those will
                    // contain run status) until we know we've decided to accept the final result;
                    delayedMessageBus = new DelayedMessageBus(messageBus);

                    runner.SetMessageBus(delayedMessageBus);
                    summary = await RunTestInternalAsync(runner);

                    // if succeeded
                    if (summary.Failed == 0 || aggregator.HasExceptions)
                    {
                        delayedMessageBus.Flush(false);
                        return(summary);
                    }
                }

                // Final run
                runner.SetMessageBus(new KuduTraceMessageBus(messageBus));
                summary = await RunTestInternalAsync(runner);

                // flush delay messages
                if (delayedMessageBus != null)
                {
                    delayedMessageBus.Flush(summary.Failed == 0 && !aggregator.HasExceptions);
                }

                return(summary);
            }
            catch (Exception ex)
            {
                // this is catastrophic
                messageBus.QueueMessage(new TestFailed(runner.GetTest(), 0, null, ex));

                return(new RunSummary {
                    Failed = 1, Total = 1
                });
            }
            finally
            {
                if (acquired)
                {
                    _semaphore.Release();
                }

                // set to original
                runner.SetMessageBus(messageBus);
            }
        }