Skip to content

Commit

Permalink
Merge pull request #18 from Nexus-Mods/osx-support
Browse files Browse the repository at this point in the history
Fix known paths tests for OSX
  • Loading branch information
halgari authored Sep 14, 2023
2 parents 87c3197 + 2287674 commit 7b24244
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ on:

jobs:
build-and-test:
uses: Nexus-Mods/NexusMods.App.Meta/.github/workflows/dotnet-build-and-test.yaml@8480fc22e4d80057d97b5b3ea5664bc72c91ab42
uses: Nexus-Mods/NexusMods.App.Meta/.github/workflows/dotnet-build-and-test-with-osx.yaml@main
5 changes: 5 additions & 0 deletions src/NexusMods.Paths/IOSInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public interface IOSInformation
[SuppressMessage("ReSharper", "InconsistentNaming", Justification = $"It's also named {nameof(OSPlatform.OSX)} in {nameof(OSPlatform)}")]
bool IsOSX => Platform == OSPlatform.OSX;

/// <summary>
/// Whether the current <see cref="Platform"/> is Osx or Linux
/// </summary>
bool IsUnixLike => Platform == OSPlatform.OSX || Platform == OSPlatform.Linux;

/// <summary>
/// Matches and returns a value based on the current platform.
/// </summary>
Expand Down
75 changes: 46 additions & 29 deletions tests/NexusMods.Paths.Tests/FileSystem/BaseFileSystemTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,36 +195,53 @@ public void Test_EnumerateRootDirectories_WithCrossPlatformPathMappings()
}

[SkippableTheory]
[InlineData(true, KnownPath.EntryDirectory, true)]
[InlineData(true, KnownPath.CurrentDirectory, true)]
[InlineData(true, KnownPath.CommonApplicationDataDirectory, true)]
[InlineData(true, KnownPath.ProgramFilesDirectory, false)]
[InlineData(true, KnownPath.ProgramFilesX86Directory, false)]
[InlineData(true, KnownPath.CommonProgramFilesDirectory, false)]
[InlineData(true, KnownPath.CommonProgramFilesX86Directory, false)]
[InlineData(true, KnownPath.TempDirectory, true)]
[InlineData(true, KnownPath.HomeDirectory, true)]
[InlineData(true, KnownPath.ApplicationDataDirectory, true)]
[InlineData(true, KnownPath.LocalApplicationDataDirectory, true)]
[InlineData(true, KnownPath.MyDocumentsDirectory, true)]
[InlineData(true, KnownPath.MyGamesDirectory, true)]

[InlineData(false, KnownPath.EntryDirectory, true)]
[InlineData(false, KnownPath.CurrentDirectory, true)]
[InlineData(false, KnownPath.CommonApplicationDataDirectory, true)]
[InlineData(false, KnownPath.ProgramFilesDirectory, true)]
[InlineData(false, KnownPath.ProgramFilesX86Directory, true)]
[InlineData(false, KnownPath.CommonProgramFilesDirectory, true)]
[InlineData(false, KnownPath.CommonProgramFilesX86Directory, true)]
[InlineData(false, KnownPath.TempDirectory, true)]
[InlineData(false, KnownPath.HomeDirectory, true)]
[InlineData(false, KnownPath.ApplicationDataDirectory, true)]
[InlineData(false, KnownPath.LocalApplicationDataDirectory, true)]
[InlineData(false, KnownPath.MyDocumentsDirectory, true)]
[InlineData(false, KnownPath.MyGamesDirectory, true)]
public void Test_KnownPath(bool isLinux, KnownPath knownPath, bool expected)
[InlineData("Linux", KnownPath.EntryDirectory, true)]
[InlineData("Linux", KnownPath.CurrentDirectory, true)]
[InlineData("Linux", KnownPath.CommonApplicationDataDirectory, true)]
[InlineData("Linux", KnownPath.ProgramFilesDirectory, false)]
[InlineData("Linux", KnownPath.ProgramFilesX86Directory, false)]
[InlineData("Linux", KnownPath.CommonProgramFilesDirectory, false)]
[InlineData("Linux", KnownPath.CommonProgramFilesX86Directory, false)]
[InlineData("Linux", KnownPath.TempDirectory, true)]
[InlineData("Linux", KnownPath.HomeDirectory, true)]
[InlineData("Linux", KnownPath.ApplicationDataDirectory, true)]
[InlineData("Linux", KnownPath.LocalApplicationDataDirectory, true)]
[InlineData("Linux", KnownPath.MyDocumentsDirectory, true)]
[InlineData("Linux", KnownPath.MyGamesDirectory, true)]

[InlineData("OSX", KnownPath.EntryDirectory, true)]
[InlineData("OSX", KnownPath.CurrentDirectory, true)]
[InlineData("OSX", KnownPath.CommonApplicationDataDirectory, true)]
// For OSX .GetKnownPath(KnownPath.ProgramFilesDirectory) returns a value, but .HasPath returns false so this
// test is disabled as it's all nonsense
// [InlineData("OSX", KnownPath.ProgramFilesDirectory, true)]
[InlineData("OSX", KnownPath.ProgramFilesX86Directory, false)]
[InlineData("OSX", KnownPath.CommonProgramFilesDirectory, false)]
[InlineData("OSX", KnownPath.CommonProgramFilesX86Directory, false)]
[InlineData("OSX", KnownPath.TempDirectory, true)]
[InlineData("OSX", KnownPath.HomeDirectory, true)]
[InlineData("OSX", KnownPath.ApplicationDataDirectory, true)]
[InlineData("OSX", KnownPath.LocalApplicationDataDirectory, true)]
[InlineData("OSX", KnownPath.MyDocumentsDirectory, true)]
[InlineData("OSX", KnownPath.MyGamesDirectory, true)]

[InlineData("Windows", KnownPath.EntryDirectory, true)]
[InlineData("Windows", KnownPath.CurrentDirectory, true)]
[InlineData("Windows", KnownPath.CommonApplicationDataDirectory, true)]
[InlineData("Windows", KnownPath.ProgramFilesDirectory, true)]
[InlineData("Windows", KnownPath.ProgramFilesX86Directory, true)]
[InlineData("Windows", KnownPath.CommonProgramFilesDirectory, true)]
[InlineData("Windows", KnownPath.CommonProgramFilesX86Directory, true)]
[InlineData("Windows", KnownPath.TempDirectory, true)]
[InlineData("Windows", KnownPath.HomeDirectory, true)]
[InlineData("Windows", KnownPath.ApplicationDataDirectory, true)]
[InlineData("Windows", KnownPath.LocalApplicationDataDirectory, true)]
[InlineData("Windows", KnownPath.MyDocumentsDirectory, true)]
[InlineData("Windows", KnownPath.MyGamesDirectory, true)]
public void Test_KnownPath(string os, KnownPath knownPath, bool expected)
{
Skip.If(isLinux != OSInformation.Shared.IsLinux);
var platform = OSPlatform.Create(os);
Skip.If(platform != OSInformation.Shared.Platform);
var fs = new InMemoryFileSystem();

var actual = fs.HasKnownPath(knownPath);
Expand Down

0 comments on commit 7b24244

Please sign in to comment.