check if mono is running with --debug arg
This commit is contained in:
parent
d3f8e0ef4c
commit
13a259b473
|
@ -0,0 +1,59 @@
|
|||
using NUnit.Framework;
|
||||
using NzbDrone.Core.HealthCheck.Checks;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using static NzbDrone.Core.HealthCheck.Checks.MonoDebugCheck;
|
||||
|
||||
namespace NzbDrone.Core.Test.HealthCheck.Checks
|
||||
{
|
||||
[TestFixture]
|
||||
public class MonoDebugFixture : CoreTest<MonoDebugCheck>
|
||||
{
|
||||
private void GivenHasStackFrame(bool hasStackFrame)
|
||||
{
|
||||
Mocker.GetMock<StackFrameHelper>()
|
||||
.Setup(f => f.HasStackFrameInfo())
|
||||
.Returns(hasStackFrame);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_if_windows()
|
||||
{
|
||||
WindowsOnly();
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_if_not_debug()
|
||||
{
|
||||
MonoOnly();
|
||||
|
||||
GivenHasStackFrame(false);
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_log_warning_if_not_debug()
|
||||
{
|
||||
MonoOnly();
|
||||
|
||||
GivenHasStackFrame(false);
|
||||
|
||||
Subject.Check();
|
||||
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_return_ok_if_debug()
|
||||
{
|
||||
MonoOnly();
|
||||
|
||||
GivenHasStackFrame(true);
|
||||
|
||||
Subject.Check().ShouldBeOk();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -236,6 +236,7 @@
|
|||
<Compile Include="HealthCheck\Checks\ImportMechanismCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerSearchCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerRssCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MonoDebugFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MonoVersionCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\IndexerStatusCheckFixture.cs" />
|
||||
<Compile Include="HealthCheck\Checks\RootFolderCheckFixture.cs" />
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
using System.Diagnostics;
|
||||
using NLog;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
public class MonoDebugCheck : HealthCheckBase
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
private readonly StackFrameHelper _stackFrameHelper;
|
||||
|
||||
public override bool CheckOnSchedule => false;
|
||||
|
||||
public MonoDebugCheck(Logger logger, StackFrameHelper stackFrameHelper)
|
||||
{
|
||||
_logger = logger;
|
||||
_stackFrameHelper = stackFrameHelper;
|
||||
}
|
||||
|
||||
public class StackFrameHelper
|
||||
{
|
||||
public virtual bool HasStackFrameInfo()
|
||||
{
|
||||
var stackTrace = new StackTrace();
|
||||
|
||||
return stackTrace.FrameCount > 0 && stackTrace.GetFrame(0).GetFileColumnNumber() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override HealthCheck Check()
|
||||
{
|
||||
if (!PlatformInfo.IsMono)
|
||||
{
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
if (!_stackFrameHelper.HasStackFrameInfo())
|
||||
{
|
||||
_logger.Warn("Mono is not running with --debug switch");
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -577,6 +577,7 @@
|
|||
<Compile Include="HealthCheck\Checks\DownloadClientCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DownloadClientStatusCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DeprecatedDroneFactoryCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MonoDebugCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MonoTlsCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\MountCheck.cs" />
|
||||
<Compile Include="HealthCheck\Checks\DroneFactoryCheck.cs" />
|
||||
|
|
Loading…
Reference in New Issue