Skip to content

Commit

Permalink
Change cli tests to run in a temp directory to avoid potential issues… (
Browse files Browse the repository at this point in the history
#1515)

… with config/ignore files in directory tree
  • Loading branch information
belav authored Feb 28, 2025
1 parent bbea252 commit 0bc6669
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Src/CSharpier.Cli.Tests/CliTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using CliWrap;
using CliWrap.Buffered;
Expand All @@ -17,10 +15,9 @@ namespace CSharpier.Cli.Tests;
// are written properly
public class CliTests
{
private static readonly string testFileDirectory = Path.Combine(
Directory.GetCurrentDirectory(),
"TestFiles"
);
private static readonly string testFileDirectory = Directory
.CreateTempSubdirectory("CsharpierTestFies")
.FullName;

[SetUp]
public void BeforeEachTest()
Expand All @@ -30,6 +27,12 @@ public void BeforeEachTest()
File.Delete(FormattingCacheFactory.CacheFilePath);
}

Directory.CreateDirectory(testFileDirectory);
}

[TearDown]
public void AfterEachTest()
{
void DeleteDirectory()
{
if (Directory.Exists(testFileDirectory))
Expand All @@ -47,8 +50,6 @@ void DeleteDirectory()
Thread.Sleep(TimeSpan.FromMilliseconds(100));
DeleteDirectory();
}

Directory.CreateDirectory(testFileDirectory);
}

[TestCase("\n")]
Expand Down

0 comments on commit 0bc6669

Please sign in to comment.