From 671a2499fb2db3e36e3e9757fb18f1dd4eceaf06 Mon Sep 17 00:00:00 2001 From: Bradley Gannon Date: Fri, 9 Jan 2026 21:52:46 -0500 Subject: [PATCH 1/3] Add a hardcoded list of scenario file names to test --- EngineTests/GameData/SaveTest.cs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/EngineTests/GameData/SaveTest.cs b/EngineTests/GameData/SaveTest.cs index deaec714..1e852318 100644 --- a/EngineTests/GameData/SaveTest.cs +++ b/EngineTests/GameData/SaveTest.cs @@ -287,15 +287,22 @@ public void LoadAllConquestScenarios() { private void CheckScenariosInCiv3Subfolder(string subfolder, bool runOneTurn) { string conquests = Path.Join(Civ3Location.GetCiv3Path(), subfolder); DirectoryInfo directoryInfo = new DirectoryInfo(conquests); - IEnumerable saveFiles = directoryInfo.EnumerateFiles().Where(fi => { - // currently only test 1 Mesopotamia.biq -> 9 WWII in the Pacific.biq: - int prefix = fi.Name[0]; - if (prefix == '7') { - // skip 7 Sengoku - Sword of the Shogun.biq for now because biq parsing fails - return false; - } - return fi.Extension.EndsWith(".biq", true, null) && char.IsAsciiDigit(fi.Name[0]); - }); + // skip all scenarios whose file names aren't explicitly listed here + string[] scenarioNamesToTest = { + "1 Mesopotamia.biq", + "2 Rise of Rome.biq", + "3 Fall of Rome.biq", + "4 Middle Ages.biq", + "5 Mesoamerica.biq", + "6 Age of Discovery.biq", + // skip for now because BIQ parsing fails + // "7 Sengoku - Sword of the Shogun.biq", + "8 Napoleonic Europe.biq", + "9 WWII in the Pacific.biq", + }; + IEnumerable saveFiles = directoryInfo.EnumerateFiles().Where(fi => + scenarioNamesToTest.Contains(fi.Name) + ); foreach (FileInfo saveFileInfo in saveFiles) { string name = saveFileInfo.Name; SaveGame game = null; From 6074be49879a1687179d343bdc1c58ccf570ef86 Mon Sep 17 00:00:00 2001 From: Bradley Gannon Date: Sat, 10 Jan 2026 22:27:35 -0500 Subject: [PATCH 2/3] Add multiplayer scenarios to SaveTest --- EngineTests/GameData/SaveTest.cs | 39 +++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/EngineTests/GameData/SaveTest.cs b/EngineTests/GameData/SaveTest.cs index 1e852318..65c98f67 100644 --- a/EngineTests/GameData/SaveTest.cs +++ b/EngineTests/GameData/SaveTest.cs @@ -278,17 +278,7 @@ public void LoadAllConquestScenarios() { string is_on_github = System.Environment.GetEnvironmentVariable("CI"); if (is_on_github != null) { return; } - // Only bother running one turn of the newer scenarios, just to keep the - // tests faster. - CheckScenariosInCiv3Subfolder("Conquests/Conquests", runOneTurn: true); - CheckScenariosInCiv3Subfolder("Conquests/Scenarios", runOneTurn: false); - } - - private void CheckScenariosInCiv3Subfolder(string subfolder, bool runOneTurn) { - string conquests = Path.Join(Civ3Location.GetCiv3Path(), subfolder); - DirectoryInfo directoryInfo = new DirectoryInfo(conquests); - // skip all scenarios whose file names aren't explicitly listed here - string[] scenarioNamesToTest = { + string[] singleplayerScenarios = { "1 Mesopotamia.biq", "2 Rise of Rome.biq", "3 Fall of Rome.biq", @@ -300,8 +290,31 @@ private void CheckScenariosInCiv3Subfolder(string subfolder, bool runOneTurn) { "8 Napoleonic Europe.biq", "9 WWII in the Pacific.biq", }; - IEnumerable saveFiles = directoryInfo.EnumerateFiles().Where(fi => - scenarioNamesToTest.Contains(fi.Name) + string[] multiplayerScenarios = { + "1 MP Mesopotamia.biq", + "2 MP Rise of Rome.biq", + "3 MP Fall of Rome.biq", + "4 MP Middle Ages.biq", + "5 MP Mesoamerica.biq", + "6 MP Age of Discovery.biq", + // skip for now because BIQ parsing fails + // "7 MP Sengoku - Sword of the Shogun.biq", + "8 MP Napoleonic Europe.biq", + "9 MP WWII in the Pacific.biq", + }; + // Only bother running one turn of the newer scenarios, just to keep the + // tests faster. + CheckScenariosInCiv3Subfolder("Conquests/Conquests", singleplayerScenarios, runOneTurn: true); + CheckScenariosInCiv3Subfolder("Conquests/Scenarios", multiplayerScenarios, runOneTurn: false); + } + + private void CheckScenariosInCiv3Subfolder(string subfolder, string[] scenarioNamesToTest, bool runOneTurn) { + string conquests = Path.Join(Civ3Location.GetCiv3Path(), subfolder); + DirectoryInfo directoryInfo = new DirectoryInfo(conquests); + IEnumerable saveFiles = directoryInfo.EnumerateFiles().Where(fi => scenarioNamesToTest.Contains(fi.Name)); + Assert.True( + scenarioNamesToTest.Count() == saveFiles.Count(), + $"Expected {scenarioNamesToTest.Count()} files but got {saveFiles.Count()}" ); foreach (FileInfo saveFileInfo in saveFiles) { string name = saveFileInfo.Name; From a8787e0a484849707dc15d2d8e63a881070ea059 Mon Sep 17 00:00:00 2001 From: Bradley Gannon Date: Sat, 10 Jan 2026 22:34:16 -0500 Subject: [PATCH 3/3] Add basename parameter to CheckScenariosInCiv3Subfolder --- EngineTests/GameData/SaveTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/EngineTests/GameData/SaveTest.cs b/EngineTests/GameData/SaveTest.cs index 65c98f67..2f4fdeb5 100644 --- a/EngineTests/GameData/SaveTest.cs +++ b/EngineTests/GameData/SaveTest.cs @@ -304,11 +304,11 @@ public void LoadAllConquestScenarios() { }; // Only bother running one turn of the newer scenarios, just to keep the // tests faster. - CheckScenariosInCiv3Subfolder("Conquests/Conquests", singleplayerScenarios, runOneTurn: true); - CheckScenariosInCiv3Subfolder("Conquests/Scenarios", multiplayerScenarios, runOneTurn: false); + CheckScenariosInCiv3Subfolder("Conquests/Conquests", singleplayerScenarios, runOneTurn: true, "singleplayer"); + CheckScenariosInCiv3Subfolder("Conquests/Scenarios", multiplayerScenarios, runOneTurn: false, "multiplayer"); } - private void CheckScenariosInCiv3Subfolder(string subfolder, string[] scenarioNamesToTest, bool runOneTurn) { + private void CheckScenariosInCiv3Subfolder(string subfolder, string[] scenarioNamesToTest, bool runOneTurn, string basename) { string conquests = Path.Join(Civ3Location.GetCiv3Path(), subfolder); DirectoryInfo directoryInfo = new DirectoryInfo(conquests); IEnumerable saveFiles = directoryInfo.EnumerateFiles().Where(fi => scenarioNamesToTest.Contains(fi.Name)); @@ -387,7 +387,7 @@ private void CheckScenariosInCiv3Subfolder(string subfolder, string[] scenarioNa } } - game.Save(Path.Combine(testDirectory, "data", "output", $"conquest_{name[0]}.json")); + game.Save(Path.Combine(testDirectory, "data", "output", $"{basename}_{name[0]}.json")); // Finally, ensure we can run the first turn of the scenario. if (runOneTurn) {