public static async IAsyncEnumerable <Test> GetTests(TestingSettings settings) { var oblivPassthrough = new Target() { Do = true, Path = "Oblivion.esm" }; var passthroughTests = settings.PassthroughSettings?.HasAnyToRun ?? false; foreach (var targetGroup in settings.TargetGroups) { if (!targetGroup.Do) { continue; } foreach (var target in targetGroup.Targets) { if (!target.Do) { continue; } PassthroughTest passthroughTest = PassthroughTest.Factory(settings, targetGroup, target); if (passthroughTests) { yield return(passthroughTest.BinaryPassthroughTest()); } if (settings.PassthroughSettings?.TestImport ?? false) { yield return(passthroughTest.TestImport()); } if (settings.TestEquality) { yield return(passthroughTest.TestEquality()); } if (settings.TestPex) { yield return(passthroughTest.TestPex()); } } } if (settings.TestGroupMasks) { yield return(RunTest("GroupMask Import", (o) => OtherTests.OblivionESM_GroupMask_Import(settings, oblivPassthrough))); yield return(RunTest("GroupMask Export", (o) => OtherTests.OblivionESM_GroupMask_Export(settings, oblivPassthrough))); } if (settings.TestFlattenedMod) { yield return(RunTest("Flatten Mod", (o) => FlattenedMod_Tests.Oblivion_FlattenMod(settings))); } if (settings.TestBenchmarks) { Mutagen.Bethesda.Tests.Benchmarks.Benchmarks.Run(); } if (settings.TestRecordEnumerables) { yield return(RunTest("Record Enumerations", (o) => OtherTests.RecordEnumerations(settings, oblivPassthrough))); } }
public Test BinaryPassthroughTest() { (TempFolder tmp, Test processedTest) = SetupProcessedFiles(); var outputPath = Path.Combine(tmp.Dir.Path, $"{this.Nickname}_NormalExport"); var processedPath = ProcessedPath(tmp); var orderedPath = Path.Combine(tmp.Dir.Path, $"{this.Nickname}_Ordered"); var binaryOverlayPath = Path.Combine(tmp.Dir.Path, $"{this.Nickname}_BinaryOverlay"); var copyInPath = Path.Combine(tmp.Dir.Path, $"{this.Nickname}_CopyIn"); var strsProcessedPath = Path.Combine(tmp.Dir.Path, "Strings/Processed"); var masterRefs = MasterReferenceReader.FromPath(new ModPath(ModKey, this.FilePath.Path), GameRelease); // Do normal if (Settings.TestNormal) { var strsWriteDir = Path.Combine(tmp.Dir.Path, "Strings", $"{this.Nickname}_Normal"); bool doStrings = false; var passthrough = TestBattery.RunTest( "Binary Normal Passthrough", this.GameRelease, this.Target, parallel: Settings.Parallel, toDo: async(o) => { o.OnNext(FilePath.ToString()); var mod = await ImportBinary(this.FilePath.Path); doStrings = mod.UsingLocalization; foreach (var record in mod.EnumerateMajorRecords()) { record.IsCompressed = false; } var writeParam = GetWriteParam(masterRefs, doStrings ? new StringsWriter(mod.ModKey, strsWriteDir) : null); mod.WriteToBinary(outputPath, writeParam); GC.Collect(); using var stream = new MutagenBinaryReadStream(processedPath, this.GameRelease); writeParam.StringsWriter?.Dispose(); AssertFilesEqual( stream, outputPath, amountToReport: 15); }); processedTest.AddAsChild(passthrough); if (doStrings) { foreach (var item in AssertStringsEqual( "Binary Normal", strsProcessedPath, strsWriteDir)) { passthrough.AddAsChild(item); } } } if (Settings.TestBinaryOverlay) { var strsWriteDir = Path.Combine(tmp.Dir.Path, "Strings", $"{this.Nickname}_Overlay"); bool doStrings = false; var passthrough = TestBattery.RunTest( "Binary Overlay Passthrough", this.GameRelease, this.Target, parallel: Settings.Parallel, toDo: async(o) => { o.OnNext(FilePath.ToString()); using (var wrapper = await ImportBinaryOverlay(this.FilePath.Path)) { doStrings = wrapper.UsingLocalization; var writeParam = GetWriteParam(masterRefs, doStrings ? new StringsWriter(wrapper.ModKey, strsWriteDir) : null); wrapper.WriteToBinary(binaryOverlayPath, writeParam); writeParam.StringsWriter?.Dispose(); } using var stream = new MutagenBinaryReadStream(processedPath, this.GameRelease); PassthroughTest.AssertFilesEqual( stream, binaryOverlayPath, amountToReport: 15); }); processedTest.AddAsChild(passthrough); if (doStrings) { foreach (var item in AssertStringsEqual( "Binary Overlay", strsProcessedPath, strsWriteDir)) { passthrough.AddAsChild(item); } } } if (Settings.TestCopyIn) { var strsWriteDir = Path.Combine(tmp.Dir.Path, "Strings", $"{this.Nickname}_CopyIn"); bool doStrings = false; var passthrough = TestBattery.RunTest( "Copy In Passthrough", this.GameRelease, this.Target, parallel: Settings.Parallel, toDo: async(o) => { o.OnNext(FilePath.ToString()); var copyIn = await ImportCopyIn(this.FilePath.Path); doStrings = copyIn.UsingLocalization; var writeParam = GetWriteParam(masterRefs, doStrings ? new StringsWriter(copyIn.ModKey, strsWriteDir) : null); copyIn.WriteToBinary(copyInPath, writeParam); writeParam.StringsWriter?.Dispose(); using var stream = new MutagenBinaryReadStream(processedPath, this.GameRelease); PassthroughTest.AssertFilesEqual( stream, copyInPath, amountToReport: 15); }); processedTest.AddAsChild(passthrough); if (doStrings) { foreach (var item in AssertStringsEqual( "Copy In", strsProcessedPath, strsWriteDir)) { passthrough.AddAsChild(item); } } } return(processedTest); }