public async Task <FilePath?> Run( IGroupRun groupRun, PatcherPrepBundle[] patchers, CancellationToken cancellation, FilePath?sourcePath, RunParameters runParameters) { for (int i = 0; i < patchers.Length; i++) { var patcher = patchers[i]; var nextPath = await RunAPatcher.Run( groupRun, patcher, cancellation, sourcePath, runParameters).ConfigureAwait(false); if (nextPath == null) { return(null); } sourcePath = nextPath; } return(sourcePath); }
public void PassesOutputPathToLoadOrderForRunProvider( IGroupRun groupRun, IReadOnlySet <ModKey> blacklist, GroupRunLoadOrderPreparer sut) { sut.Write(groupRun, blacklist); sut.LoadOrderForRunProvider.Received(1).Get(groupRun.ModKey, blacklist); }
public void PathReturnsUnderWorkingDirectory( IGroupRun groupRun, DirectoryPath workingDirectory, RunLoadOrderPathProvider sut) { sut.ProfileDirectories.WorkingDirectory.Returns(workingDirectory); sut.PathFor(groupRun).IsUnderneath(workingDirectory).Should().BeTrue(); }
public void PatcherNameShouldBeSanitizedName( IGroupRun groupRun, IPatcherRun patcher, FilePath?sourcePath, RunParameters runParameters, string sanitize, RunArgsConstructor sut) { sut.PatcherNameSanitizer.Sanitize(default !).ReturnsForAnyArgs(sanitize);
public async Task PassesOutputToRunLoadOrderPreparer( IGroupRun groupRun, IReadOnlySet <ModKey> blacklist, GroupRunPreparer sut) { await sut.Prepare(groupRun, blacklist); sut.GroupRunLoadOrderPreparer.Received(1).Write(groupRun, blacklist); }
public void PassesPatcherNameToSanitizer( IGroupRun groupRun, IPatcherRun patcher, FilePath?sourcePath, RunParameters runParameters, RunArgsConstructor sut) { sut.GetArgs(groupRun, patcher, sourcePath, runParameters); sut.PatcherNameSanitizer.Received(1).Sanitize(patcher.Name); }
public async Task RetrievesArgs( IGroupRun groupRun, IPatcherRun patcher, CancellationToken cancellation, FilePath?sourcePath, RunParameters runParameters, RunSynthesisPatcher args, RunAPatcher sut) { sut.GetRunArgs.GetArgs(default !, default !, default, default !)
public async Task PassesPersistenceToPersister( IGroupRun groupRun, PersistenceMode persistenceMode, IReadOnlySet <ModKey> blacklist, string?persistencePath, GroupRunPreparer sut) { await sut.Prepare(groupRun, blacklist, persistenceMode, persistencePath); sut.PersistencePreparer.Received(1).Prepare(persistenceMode, persistencePath); }
public void OutputPathUnderWorkingDirectory( IGroupRun groupRun, IPatcherRun patcher, FilePath?sourcePath, RunParameters runParameters, RunArgsConstructor sut) { var result = sut.GetArgs(groupRun, patcher, sourcePath, runParameters); result.OutputPath.IsUnderneath(sut.ProfileDirectories.WorkingDirectory) .Should().BeTrue(); }
public GroupRunVm( GroupVm groupVm, IGroupRun run, RunDisplayControllerVm runDisplayControllerVm, IEnumerable <PatcherRunVm> runVms) { SourceVm = groupVm; GroupVm = groupVm; Run = run; RunDisplayControllerVm = runDisplayControllerVm; Patchers = runVms; _hasStarted = runVms.AsObservableChangeSet() .FilterOnObservable(x => x.WhenAnyValue(x => x.State.Value) .Select(x => x != RunState.NotStarted)) .QueryWhenChanged(q => q.Count > 0) .ToGuiProperty(this, nameof(HasStarted), deferSubscription: true); _runTimeString = runVms.AsObservableChangeSet() .AutoRefresh(x => x.RunTime) .Transform(x => x.RunTime, transformOnRefresh: true) .QueryWhenChanged(q => { TimeSpan span = new(); foreach (var s in q) { span += s; } return(span); }) .Select(time => { if (time == new TimeSpan()) { return(string.Empty); } if (time.TotalDays > 1) { return($"{time.TotalDays:n1}d"); } if (time.TotalHours > 1) { return($"{time.TotalHours:n1}h"); } if (time.TotalMinutes > 1) { return($"{time.TotalMinutes:n1}m"); } return($"{time.TotalSeconds:n1}s"); }) .ToGuiProperty <string>(this, nameof(RunTimeString), string.Empty, deferSubscription: true); }
public async Task <FilePath?> Run( IGroupRun groupRun, PatcherPrepBundle prepBundle, CancellationToken cancellation, FilePath?sourcePath, RunParameters runParameters) { try { // Finish waiting for prep, if it didn't finish var prepException = await prepBundle.Prep.ConfigureAwait(false); if (prepException != null) { return(null); } var args = GetRunArgs.GetArgs( groupRun, prepBundle.Run, sourcePath, runParameters); _fs.Directory.CreateDirectory(args.OutputPath.Directory !); _logger.Information("================= Starting Patcher {Patcher} Run =================", prepBundle.Run.Name); _reporter.ReportStartingRun(prepBundle.Run.Key, prepBundle.Run.Name); await prepBundle.Run.Run(args, cancel : cancellation).ConfigureAwait(false); if (cancellation.IsCancellationRequested) { return(null); } return(FinalizePatcherRun.Finalize(prepBundle.Run, args.OutputPath)); } catch (TaskCanceledException) { return(null); } catch (Exception ex) { _reporter.ReportRunProblem(prepBundle.Run.Key, prepBundle.Run.Name, ex); return(null); } }
public async Task ThrowingPersistencePrepareStillRunsLoadOrderPrepare( IGroupRun groupRun, PersistenceMode persistenceMode, IReadOnlySet <ModKey> blacklist, string?persistencePath, GroupRunPreparer sut) { sut.PersistencePreparer.When(x => x.Prepare(Arg.Any <PersistenceMode>(), Arg.Any <string?>())) .Do(_ => throw new NotImplementedException()); await Assert.ThrowsAsync <NotImplementedException>(async() => { await sut.Prepare(groupRun, blacklist, persistenceMode, persistencePath); }); sut.GroupRunLoadOrderPreparer.Received(1).Write(groupRun, blacklist); }
public async Task Prepare( IGroupRun groupRun, IReadOnlySet <ModKey> blackListedMods, PersistenceMode persistenceMode = PersistenceMode.None, string?persistencePath = null) { await Task.WhenAll( Task.Run(() => { GroupRunLoadOrderPreparer.Write(groupRun, blackListedMods); }), Task.Run(() => { PersistencePreparer.Prepare(persistenceMode, persistencePath); })).ConfigureAwait(false); }
public async Task PassesEachPatcherToRunComponent( IGroupRun groupRun, PatcherPrepBundle[] patchers, CancellationToken cancellation, FilePath?sourcePath, RunParameters runParameters, RunSomePatchers sut) { await sut.Run( groupRun, patchers, cancellation, sourcePath, runParameters); await sut.RunAPatcher.ReceivedWithAnyArgs().Run(
public void Write( IGroupRun groupRun, IReadOnlySet <ModKey> blackListedMods) { var loadOrderList = LoadOrderForRunProvider.Get(groupRun.ModKey, blackListedMods); Printer.Print(loadOrderList); var loadOrderPath = LoadOrderPathProvider.PathFor(groupRun); _fileSystem.Directory.CreateDirectory(loadOrderPath.Directory); LoadOrderWriter.Write( loadOrderPath, loadOrderList, removeImplicitMods: true); }
public async Task CancelledReturnsNull( IGroupRun groupRun, IPatcherRun patcher, CancellationToken cancelled, FilePath?sourcePath, RunParameters runParameters, RunAPatcher sut) { (await sut.Run( groupRun, new PatcherPrepBundle( patcher, Task.FromResult <Exception?>(new NotImplementedException())), cancelled, sourcePath, runParameters)) .Should().BeNull(); }
public async Task <bool> Run( IGroupRun groupRun, CancellationToken cancellation, DirectoryPath outputDir, RunParameters runParameters, FilePath?sourcePath = null) { _logger.Information("================= Starting Group {Group} Run =================", groupRun.ModKey.Name); if (groupRun.BlacklistedMods.Count > 0) { _logger.Information("Blacklisting mods:"); foreach (var mod in groupRun.BlacklistedMods.OrderBy(x => x.Name)) { _logger.Information(" {Mod}", mod); } } await GroupRunPreparer.Prepare( groupRun, groupRun.BlacklistedMods, runParameters.PersistenceMode, runParameters.PersistencePath).ConfigureAwait(false); var finalPath = await RunSomePatchers.Run( groupRun, groupRun.Patchers, cancellation, sourcePath, runParameters).ConfigureAwait(false); if (finalPath == null) { return(false); } cancellation.ThrowIfCancellationRequested(); MoveFinalResults.Move(finalPath.Value, outputDir); return(true); }
public RunSynthesisPatcher GetArgs( IGroupRun groupRun, IPatcherRun patcher, FilePath?sourcePath, RunParameters runParameters) { var fileName = PatcherNameSanitizer.Sanitize(patcher.Name); var nextPath = new FilePath( Path.Combine(ProfileDirectories.WorkingDirectory, groupRun.ModKey.Name, $"{patcher.Index} - {fileName}", groupRun.ModKey.FileName)); return(new RunSynthesisPatcher() { SourcePath = sourcePath, OutputPath = nextPath, DataFolderPath = DataDirectoryProvider.Path, GameRelease = ReleaseContext.Release, Localize = runParameters.Localize, TargetLanguage = runParameters.TargetLanguage.ToString(), LoadOrderFilePath = RunLoadOrderPathProvider.PathFor(groupRun), PersistencePath = runParameters.PersistenceMode == PersistenceMode.None ? null : runParameters.PersistencePath, PatcherName = fileName, ModKey = groupRun.ModKey.FileName, }); }
public void RemovesImplicitMods( IGroupRun groupRun, GroupRunLoadOrderPreparer sut) { sut.Write(groupRun, default !);
public FilePath PathFor(IGroupRun groupRun) { return(System.IO.Path.Combine(ProfileDirectories.WorkingDirectory, groupRun.ModKey.Name, "Plugins.txt")); }