From 18a72010044460d1b6db88d65a7029497e092b00 Mon Sep 17 00:00:00 2001
From: YoshiRulz <OSSYoshiRulz@gmail.com>
Date: Sat, 13 Aug 2022 22:04:54 +1000
Subject: [PATCH] Fix building testroms project

fixes b8d5dd899
also addressed code style warnings and fixed a typo in GambatteSuite.BeforeAll
note the last acid suite fail is gone after a recent SameBoy update,
unfortunately the same update added a bunch of fails in the mealybug suite,
though the suite itself needs updating too
---
 .../GambatteSuite.cs                                       | 2 +-
 src/BizHawk.Tests.Testroms.GB.GambatteSuite/readme.md      | 1 +
 src/BizHawk.Tests.Testroms.GB/GB_GBC/AcidTestroms.cs       | 6 +++---
 src/BizHawk.Tests.Testroms.GB/GB_GBC/GBHelper.cs           | 4 ++--
 src/BizHawk.Tests.Testroms.GB/TestUtils.cs                 | 7 +++++--
 src/BizHawk.Tests.Testroms.GB/readme.md                    | 3 ++-
 6 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.cs b/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.cs
index a830ae8de6..eee510a828 100644
--- a/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.cs
+++ b/src/BizHawk.Tests.Testroms.GB.GambatteSuite/GambatteSuite.cs
@@ -82,7 +82,7 @@ namespace BizHawk.Tests.Testroms.GB.GambatteSuite
 		[ClassInitialize]
 		public static void BeforeAll(TestContext ctx)
 		{
-			if (!(GambatteHexStrTestCase.KnownFailures.IsSortedAsc() && GambatteHexStrTestCase.KnownFailures.IsSortedAsc())) throw new Exception(SUITE_ID + " known-failing testcase list must be sorted");
+			if (!(GambatteHexStrTestCase.KnownFailures.IsSortedAsc() && GambatteRefImageTestCase.KnownFailures.IsSortedAsc())) throw new Exception(SUITE_ID + " known-failing testcase list must be sorted");
 			TestUtils.PrepareDBAndOutput(SUITE_ID);
 		}
 
diff --git a/src/BizHawk.Tests.Testroms.GB.GambatteSuite/readme.md b/src/BizHawk.Tests.Testroms.GB.GambatteSuite/readme.md
index ec18083048..893ba77fd6 100644
--- a/src/BizHawk.Tests.Testroms.GB.GambatteSuite/readme.md
+++ b/src/BizHawk.Tests.Testroms.GB.GambatteSuite/readme.md
@@ -13,3 +13,4 @@ Note that firmware does not need to be copied here. They are taken from `../BizH
 > This test suite is huge and takes a **really long time** to run. Like several hours.
 
 Summary of `BIZHAWKTEST_RUN_KNOWN_FAILURES=1 ./run_tests_release.sh` should read 13681 passed / 1304 skipped / 0 failed.
+TODO update these numbers
diff --git a/src/BizHawk.Tests.Testroms.GB/GB_GBC/AcidTestroms.cs b/src/BizHawk.Tests.Testroms.GB/GB_GBC/AcidTestroms.cs
index 2b9a9ca661..58d1994e98 100644
--- a/src/BizHawk.Tests.Testroms.GB/GB_GBC/AcidTestroms.cs
+++ b/src/BizHawk.Tests.Testroms.GB/GB_GBC/AcidTestroms.cs
@@ -21,7 +21,7 @@ namespace BizHawk.Tests.Testroms.GB
 				"cgb-acid-hell" => "res.cgb_acid_hell_artifact.reference.png",
 				"cgb-acid2" => "res.cgb_acid2_artifact.reference.png",
 				"dmg-acid2" => $"res.dmg_acid2_artifact.reference-{(Setup.Variant.IsColour() ? "cgb" : "dmg")}.png",
-				_ => throw new Exception()
+				_ => throw new InvalidOperationException()
 			};
 
 			public readonly string RomEmbedPath => TestName switch
@@ -29,7 +29,7 @@ namespace BizHawk.Tests.Testroms.GB
 				"cgb-acid-hell" => "res.cgb_acid_hell_artifact.cgb-acid-hell.gbc",
 				"cgb-acid2" => "res.cgb_acid2_artifact.cgb-acid2.gbc",
 				"dmg-acid2" => "res.dmg_acid2_artifact.dmg-acid2.gb",
-				_ => throw new Exception()
+				_ => throw new InvalidOperationException()
 			};
 
 			public readonly CoreSetup Setup;
@@ -78,7 +78,7 @@ namespace BizHawk.Tests.Testroms.GB
 
 		private static readonly IReadOnlyCollection<string> KnownFailures = new[]
 		{
-			"cgb-acid2 on CGB_C in SameBoy (no BIOS)",
+			"", // none \o/
 		};
 
 		[ClassCleanup]
diff --git a/src/BizHawk.Tests.Testroms.GB/GB_GBC/GBHelper.cs b/src/BizHawk.Tests.Testroms.GB/GB_GBC/GBHelper.cs
index f8b15c1b4b..b2bccfbcd8 100644
--- a/src/BizHawk.Tests.Testroms.GB/GB_GBC/GBHelper.cs
+++ b/src/BizHawk.Tests.Testroms.GB/GB_GBC/GBHelper.cs
@@ -155,7 +155,7 @@ namespace BizHawk.Tests.Testroms.GB
 				ConsoleVariant.CGB_C => biosAvailable ? SameBoySyncSettings_GBC_C_USEBIOS : SameBoySyncSettings_GBC_C_NOBIOS,
 				ConsoleVariant.CGB_D => biosAvailable ? SameBoySyncSettings_GBC_D_USEBIOS : SameBoySyncSettings_GBC_D_NOBIOS,
 				ConsoleVariant.DMG or ConsoleVariant.DMG_B => biosAvailable ? SameBoySyncSettings_GB_USEBIOS : SameBoySyncSettings_GB_NOBIOS,
-				_ => throw new Exception()
+				_ => throw new InvalidOperationException()
 			};
 
 		public static DummyFrontend.ClassInitCallbackDelegate InitGBCore(CoreSetup setup, string romFilename, byte[] rom)
@@ -168,7 +168,7 @@ namespace BizHawk.Tests.Testroms.GB
 					CoreNames.Gambatte => new Gameboy(coreComm, game, rom, GambatteSettings, GetGambatteSyncSettings(setup.Variant, setup.UseBIOS), deterministic: true),
 					CoreNames.GbHawk => new GBHawk(coreComm, game, rom, new(), GetGBHawkSyncSettings(setup.Variant)),
 					CoreNames.Sameboy => new Sameboy(coreComm, game, rom, SameBoySettings, GetSameBoySyncSettings(setup.Variant, setup.UseBIOS), deterministic: true),
-					_ => throw new Exception()
+					_ => throw new InvalidOperationException("unknown GB core")
 				};
 				var biosWaitDuration = setup.UseBIOS || setup.CoreName is CoreNames.Sameboy
 					? setup.Variant.IsColour()
diff --git a/src/BizHawk.Tests.Testroms.GB/TestUtils.cs b/src/BizHawk.Tests.Testroms.GB/TestUtils.cs
index 549ebba4cc..a7b1f64a66 100644
--- a/src/BizHawk.Tests.Testroms.GB/TestUtils.cs
+++ b/src/BizHawk.Tests.Testroms.GB/TestUtils.cs
@@ -31,8 +31,11 @@ namespace BizHawk.Tests.Testroms.GB
 			if (_initialised.Contains(suiteID)) return;
 			if (_initialised.Count == 0)
 			{
-				Database.InitializeDatabase(Path.Combine(".", "gamedb", "gamedb.txt"), silent: true); // runs in the background; required for Database.GetGameInfo calls
-				if (!OSTailoredCode.IsUnixHost) SetDllDirectory(Path.Combine("..", "output", "dll")); // on Linux, this is done by the shell script with the env. var. LD_LIBRARY_PATH
+				Database.InitializeDatabase( // runs in the background; required for Database.GetGameInfo calls
+					bundledRoot: Path.Combine(".", "gamedb"),
+					userRoot: Path.Combine(".", "gamedb"),
+					silent: true);
+				if (!OSTailoredCode.IsUnixHost) _ = SetDllDirectory(Path.Combine("..", "output", "dll")); // on Linux, this is done by the shell script with the env. var. LD_LIBRARY_PATH
 			}
 			_initialised.Add(suiteID);
 			DirectoryInfo di = new(suiteID);
diff --git a/src/BizHawk.Tests.Testroms.GB/readme.md b/src/BizHawk.Tests.Testroms.GB/readme.md
index 84484ecfc9..364b5e3722 100644
--- a/src/BizHawk.Tests.Testroms.GB/readme.md
+++ b/src/BizHawk.Tests.Testroms.GB/readme.md
@@ -18,7 +18,7 @@ res
 └─ rtc3test_artifact
 ```
 
-As with EmuHawk, the target framework and configuration for all the BizHawk project deps is dictated by this project. That means .NET Standard 2.0, or .NET 5 if the project supports it.
+As with EmuHawk, the target framework and configuration for all the BizHawk project deps is dictated by this project. That means .NET Standard 2.0, or .NET 6 if the project supports it.
 To build and run the tests in `Release` configuration (or `Debug` if you need that for some reason):
 - On Linux, run `run_tests_release.sh` or `run_tests_debug.sh`.
 - On Windows, pass `-c Release` to `dotnet test` (must `cd` to this project). Omitting `-c` will use `Debug`.
@@ -73,3 +73,4 @@ dotnet test -c Release -l "console;verbosity=detailed"
 ```
 
 Summary of `BIZHAWKTEST_RUN_KNOWN_FAILURES=1 ./run_tests_release.sh` should read 166 passed / 174 skipped / 0 failed.
+TODO update these numbers