Skip to content

Commit

Permalink
Merge branch 'main' into topic/vb/net8.0-enable
Browse files Browse the repository at this point in the history
  • Loading branch information
vbreuss authored Oct 31, 2023
2 parents ef44730 + b053078 commit 922dd04
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 28 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarCloud packages
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand All @@ -176,7 +176,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand All @@ -202,7 +202,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Download code coverage files (MacOS)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-stryker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
timeout-minutes: 300
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup MSBuild
Expand All @@ -138,7 +138,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Save PR number to file
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
distribution: 'temurin'
java-version: '17'
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Tag current commit
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Tag current commit
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Tag current commit
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Tag current commit
Expand Down Expand Up @@ -156,7 +156,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Tag current commit
Expand All @@ -180,7 +180,7 @@ jobs:
runs-on: windows-latest
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Tag current commit
Expand Down Expand Up @@ -211,7 +211,7 @@ jobs:
timeout-minutes: 300
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand Down Expand Up @@ -239,7 +239,7 @@ jobs:
timeout-minutes: 300
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand Down Expand Up @@ -282,7 +282,7 @@ jobs:
needs: [analyze, test-macos, test-ubuntu, test-windows, test-net-framework, test-examples]
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Tag current commit
Expand Down Expand Up @@ -348,7 +348,7 @@ jobs:
label-template: |
state: released
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Delete release branch
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stryker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
timeout-minutes: 300
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
timeout-minutes: 300
steps:
- name: Checkout sources
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0
- name: Setup .NET
Expand Down
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />
<PackageVersion Include="xunit" Version="2.5.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.1" />
<PackageVersion Include="xunit" Version="2.5.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="NSubstitute" Version="5.1.0" />
</ItemGroup>
Expand Down
15 changes: 15 additions & 0 deletions Source/Testably.Abstractions.Testing/FileSystem/PathMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ public override string GetFullPath(string path)
{
path.EnsureValidArgument(FileSystem, nameof(path));

string? pathRoot = Path.GetPathRoot(path);
string? directoryRoot = Path.GetPathRoot(_fileSystem.Storage.CurrentDirectory);
if (!string.IsNullOrEmpty(pathRoot) && !string.IsNullOrEmpty(directoryRoot))
{
if (char.ToUpperInvariant(pathRoot[0]) != char.ToUpperInvariant(directoryRoot[0]))
{
return Path.GetFullPath(path);
}

if (pathRoot.Length < directoryRoot.Length)
{
path = path.Substring(pathRoot.Length);
}
}

return Path.GetFullPath(Path.Combine(
_fileSystem.Storage.CurrentDirectory,
path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public IEnumerable<IStorageLocation> EnumerateLocations(
enumerationOptions ??= EnumerationOptionsHelper.Compatible;

string fullPath = location.FullPath;
string fullPathWithoutTrailingSlash = fullPath;
#if NETSTANDARD2_0
if (!fullPath.EndsWith($"{_fileSystem.Path.DirectorySeparatorChar}"))
#else
Expand All @@ -181,6 +182,10 @@ public IEnumerable<IStorageLocation> EnumerateLocations(
{
fullPath += _fileSystem.Path.DirectorySeparatorChar;
}
else if (_fileSystem.Path.GetPathRoot(fullPath) != fullPath)
{
fullPathWithoutTrailingSlash = fullPathWithoutTrailingSlash.TrimEnd(_fileSystem.Path.DirectorySeparatorChar);
}

foreach (KeyValuePair<IStorageLocation, IStorageContainer> item in _containers
.Where(x => x.Key.FullPath.StartsWith(fullPath,
Expand All @@ -192,7 +197,7 @@ public IEnumerable<IStorageLocation> EnumerateLocations(
item.Key.FullPath.TrimEnd(_fileSystem.Path
.DirectorySeparatorChar));
if (!enumerationOptions.RecurseSubdirectories &&
parentPath?.Equals(location.FullPath,
parentPath?.Equals(fullPathWithoutTrailingSlash,
InMemoryLocation.StringComparisonMode) != true)
{
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,16 @@ public void

result.Count().Should().Be(2);
}

[SkippableFact]
public void EnumerateDirectories_WithTrailingSlash_ShouldEnumerateSubdirectories()
{
string queryPath = @"foo" + FileSystem.Path.DirectorySeparatorChar;
string expectedPath = FileSystem.Path.Combine("foo", "bar");
FileSystem.Directory.CreateDirectory(expectedPath);

IEnumerable<string> actualResult = FileSystem.Directory.EnumerateDirectories(queryPath);

actualResult.Should().BeEquivalentTo(expectedPath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,49 @@ public abstract partial class GetFullPathTests<TFileSystem>
: FileSystemTestBase<TFileSystem>
where TFileSystem : IFileSystem
{
[SkippableFact]
public void GetFullPath_Dot_ShouldReturnToCurrentDirectory()
{
string expectedFullPath = FileSystem.Directory.GetCurrentDirectory();

string result = FileSystem.Path.GetFullPath(".");

result.Should().Be(expectedFullPath);
}

[SkippableFact]
public void GetFullPath_RelativePathWithDrive_ShouldReturnExpectedValue()
{
Skip.IfNot(Test.RunsOnWindows);

string currentDirectory = FileSystem.Directory.GetCurrentDirectory();
string drive = currentDirectory.Substring(0, 1);
string input = $"{drive}:test.txt";
string expectedFullPath = FileSystem.Path.Combine(currentDirectory, "test.txt");

string result = FileSystem.Path.GetFullPath(input);

result.Should().Be(expectedFullPath);
}

[SkippableFact]
public void
GetFullPath_RelativePathWithDrive_WhenCurrentDirectoryIsDifferent_ShouldReturnExpectedValue()
{
Skip.IfNot(Test.RunsOnWindows);

string currentDirectory = FileSystem.Directory.GetCurrentDirectory();
string otherDrive = currentDirectory
.Substring(0,1)
.Equals("x", StringComparison.OrdinalIgnoreCase) ? "Y" : "X";
string input = $"{otherDrive}:test.txt";
string expectedFullPath = $@"{otherDrive}:\test.txt";

string result = FileSystem.Path.GetFullPath(input);

result.Should().Be(expectedFullPath);
}

[SkippableTheory]
[InlineData(@"top/../most/file", @"most/file")]
[InlineData(@"top/../most/../dir/file", @"dir/file")]
Expand Down

0 comments on commit 922dd04

Please sign in to comment.