mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
WabbajackTest.TestUtils calls await on directory deletion
This commit is contained in:
parent
18d5f56f52
commit
165b857709
@ -78,10 +78,8 @@ namespace Wabbajack.Common
|
|||||||
using var tr = new StreamReader(stream, Encoding.UTF8, leaveOpen: true);
|
using var tr = new StreamReader(stream, Encoding.UTF8, leaveOpen: true);
|
||||||
using var reader = new JsonTextReader(tr);
|
using var reader = new JsonTextReader(tr);
|
||||||
var ser = JsonSerializer.Create(JsonSettings);
|
var ser = JsonSerializer.Create(JsonSettings);
|
||||||
return ser.Deserialize<T>(reader);
|
return ser.Deserialize<T>(reader)!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private class HashJsonConverter : JsonConverter<Hash>
|
private class HashJsonConverter : JsonConverter<Hash>
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ namespace Wabbajack.Test
|
|||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
{
|
{
|
||||||
utils.Dispose();
|
utils.DisposeAsync().AsTask().Wait();
|
||||||
_unsub.Dispose();
|
_unsub.Dispose();
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ namespace Wabbajack.Test
|
|||||||
{
|
{
|
||||||
Queue.Dispose();
|
Queue.Dispose();
|
||||||
_unsub.Dispose();
|
_unsub.Dispose();
|
||||||
|
utils.DisposeAsync().AsTask().Wait();
|
||||||
base.Dispose();
|
base.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ using Path = Alphaleonis.Win32.Filesystem.Path;
|
|||||||
|
|
||||||
namespace Wabbajack.Test
|
namespace Wabbajack.Test
|
||||||
{
|
{
|
||||||
public class TestUtils : IDisposable
|
public class TestUtils : IAsyncDisposable
|
||||||
{
|
{
|
||||||
private static Random _rng = new Random();
|
private static Random _rng = new Random();
|
||||||
public TestUtils()
|
public TestUtils()
|
||||||
@ -119,13 +119,14 @@ namespace Wabbajack.Test
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public async ValueTask DisposeAsync()
|
||||||
{
|
{
|
||||||
var exts = new [] {".md", ".exe"};
|
var exts = new[] { ".md", ".exe" };
|
||||||
WorkingDirectory.Combine(ID).DeleteDirectory();
|
await WorkingDirectory.Combine(ID).DeleteDirectory();
|
||||||
Profiles.Do(p =>
|
Profiles.Do(p =>
|
||||||
{
|
{
|
||||||
foreach (var ext in exts) {
|
foreach (var ext in exts)
|
||||||
|
{
|
||||||
var path = Path.Combine(Directory.GetCurrentDirectory(), p + ext);
|
var path = Path.Combine(Directory.GetCurrentDirectory(), p + ext);
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
File.Delete(path);
|
File.Delete(path);
|
||||||
@ -246,7 +247,5 @@ namespace Wabbajack.Test
|
|||||||
GenerateRandomFileData(fullPath, i);
|
GenerateRandomFileData(fullPath, i);
|
||||||
return fullPath;
|
return fullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ namespace Wabbajack.VirtualFileSystem.Test
|
|||||||
public async Task ArchiveContentsAreIndexed()
|
public async Task ArchiveContentsAreIndexed()
|
||||||
{
|
{
|
||||||
await AddFile(ARCHIVE_TEST_TXT, "This is a test");
|
await AddFile(ARCHIVE_TEST_TXT, "This is a test");
|
||||||
ZipUpFolder(ARCHIVE_TEST_TXT.Parent, TEST_ZIP);
|
await ZipUpFolder(ARCHIVE_TEST_TXT.Parent, TEST_ZIP);
|
||||||
await AddTestRoot();
|
await AddTestRoot();
|
||||||
|
|
||||||
var absPath = "test.zip".RelativeTo(VFS_TEST_DIR);
|
var absPath = "test.zip".RelativeTo(VFS_TEST_DIR);
|
||||||
@ -78,7 +78,7 @@ namespace Wabbajack.VirtualFileSystem.Test
|
|||||||
public async Task DuplicateFileHashes()
|
public async Task DuplicateFileHashes()
|
||||||
{
|
{
|
||||||
await AddFile(ARCHIVE_TEST_TXT, "This is a test");
|
await AddFile(ARCHIVE_TEST_TXT, "This is a test");
|
||||||
ZipUpFolder(ARCHIVE_TEST_TXT.Parent, TEST_ZIP);
|
await ZipUpFolder(ARCHIVE_TEST_TXT.Parent, TEST_ZIP);
|
||||||
|
|
||||||
await AddFile(TEST_TXT, "This is a test");
|
await AddFile(TEST_TXT, "This is a test");
|
||||||
await AddTestRoot();
|
await AddTestRoot();
|
||||||
@ -127,7 +127,7 @@ namespace Wabbajack.VirtualFileSystem.Test
|
|||||||
public async Task CanStageSimpleArchives()
|
public async Task CanStageSimpleArchives()
|
||||||
{
|
{
|
||||||
await AddFile(ARCHIVE_TEST_TXT, "This is a test");
|
await AddFile(ARCHIVE_TEST_TXT, "This is a test");
|
||||||
ZipUpFolder(ARCHIVE_TEST_TXT.Parent, TEST_ZIP);
|
await ZipUpFolder(ARCHIVE_TEST_TXT.Parent, TEST_ZIP);
|
||||||
await AddTestRoot();
|
await AddTestRoot();
|
||||||
|
|
||||||
var res = new FullPath(TEST_ZIP, new[] {(RelativePath)"test.txt"});
|
var res = new FullPath(TEST_ZIP, new[] {(RelativePath)"test.txt"});
|
||||||
@ -143,12 +143,12 @@ namespace Wabbajack.VirtualFileSystem.Test
|
|||||||
public async Task CanStageNestedArchives()
|
public async Task CanStageNestedArchives()
|
||||||
{
|
{
|
||||||
await AddFile(ARCHIVE_TEST_TXT, "This is a test");
|
await AddFile(ARCHIVE_TEST_TXT, "This is a test");
|
||||||
ZipUpFolder(ARCHIVE_TEST_TXT.Parent, TEST_ZIP);
|
await ZipUpFolder(ARCHIVE_TEST_TXT.Parent, TEST_ZIP);
|
||||||
|
|
||||||
var inner_dir = @"archive\other\dir".RelativeTo(VFS_TEST_DIR);
|
var inner_dir = @"archive\other\dir".RelativeTo(VFS_TEST_DIR);
|
||||||
inner_dir.CreateDirectory();
|
inner_dir.CreateDirectory();
|
||||||
TEST_ZIP.MoveTo( @"archive\other\dir\nested.zip".RelativeTo(VFS_TEST_DIR));
|
TEST_ZIP.MoveTo( @"archive\other\dir\nested.zip".RelativeTo(VFS_TEST_DIR));
|
||||||
ZipUpFolder(ARCHIVE_TEST_TXT.Parent, TEST_ZIP);
|
await ZipUpFolder(ARCHIVE_TEST_TXT.Parent, TEST_ZIP);
|
||||||
|
|
||||||
await AddTestRoot();
|
await AddTestRoot();
|
||||||
|
|
||||||
@ -168,10 +168,10 @@ namespace Wabbajack.VirtualFileSystem.Test
|
|||||||
await filename.WriteAllTextAsync(text);
|
await filename.WriteAllTextAsync(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ZipUpFolder(AbsolutePath folder, AbsolutePath output)
|
private static async Task ZipUpFolder(AbsolutePath folder, AbsolutePath output)
|
||||||
{
|
{
|
||||||
ZipFile.CreateFromDirectory((string)folder, (string)output);
|
ZipFile.CreateFromDirectory((string)folder, (string)output);
|
||||||
folder.DeleteDirectory();
|
await folder.DeleteDirectory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user