Skip to content

Commit

Permalink
refactor: normalize line endings using .gitattributes (#487)
Browse files Browse the repository at this point in the history
The .gitattributes file is inspired by
[NUnit](https://github.com/nunit/nunit/blob/master/.gitattributes).

---------

Co-authored-by: Valentin <valentin.breuss@baur.at>
  • Loading branch information
vbreuss and vbreuss authored Mar 14, 2024
1 parent 7e28ffa commit 4479e41
Show file tree
Hide file tree
Showing 5 changed files with 1,494 additions and 1,476 deletions.
18 changes: 18 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Normalize line endings
* text=auto

# Prevent files from being exported
.gitattributes export-ignore
.gitignore export-ignore

# ReSharper DotSettings files are in Unix Format
*.DotSettings text eol=lf

# MonoDevelop on Linux uses CRLF for these files
*.sln text eol=crlf
packages/repositories.config text eol=crlf

# Allows checking out and developing in Windows
# while mounting and running tests in Linux
*.sh text eol=lf
build text eol=lf
132 changes: 66 additions & 66 deletions Tests/Helpers/Testably.Abstractions.TestHelpers/Test.cs
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
using System.IO.Abstractions;
using System.Runtime.InteropServices;
using Xunit;

namespace Testably.Abstractions.TestHelpers;

public class Test
{
public static bool IsNet7OrGreater
#if NET7_0_OR_GREATER
=> true;
#else
=> false;
#endif
public bool IsNetFramework { get; }

public bool RunsOnLinux { get; }

public bool RunsOnMac { get; }

public bool RunsOnWindows { get; }

public Test()
{
RunsOnLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
RunsOnMac = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
RunsOnWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
IsNetFramework = RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework");
}

public static void SkipBrittleTestsOnRealFileSystem(
IFileSystem fileSystem, bool condition = true)
{
Skip.If(fileSystem is RealFileSystem && condition,
"Brittle tests are skipped on the real file system.");
}

public static void SkipBrittleTestsOnRealTimeSystem(
ITimeSystem timeSystem, bool condition = true)
{
Skip.If(timeSystem is RealTimeSystem && condition,
"Brittle tests are skipped on the real time system.");
}

public static void SkipIfLongRunningTestsShouldBeSkipped(IFileSystem fileSystem)
{
#if DEBUG && !INCLUDE_LONGRUNNING_TESTS_ALSO_IN_DEBUG_MODE
Skip.If(fileSystem is RealFileSystem,
"Long-Running tests are skipped in DEBUG mode unless the build constant 'INCLUDE_LONG_RUNNING_TESTS_ALSO_IN_DEBUG_MODE' is set.");
#endif
// ReSharper disable once CommentTypo
// Do nothing when in release mode or `INCLUDE_LONGRUNNING_TESTS_ALSO_IN_DEBUG_MODE` is set
}

public static void SkipIfTestsOnRealFileSystemShouldBeSkipped(IFileSystem fileSystem)
{
#if NCRUNCH
Skip.If(fileSystem is RealFileSystem, "NCrunch should not test the real file system.");
#endif
#if DEBUG && SKIP_TESTS_ON_REAL_FILESYSTEM
Skip.If(fileSystem is RealFileSystem,
"Tests against real FileSystem are skipped in DEBUG mode with the build constant 'SKIP_TESTS_ON_REAL_FILESYSTEM'.");
#endif
// Do nothing when in release mode or `SKIP_TESTS_ON_REAL_FILESYSTEM` is not set
}
}
using System.IO.Abstractions;
using System.Runtime.InteropServices;
using Xunit;

namespace Testably.Abstractions.TestHelpers;

public class Test
{
public static bool IsNet7OrGreater
#if NET7_0_OR_GREATER
=> true;
#else
=> false;
#endif
public bool IsNetFramework { get; }

public bool RunsOnLinux { get; }

public bool RunsOnMac { get; }

public bool RunsOnWindows { get; }

public Test()
{
RunsOnLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
RunsOnMac = RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
RunsOnWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
IsNetFramework = RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework");
}

public static void SkipBrittleTestsOnRealFileSystem(
IFileSystem fileSystem, bool condition = true)
{
Skip.If(fileSystem is RealFileSystem && condition,
"Brittle tests are skipped on the real file system.");
}

public static void SkipBrittleTestsOnRealTimeSystem(
ITimeSystem timeSystem, bool condition = true)
{
Skip.If(timeSystem is RealTimeSystem && condition,
"Brittle tests are skipped on the real time system.");
}

public static void SkipIfLongRunningTestsShouldBeSkipped(IFileSystem fileSystem)
{
#if DEBUG && !INCLUDE_LONGRUNNING_TESTS_ALSO_IN_DEBUG_MODE
Skip.If(fileSystem is RealFileSystem,
"Long-Running tests are skipped in DEBUG mode unless the build constant 'INCLUDE_LONG_RUNNING_TESTS_ALSO_IN_DEBUG_MODE' is set.");
#endif
// ReSharper disable once CommentTypo
// Do nothing when in release mode or `INCLUDE_LONGRUNNING_TESTS_ALSO_IN_DEBUG_MODE` is set
}

public static void SkipIfTestsOnRealFileSystemShouldBeSkipped(IFileSystem fileSystem)
{
#if NCRUNCH
Skip.If(fileSystem is RealFileSystem, "NCrunch should not test the real file system.");
#endif
#if DEBUG && SKIP_TESTS_ON_REAL_FILESYSTEM
Skip.If(fileSystem is RealFileSystem,
"Tests against real FileSystem are skipped in DEBUG mode with the build constant 'SKIP_TESTS_ON_REAL_FILESYSTEM'.");
#endif
// Do nothing when in release mode or `SKIP_TESTS_ON_REAL_FILESYSTEM` is not set
}
}
Loading

0 comments on commit 4479e41

Please sign in to comment.