fix scratch dir creation

This commit is contained in:
Adam Hathcock
2026-01-08 14:01:35 +00:00
parent 4f0a2e3c95
commit bdcc1d32c2
2 changed files with 29 additions and 13 deletions

View File

@@ -10,15 +10,16 @@ namespace SharpCompress.Test;
public class TestBase : IDisposable
{
private readonly string SOLUTION_BASE_PATH;
protected readonly string TEST_ARCHIVES_PATH;
protected readonly string ORIGINAL_FILES_PATH;
protected readonly string MISC_TEST_FILES_PATH;
private readonly string SCRATCH_BASE_PATH;
protected readonly string SCRATCH_FILES_PATH;
protected readonly string SCRATCH2_FILES_PATH;
private static readonly string SOLUTION_BASE_PATH;
public static readonly string TEST_ARCHIVES_PATH;
public static readonly string ORIGINAL_FILES_PATH;
public static readonly string MISC_TEST_FILES_PATH;
private static readonly string SCRATCH_BASE_PATH;
protected TestBase()
private static readonly string SCRATCH_DIRECTORY;
private static readonly string SCRATCH2_DIRECTORY;
static TestBase()
{
var index = AppDomain.CurrentDomain.BaseDirectory.IndexOf(
"SharpCompress.Test",
@@ -36,14 +37,31 @@ public class TestBase : IDisposable
"TestArchives",
Guid.NewGuid().ToString()
);
SCRATCH_FILES_PATH = Path.Combine(SCRATCH_BASE_PATH, "Scratch");
SCRATCH2_FILES_PATH = Path.Combine(SCRATCH_BASE_PATH, "Scratch2");
SCRATCH_DIRECTORY = Path.Combine(SCRATCH_BASE_PATH, "Scratch");
SCRATCH2_DIRECTORY = Path.Combine(SCRATCH_BASE_PATH, "Scratch2");
Directory.CreateDirectory(SCRATCH_DIRECTORY);
Directory.CreateDirectory(SCRATCH2_DIRECTORY);
}
private readonly Guid _testGuid = Guid.NewGuid();
protected readonly string SCRATCH_FILES_PATH;
protected readonly string SCRATCH2_FILES_PATH;
protected TestBase()
{
SCRATCH_FILES_PATH = Path.Combine(SCRATCH_DIRECTORY, _testGuid.ToString());
SCRATCH2_FILES_PATH = Path.Combine(SCRATCH2_DIRECTORY, _testGuid.ToString());
Directory.CreateDirectory(SCRATCH_FILES_PATH);
Directory.CreateDirectory(SCRATCH2_FILES_PATH);
}
public void Dispose() => Directory.Delete(SCRATCH_BASE_PATH, true);
public void Dispose()
{
Directory.Delete(SCRATCH_FILES_PATH, true);
Directory.Delete(SCRATCH2_FILES_PATH, true);
}
public void VerifyFiles()
{

View File

@@ -379,7 +379,6 @@ public class ZipArchiveTests : ArchiveTests
archive.SaveTo(scratchPath, writerOptions);
}
CompareArchivesByPath(unmodified, scratchPath, Encoding.GetEncoding(866));
Directory.Delete(SCRATCH_FILES_PATH, true);
}
/// <summary>
@@ -449,7 +448,6 @@ public class ZipArchiveTests : ArchiveTests
)
);
}
Directory.Delete(SCRATCH_FILES_PATH, true);
}
[Fact]