Skip to content

Commit 2058c97

Browse files
committed
fix tests on linux
1 parent b24f6ad commit 2058c97

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/PetroglyphTools/PG.StarWarsGame.Engine.Test/EngineRepositoryTestBase.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,4 +334,13 @@ private static string JitterSeparators(string path, Random random)
334334
}
335335
return new string(chars);
336336
}
337+
338+
/// <summary>
339+
/// Returns the last segment of an engine path, treating both '/' and '\' as separators.
340+
/// </summary>
341+
// Engine paths always use '\'; System.IO.Path.GetFileName only splits on '\' on Windows.
342+
protected static string EngineFileName(string path)
343+
{
344+
return path.Substring(path.LastIndexOfAny(['/', '\\']) + 1);
345+
}
337346
}

src/PetroglyphTools/PG.StarWarsGame.Engine.Test/IO/Foc/FocGameRepositoryTests.Initialization.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.IO;
21
using System.Linq;
32
using PG.StarWarsGame.Engine.ErrorReporting;
43
using Xunit;
@@ -124,7 +123,7 @@ public void ErrorReporter_MissingEawPatches_AssertsFileNotFound_WhenFallbackConf
124123

125124
var names = reporter.Asserts
126125
.Where(a => a.Kind == EngineAssertKind.FileNotFound)
127-
.Select(a => Path.GetFileName(a.Value))
126+
.Select(a => EngineFileName(a.Value))
128127
.ToList();
129128
// 6 missing: Patch / Patch2 / 64Patch in both the fallback and the FoC dir.
130129
Assert.Equal(2, names.Count(v => v == "Patch.meg"));

src/PetroglyphTools/PG.StarWarsGame.Engine.Test/IO/GameRepositoryTests.Initialization.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.IO;
21
using System.Linq;
32
using PG.StarWarsGame.Engine.ErrorReporting;
43
using Xunit;
@@ -141,7 +140,7 @@ public void ErrorReporter_MissingPatchMegs_AssertsFileNotFound()
141140

142141
var fileNotFoundNames = reporter.Asserts
143142
.Where(a => a.Kind == EngineAssertKind.FileNotFound)
144-
.Select(a => Path.GetFileName(a.Value))
143+
.Select(a => EngineFileName(a.Value))
145144
.ToList();
146145
Assert.Contains("Patch.meg", fileNotFoundNames);
147146
Assert.Contains("Patch2.meg", fileNotFoundNames);
@@ -165,7 +164,7 @@ public void ErrorReporter_AllPatchesPresent_NoFileNotFoundForPatches()
165164

166165
var fileNotFoundNames = reporter.Asserts
167166
.Where(a => a.Kind == EngineAssertKind.FileNotFound)
168-
.Select(a => Path.GetFileName(a.Value))
167+
.Select(a => EngineFileName(a.Value))
169168
.ToList();
170169
Assert.DoesNotContain("Patch.meg", fileNotFoundNames);
171170
Assert.DoesNotContain("Patch2.meg", fileNotFoundNames);
@@ -189,7 +188,7 @@ public void ErrorReporter_MegaFilesXmlReferencesMissingMeg_AssertsFileNotFound()
189188
_ = CreateRepository(repo, reporter);
190189

191190
Assert.Contains(reporter.Asserts, a =>
192-
a.Kind == EngineAssertKind.FileNotFound && Path.GetFileName(a.Value) == "DoesNotExist.meg");
191+
a.Kind == EngineAssertKind.FileNotFound && EngineFileName(a.Value) == "DoesNotExist.meg");
193192
}
194193

195194
[Fact]
@@ -210,6 +209,6 @@ public void ErrorReporter_MissingSpeechMeg_DoesNotAssert()
210209
_ = CreateRepository(repo, reporter);
211210

212211
Assert.DoesNotContain(reporter.Asserts, a =>
213-
a.Kind == EngineAssertKind.FileNotFound && Path.GetFileName(a.Value) == "EnglishSpeech.meg");
212+
a.Kind == EngineAssertKind.FileNotFound && EngineFileName(a.Value) == "EnglishSpeech.meg");
214213
}
215214
}

0 commit comments

Comments
 (0)