Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Tests/CShell.Tests/Exec.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,26 @@ public class ExecTests
private static string ShellFlag => IsWindows ? "/c" : "-c";

private string tempFolder;
private string originalFolder;

[TestInitialize]
public void Init()
{
this.originalFolder = Environment.CurrentDirectory;
this.tempFolder = Path.Combine(Path.GetTempPath(), "cshell-exec-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(this.tempFolder);
}

[TestCleanup]
public void Cleanup()
{
// A CShell's CurrentFolder is the PROCESS's current directory, so a test that started
// one in the temp folder left the whole test run standing in it. Step out before
// deleting: on Linux the delete otherwise succeeds and every later `new CShell()`
// throws from getcwd() on a directory that is no longer there, and on Windows the
// delete fails instead and the folders pile up.
Environment.CurrentDirectory = this.originalFolder;

try
{
Directory.Delete(this.tempFolder, true);
Expand Down
Loading