Skip to content

Commit f64e3cf

Browse files
committed
exclude tests with different behaviour on mono
1 parent e28b036 commit f64e3cf

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

src/log4net.Tests/Appender/RollingFileAppenderTest.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ namespace log4net.Tests.Appender
4141
[TestFixture]
4242
public sealed class RollingFileAppenderTest
4343
{
44-
private static readonly bool isMono = Type.GetType("Mono.Runtime") is not null;
45-
4644
private const string c_fileName = "test_41d3d834_4320f4da.log";
4745

4846
private const string c_testMessage98Chars =
@@ -1381,6 +1379,7 @@ private static void AssertFileEquals(string filename, string contents)
13811379
[Test]
13821380
public void TestLogOutput()
13831381
{
1382+
Utils.InconclusiveOnMono();
13841383
string filename = "test_simple.log";
13851384
SilentErrorHandler sh = new();
13861385
ILogger log = CreateLogger(filename, new FileAppender.ExclusiveLock(), sh);
@@ -1421,6 +1420,7 @@ public void TestExclusiveLockFails()
14211420
[Test]
14221421
public void TestExclusiveLockRecovers()
14231422
{
1423+
Utils.InconclusiveOnMono();
14241424
string filename = "test_exclusive_lock_recovers.log";
14251425

14261426
FileStream fs = new(filename, FileMode.Create, FileAccess.Write, FileShare.None);
@@ -1444,10 +1444,7 @@ public void TestExclusiveLockRecovers()
14441444
[Test]
14451445
public void TestExclusiveLockLocks()
14461446
{
1447-
if (isMono)
1448-
{
1449-
Assert.Inconclusive("mono has a different behaviour");
1450-
}
1447+
Utils.InconclusiveOnMono();
14511448
string filename = "test_exclusive_lock_locks.log";
14521449
bool locked = false;
14531450

@@ -1484,6 +1481,7 @@ public void TestExclusiveLockLocks()
14841481
[Test]
14851482
public void TestMinimalLockFails()
14861483
{
1484+
Utils.InconclusiveOnMono();
14871485
string filename = "test_minimal_lock_fails.log";
14881486

14891487
FileStream fs = new(filename, FileMode.Create, FileAccess.Write, FileShare.None);
@@ -1507,6 +1505,7 @@ public void TestMinimalLockFails()
15071505
[Test]
15081506
public void TestMinimalLockRecovers()
15091507
{
1508+
Utils.InconclusiveOnMono();
15101509
string filename = "test_minimal_lock_recovers.log";
15111510

15121511
FileStream fs = new(filename, FileMode.Create, FileAccess.Write, FileShare.None);
@@ -1530,6 +1529,7 @@ public void TestMinimalLockRecovers()
15301529
[Test]
15311530
public void TestMinimalLockUnlocks()
15321531
{
1532+
Utils.InconclusiveOnMono();
15331533
string filename = "test_minimal_lock_unlocks.log";
15341534
bool locked;
15351535

@@ -1558,6 +1558,7 @@ public void TestMinimalLockUnlocks()
15581558
[Test]
15591559
public void TestInterProcessLockFails()
15601560
{
1561+
Utils.InconclusiveOnMono();
15611562
string filename = "test_interprocess_lock_fails.log";
15621563

15631564
FileStream fs = new(filename, FileMode.Create, FileAccess.Write, FileShare.None);
@@ -1581,6 +1582,7 @@ public void TestInterProcessLockFails()
15811582
[Test]
15821583
public void TestInterProcessLockRecovers()
15831584
{
1585+
Utils.InconclusiveOnMono();
15841586
string filename = "test_interprocess_lock_recovers.log";
15851587

15861588
FileStream fs = new(filename, FileMode.Create, FileAccess.Write, FileShare.None);
@@ -1604,6 +1606,7 @@ public void TestInterProcessLockRecovers()
16041606
[Test]
16051607
public void TestInterProcessLockUnlocks()
16061608
{
1609+
Utils.InconclusiveOnMono();
16071610
string filename = "test_interprocess_lock_unlocks.log";
16081611
bool locked;
16091612

@@ -1632,6 +1635,7 @@ public void TestInterProcessLockUnlocks()
16321635
[Test]
16331636
public void TestInterProcessLockRoll()
16341637
{
1638+
Utils.InconclusiveOnMono();
16351639
const string filename = "test_interprocess_lock_roll.log";
16361640

16371641
SilentErrorHandler sh = new();

src/log4net.Tests/Appender/SmtpPickupDirAppenderTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ private static void DestroyLogger()
170170
[Test]
171171
public void TestOutputContainsSentDate()
172172
{
173+
Utils.InconclusiveOnMono();
173174
SilentErrorHandler sh = new SilentErrorHandler();
174175
SmtpPickupDirAppender appender = CreateSmtpPickupDirAppender(sh);
175176
ILogger log = CreateLogger(appender);
@@ -203,6 +204,7 @@ public void TestOutputContainsSentDate()
203204
[Test]
204205
public void TestConfigurableFileExtension()
205206
{
207+
Utils.InconclusiveOnMono();
206208
const string fileExtension = "eml";
207209
SilentErrorHandler sh = new SilentErrorHandler();
208210
SmtpPickupDirAppender appender = CreateSmtpPickupDirAppender(sh);
@@ -226,6 +228,7 @@ public void TestConfigurableFileExtension()
226228
[Test]
227229
public void TestDefaultFileNameIsAGuid()
228230
{
231+
Utils.InconclusiveOnMono();
229232
SilentErrorHandler sh = new SilentErrorHandler();
230233
SmtpPickupDirAppender appender = CreateSmtpPickupDirAppender(sh);
231234
ILogger log = CreateLogger(appender);

src/log4net.Tests/Core/LoggingEventTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ private static readonly DateTime localTime
3939
[Test]
4040
public void SerializeDeserialize_BinaryFormatter()
4141
{
42+
Utils.InconclusiveOnMono();
4243
var timestamp = localTime.ToUniversalTime();
4344
var ev = new LoggingEvent(new LoggingEventData
4445
{
@@ -87,6 +88,7 @@ public void SerializeDeserialize_BinaryFormatter()
8788
[Test]
8889
public void DeserializeV2()
8990
{
91+
Utils.InconclusiveOnMono();
9092
const string datPath = @"..\..\..\..\integration-testing\log4net2-SerializeEvent\SerializeV2Event.dat";
9193
using var stream = File.OpenRead(datPath);
9294
var formatter = new BinaryFormatter();

src/log4net.Tests/Utils.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,40 @@
1717
//
1818
#endregion
1919

20+
using System;
21+
using NUnit.Framework;
22+
2023
namespace log4net.Tests
2124
{
2225
/// <summary>
23-
/// Summary description for Class1.
26+
/// Utilities for testing
2427
/// </summary>
2528
public static class Utils
2629
{
30+
/// <summary>
31+
/// Is the mono runtime used
32+
/// </summary>
33+
internal static bool IsMono { get; } = Type.GetType("Mono.Runtime") is not null;
34+
35+
/// <summary>
36+
/// Skips the current test when run under mono
37+
/// </summary>
38+
internal static void InconclusiveOnMono()
39+
{
40+
if (IsMono)
41+
{
42+
Assert.Inconclusive("mono has a different behaviour");
43+
}
44+
}
45+
46+
/// <summary>
47+
/// Sample property key
48+
/// </summary>
2749
internal const string PROPERTY_KEY = "prop1";
2850

51+
/// <summary>
52+
/// Remove the <see cref="PROPERTY_KEY"/> from alle log4net contexts
53+
/// </summary>
2954
internal static void RemovePropertyFromAllContexts()
3055
{
3156
GlobalContext.Properties.Remove(PROPERTY_KEY);

0 commit comments

Comments
 (0)