File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,6 +42,8 @@ protected TestBase(ITestOutputHelper logger)
4242
4343 protected static CancellationToken UnexpectedTimeoutToken => new CancellationTokenSource ( UnexpectedTimeout ) . Token ;
4444
45+ protected static bool IsTestRunOnAzurePipelines => ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "SYSTEM_DEFINITIONID" ) ) ;
46+
4547 protected ITestOutputHelper Logger { get ; }
4648
4749 protected CancellationToken TimeoutToken => Debugger . IsAttached ? CancellationToken . None : this . timeoutTokenSource . Token ;
@@ -61,6 +63,12 @@ protected static void AssertCollectedObject(WeakReference weakReference)
6163 GC . Collect ( ) ;
6264 GC . WaitForPendingFinalizers ( ) ;
6365
66+ // For some reason the assertion tends to be sketchy when running on Azure Pipelines.
67+ if ( IsTestRunOnAzurePipelines )
68+ {
69+ Assert . SkipWhen ( weakReference . IsAlive , "Weak reference is still alive." ) ;
70+ }
71+
6472 Assert . False ( weakReference . IsAlive ) ;
6573 }
6674
You can’t perform that action at this time.
0 commit comments