Skip to content

Commit

Permalink
NLog.UnitTests - Changed IsTravis to IsLinux
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot committed Jan 29, 2021
1 parent 9e842c6 commit 70dea25
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/NLog/Config/LoggingConfiguration.cs
Expand Up @@ -848,7 +848,7 @@ internal string ExpandSimpleVariables(string input)
internal string ExpandSimpleVariables(string input, out string matchingVariableName)
{
string output = input;
var culture = StringComparison.CurrentCultureIgnoreCase;
var culture = StringComparison.OrdinalIgnoreCase;
matchingVariableName = null;

if (Variables.Count > 0 && output?.IndexOf("${") >= 0)
Expand Down
2 changes: 1 addition & 1 deletion tests/NLog.UnitTests/Config/CultureInfoTests.cs
Expand Up @@ -133,7 +133,7 @@ public void ProcessInfoLayoutRendererCultureTest()

var logEventInfo = CreateLogEventInfo(cultureName);

if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] CultureInfoTests.ProcessInfoLayoutRendererCultureTest because we are running in Travis");
}
Expand Down
14 changes: 7 additions & 7 deletions tests/NLog.UnitTests/Config/ReloadTests.cs
Expand Up @@ -110,7 +110,7 @@ private static void SetLogManagerConfiguration(bool useExplicitFileLoading, stri
public void TestAutoReloadOnFileChange(bool useExplicitFileLoading)
{
#if NETSTANDARD
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] ReloadTests.TestAutoReloadOnFileChange because we are running in Travis");
return;
Expand Down Expand Up @@ -170,7 +170,7 @@ public void TestAutoReloadOnFileChange(bool useExplicitFileLoading)
public void TestAutoReloadOnFileMove(bool useExplicitFileLoading)
{
#if NETSTANDARD
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] ReloadTests.TestAutoReloadOnFileMove because we are running in Travis");
return;
Expand Down Expand Up @@ -238,7 +238,7 @@ public void TestAutoReloadOnFileMove(bool useExplicitFileLoading)
public void TestAutoReloadOnFileCopy(bool useExplicitFileLoading)
{
#if NETSTANDARD
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] ReloadTests.TestAutoReloadOnFileCopy because we are running in Travis");
return;
Expand Down Expand Up @@ -306,7 +306,7 @@ public void TestAutoReloadOnFileCopy(bool useExplicitFileLoading)
public void TestIncludedConfigNoReload(bool useExplicitFileLoading)
{
#if NETSTANDARD
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] ReloadTests.TestIncludedConfigNoReload because we are running in Travis");
return;
Expand Down Expand Up @@ -372,7 +372,7 @@ public void TestIncludedConfigNoReload(bool useExplicitFileLoading)
public void TestIncludedConfigReload(bool useExplicitFileLoading)
{
#if NETSTANDARD
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] ReloadTests.TestIncludedConfigNoReload because we are running in Travis");
return;
Expand Down Expand Up @@ -438,7 +438,7 @@ public void TestIncludedConfigReload(bool useExplicitFileLoading)
public void TestMainConfigReload(bool useExplicitFileLoading)
{
#if NETSTANDARD
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] ReloadTests.TestMainConfigReload because we are running in Travis");
return;
Expand Down Expand Up @@ -509,7 +509,7 @@ public void TestMainConfigReload(bool useExplicitFileLoading)
public void TestMainConfigReloadIncludedConfigNoReload(bool useExplicitFileLoading)
{
#if NETSTANDARD
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] ReloadTests.TestMainConfigReload because we are running in Travis");
return;
Expand Down
2 changes: 1 addition & 1 deletion tests/NLog.UnitTests/Fluent/LogBuilderTests.cs
Expand Up @@ -475,7 +475,7 @@ public void LogBuilder_message_overloadsTest()
[Fact]
public void LogBuilder_message_cultureTest()
{
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] LogBuilderTests.LogBuilder_message_cultureTest because we are running in Travis");
return;
Expand Down
Expand Up @@ -118,7 +118,7 @@ public void DateTimeFormat()
[Fact]
public void DateTimeCulture()
{
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] EventPropertiesTests.DateTimeCulture because we are running in Travis");
return;
Expand Down
2 changes: 1 addition & 1 deletion tests/NLog.UnitTests/LayoutRenderers/IdentityTests.cs
Expand Up @@ -52,7 +52,7 @@ public class IdentityTests : NLogTestBase
public void WindowsIdentityTest()
{
#if NETSTANDARD
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] IdentityTests.WindowsIdentityTest NetStandard on Travis not supporting WindowsIdentity");
return; // NetCore on Travis not supporting WindowsIdentity
Expand Down
2 changes: 1 addition & 1 deletion tests/NLog.UnitTests/LogManagerTests.cs
Expand Up @@ -279,7 +279,7 @@ private void OnConfigReloaded(object sender, LoggingConfigurationReloadedEventAr
public void AutoReloadTest()
{
#if NETSTANDARD
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] LogManagerTests.AutoReloadTest because we are running in Travis");
return;
Expand Down
9 changes: 4 additions & 5 deletions tests/NLog.UnitTests/NLogTestBase.cs
Expand Up @@ -446,13 +446,12 @@ protected static CultureInfo GetCultureInfo(string cultureName)
}

/// <summary>
/// Are we running on Travis?
/// Are we running on Linux environment or Windows environemtn ?
/// </summary>
/// <returns></returns>
protected static bool IsTravis()
/// <returns>true when something else than Windows</returns>
protected static bool IsLinux()
{
var val = Environment.GetEnvironmentVariable("TRAVIS");
return val != null && val.Equals("true", StringComparison.OrdinalIgnoreCase);
return !NLog.Internal.PlatformDetector.IsWin32;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions tests/NLog.UnitTests/Targets/DatabaseTargetTests.cs
Expand Up @@ -1619,7 +1619,7 @@ public void RethrowingInstallExceptions()
[Fact]
public void SqlServer_NoTargetInstallException()
{
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("skipping test SqlServer_NoTargetInstallException because we are running in Travis");
return;
Expand Down Expand Up @@ -1671,7 +1671,7 @@ IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = 'dbo' AN
[Fact]
public void SqlServer_InstallAndLogMessage()
{
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("skipping test SqlServer_InstallAndLogMessage because we are running in Travis");
return;
Expand Down
6 changes: 3 additions & 3 deletions tests/NLog.UnitTests/Targets/FileTargetTests.cs
Expand Up @@ -122,7 +122,7 @@ public void SimpleFileTest(bool concurrentWrites, bool keepFileOpen, bool networ
[MemberData(nameof(SimpleFileTest_TestParameters))]
public void SimpleFileDeleteTest(bool concurrentWrites, bool keepFileOpen, bool networkWrites, bool forceManaged, bool forceMutexConcurrentWrites)
{
bool isSimpleKeepFileOpen = keepFileOpen && !networkWrites && !concurrentWrites && IsTravis();
bool isSimpleKeepFileOpen = keepFileOpen && !networkWrites && !concurrentWrites && IsLinux();
#if MONO
if (IsTravis() && concurrentWrites && keepFileOpen && !networkWrites)
{
Expand Down Expand Up @@ -411,7 +411,7 @@ public void RollingArchiveEveryMonth()
[InlineData(true, true, ArchiveNumberingMode.Sequence)]
public void DatedArchiveEveryMonth(bool archiveSubFolder, bool maxArchiveDays, ArchiveNumberingMode archiveNumberingMode)
{
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] FileTargetTests.DatedArchiveEveryMonth because SetCreationTime is not working on Travis");
return;
Expand Down Expand Up @@ -1392,7 +1392,7 @@ where UniqueBaseAppender(concurrentWrites, keepFileOpen, networkWrites, forceMut
public void DateArchive_UsesDateFromCurrentTimeSource(DateTimeKind timeKind, bool includeDateInLogFilePath, bool concurrentWrites, bool keepFileOpen, bool networkWrites, bool includeSequenceInArchive, bool forceManaged, bool forceMutexConcurrentWrites, bool maxArhiveDays)
{
#if NETSTANDARD
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] FileTargetTests.DateArchive_UsesDateFromCurrentTimeSource because SetLastWriteTime is not working on Travis");
return;
Expand Down
2 changes: 1 addition & 1 deletion tests/NLog.UnitTests/Targets/NetworkTargetTests.cs
Expand Up @@ -906,7 +906,7 @@ public void SslProtocolsConfigTest(string sslOptions, SslProtocols expected)
[InlineData("30", 30)]
public void KeepAliveTimeConfigTest(string keepAliveTimeSeconds, int expected)
{
if (IsTravis())
if (IsLinux())
{
Console.WriteLine("[SKIP] NetworkTargetTests.KeepAliveTimeConfigTest because we are running in Travis");
return;
Expand Down
Expand Up @@ -174,7 +174,7 @@ private void AsyncTargetWrapperSyncTest_WhenTimeToSleepBetweenBatchesIsEqualToZe
}
}

#if !NET35 && !NET40
#if DEBUG
if (!IsAppVeyor()) // Skip timing test when running within OpenCover.Console.exe
#endif
Assert.InRange(elapsedMilliseconds, 0, 975);
Expand Down

0 comments on commit 70dea25

Please sign in to comment.