Skip to content

Commit

Permalink
Fixing tests when run on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
belav committed Jul 25, 2023
1 parent 24a5876 commit b8d3ad2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Scripts/RunLinuxTests.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# running this seems to screw up the nuget restore, but provides a way to figure out why a test is failing on linux while working on windows.
# you have to run this from the root, IE powershell ./Scripts/RunLinuxTests.ps1
# also a lot of these tests fail due to line endings in your local files being \r\n but the writeLine using \n
docker run --rm -v ${pwd}:/app -e "NormalizeLineEndings=1" -w /app/tests mcr.microsoft.com/dotnet/sdk:6.0 dotnet test /app/Src/CSharpier.Tests/CSharpier.Tests.csproj --logger:trx
docker run --rm -v ${pwd}:/app -e "NormalizeLineEndings=1" -w /app/tests mcr.microsoft.com/dotnet/sdk:7.0 dotnet test /app/Src/CSharpier.Tests/CSharpier.Tests.csproj --logger:trx

# gross way to run csharpier against the csharpier-repos
#docker run --rm -v ${pwd}:/app -e "NormalizeLineEndings=1" -w /app mcr.microsoft.com/dotnet/sdk:5.0 dotnet ./csharpier/Src/CSharpier/bin/Debug/net6.0/dotnet-csharpier.dll csharpier-repos --skip-write
11 changes: 11 additions & 0 deletions Src/CSharpier.Tests/OptionsProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@ private class TestContext

public void WhenAFileExists(string path, string contents)
{
if (!OperatingSystem.IsWindows())
{
path = path.Replace("c:", string.Empty);
}

this.fileSystem.AddFile(path, new MockFileData(contents));
}

Expand All @@ -446,6 +451,12 @@ public async Task<PrinterOptions> CreateProviderAndGetOptionsFor(
string filePath
)
{
if (!OperatingSystem.IsWindows())
{
directoryName = directoryName.Replace("c:", string.Empty);
filePath = filePath.Replace("c:", string.Empty);
}

this.fileSystem.AddDirectory(directoryName);
var provider = await OptionsProvider.Create(
directoryName,
Expand Down

0 comments on commit b8d3ad2

Please sign in to comment.