mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Make the tests faster by defaulting to not indexing game files
This commit is contained in:
parent
124704939d
commit
4bcf2eb1b1
22
Wabbajack.Common/LogTime.cs
Normal file
22
Wabbajack.Common/LogTime.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Wabbajack.Common
|
||||
{
|
||||
public class LogTime : IAsyncDisposable
|
||||
{
|
||||
private readonly string _message;
|
||||
private readonly DateTime _start;
|
||||
|
||||
public LogTime(string message)
|
||||
{
|
||||
_message = message;
|
||||
_start = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
Utils.Log($"Log Time: {_message} {DateTime.UtcNow - _start}");
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ namespace Wabbajack.Common
|
||||
private Stream _inner;
|
||||
private WorkQueue? _queue;
|
||||
private DateTime _lastUpdate;
|
||||
private TimeSpan _span;
|
||||
|
||||
public StatusFileStream(Stream fs, string message, WorkQueue? queue = null)
|
||||
{
|
||||
@ -16,6 +17,7 @@ namespace Wabbajack.Common
|
||||
_inner = fs;
|
||||
_message = message;
|
||||
_lastUpdate = DateTime.UnixEpoch;
|
||||
_span = TimeSpan.FromMilliseconds(500);
|
||||
}
|
||||
|
||||
public override void Flush()
|
||||
@ -41,7 +43,7 @@ namespace Wabbajack.Common
|
||||
|
||||
private void UpdateStatus()
|
||||
{
|
||||
if (DateTime.Now - _lastUpdate < TimeSpan.FromMilliseconds(500))
|
||||
if (DateTime.Now - _lastUpdate < _span)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace Wabbajack.Common
|
||||
|
||||
public void MakeUpdate(Percent progress)
|
||||
{
|
||||
_progress.OnNext(OverAllStatus(progress));
|
||||
_progress.OnNext(progress);
|
||||
}
|
||||
|
||||
public void MakeUpdate(int max, int curr)
|
||||
|
@ -95,13 +95,27 @@ namespace Wabbajack.Lib
|
||||
Utils.Log($"VFS File Location: {VFSCacheName}");
|
||||
|
||||
if (cancel.IsCancellationRequested) return false;
|
||||
await VFS.IntegrateFromFile(VFSCacheName);
|
||||
|
||||
var roots = new List<AbsolutePath>
|
||||
{
|
||||
MO2Folder, GamePath, MO2DownloadsFolder, CompilingGame.GameLocation()
|
||||
};
|
||||
|
||||
if (VFSCacheName.Exists)
|
||||
await VFS.IntegrateFromFile(VFSCacheName);
|
||||
|
||||
List<AbsolutePath> roots;
|
||||
if (UseGamePaths)
|
||||
{
|
||||
roots = new List<AbsolutePath>
|
||||
{
|
||||
MO2Folder, GamePath, MO2DownloadsFolder, CompilingGame.GameLocation()
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
roots = new List<AbsolutePath>
|
||||
{
|
||||
MO2Folder, MO2DownloadsFolder
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// TODO: make this generic so we can add more paths
|
||||
|
||||
var lootPath = (AbsolutePath)Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
@ -349,6 +363,8 @@ namespace Wabbajack.Lib
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool UseGamePaths { get; set; } = true;
|
||||
|
||||
private async Task CleanInvalidArchives()
|
||||
{
|
||||
var remove = (await IndexedArchives.PMap(Queue, async a =>
|
||||
|
@ -33,19 +33,20 @@ namespace Wabbajack.Test
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
protected async Task<MO2Compiler> ConfigureAndRunCompiler(string profile)
|
||||
protected async Task<MO2Compiler> ConfigureAndRunCompiler(string profile, bool useGameFiles= false)
|
||||
{
|
||||
var compiler = new MO2Compiler(
|
||||
mo2Folder: utils.MO2Folder,
|
||||
mo2Profile: profile,
|
||||
outputFile: OutputFile(profile));
|
||||
compiler.UseGamePaths = useGameFiles;
|
||||
Assert.True(await compiler.Begin());
|
||||
return compiler;
|
||||
}
|
||||
|
||||
protected async Task<ModList> CompileAndInstall(string profile)
|
||||
protected async Task<ModList> CompileAndInstall(string profile, bool useGameFiles = false)
|
||||
{
|
||||
var compiler = await ConfigureAndRunCompiler(profile);
|
||||
var compiler = await ConfigureAndRunCompiler(profile, useGameFiles: useGameFiles);
|
||||
Utils.Log("Finished Compiling");
|
||||
await Install(compiler);
|
||||
return compiler.ModList;
|
||||
|
@ -73,7 +73,7 @@ namespace Wabbajack.Test
|
||||
await utils.AddManualDownload(
|
||||
new Dictionary<string, byte[]> {{"/baz/biz.pex", await testPex.ReadAllBytesAsync()}});
|
||||
|
||||
await CompileAndInstall(profile);
|
||||
await CompileAndInstall(profile, useGameFiles: true);
|
||||
|
||||
await utils.VerifyInstalledGameFile(@"enbstuff\test.pex");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user