From 3ec9e24846a5711a83cc1ff148b5e4e8cafd2cf1 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 9 Sep 2026 16:49:35 +0000 Subject: [PATCH] fix managed tests on linux Authored by Claude (claude-opus-5) Util.TestDataDir was windows-only in three ways: CodeBase.Replace("file:///","") drops the leading slash of a unix path, the candidate paths used literal backslash separators (ordinary filename chars on unix, so GetFullPath never resolved them), and they were combined against the dll file path rather than its directory. Replaced with an upward search for TestData starting at the assembly's directory, which works under both the VS and dotnet output layouts. TestMesh and TestMeshTransform also opened "monolithref.mmobj"; the file on disk is MonolithRef.mmobj, which only matters on a case-sensitive filesystem. All 20 tests now pass under mono on linux. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_0148v6m1593drJ3ZVBJxZzsU --- CLAUDE.md | 6 ++---- Test.MMManaged/TestMesh.fs | 2 +- Test.MMManaged/TestMeshTransform.fs | 2 +- Test.MMManaged/Util.fs | 32 +++++++++++++---------------- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 2e14c3f7..85db8b1a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -71,10 +71,8 @@ cp FSharp.Core.4.4.3.0/FSharp.Core.dll Debug/ cd Debug && mono /path/to/nunit3-console.exe Test.MMManaged.dll ``` -Known: 6 tests fail on linux regardless of the change under test (TestMesh, TestMeshTransform -x2, TestModDB, TestModDBInterop, TestYaml). They all die in `Util.TestDataDir`'s static -constructor, which searches windows-style relative paths for TestData. Compare against a -master build before assuming a failure is yours. +All tests pass on linux. `State.reloadSnapshotProfiles` logs an error about a missing +`TestData/SnapshotProfiles` dir during the interop test; that is expected and not a failure. ## Interop notes diff --git a/Test.MMManaged/TestMesh.fs b/Test.MMManaged/TestMesh.fs index 23be2892..339c5973 100644 --- a/Test.MMManaged/TestMesh.fs +++ b/Test.MMManaged/TestMesh.fs @@ -7,7 +7,7 @@ open ModelMod open ModelMod.CoreTypes let monolith = - let mpath = Path.Combine(Util.TestDataDir,"monolithref.mmobj") + let mpath = Path.Combine(Util.TestDataDir,"MonolithRef.mmobj") MeshUtil.readFrom(mpath,CoreTypes.GPUReplacement,CoreTypes.DefaultReadFlags) open MonoGameHelpers diff --git a/Test.MMManaged/TestMeshTransform.fs b/Test.MMManaged/TestMeshTransform.fs index 6b795f88..ffcbcba0 100644 --- a/Test.MMManaged/TestMeshTransform.fs +++ b/Test.MMManaged/TestMeshTransform.fs @@ -10,7 +10,7 @@ open ModelMod.CoreTypes let vecEq = Util.veqEqEpsilon 0.000001f let monolith = - let mpath = Path.Combine(Util.TestDataDir,"monolithref.mmobj") + let mpath = Path.Combine(Util.TestDataDir,"MonolithRef.mmobj") MeshUtil.readFrom(mpath,CoreTypes.GPUReplacement,CoreTypes.DefaultReadFlags) [] diff --git a/Test.MMManaged/Util.fs b/Test.MMManaged/Util.fs index 99c4043b..2758e3ea 100644 --- a/Test.MMManaged/Util.fs +++ b/Test.MMManaged/Util.fs @@ -12,22 +12,18 @@ let veqEqEpsilon (ep:float32) (v1:Vec3F) (v2:Vec3F) = let dz = Math.Abs(v1.Z - v2.Z) dx < ep && dy < ep && dz < ep -let TestDataDir = - let asmPath = Assembly.GetExecutingAssembly().CodeBase.Replace("file:///","") - - let paths = [ @"..\..\TestData"; @"..\TestData"; "@\..\..\..\..\..\TestData" ] - - let paths = paths |> List.map (fun p -> Path.GetFullPath(Path.Combine(asmPath,p))) - - let found = - paths |> List.tryPick (fun p -> - if Directory.Exists p then - Some(p) - else - None - ) - - match found with - | None -> failwithf "Failed to locate test data directory, searched: %A" paths +let TestDataDir = + // walk up from the assembly dir looking for TestData; the output layout differs between the + // VS and dotnet builds. avoid literal path separators, they aren't portable. + let asmDir = Path.GetDirectoryName(Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) + + let rec search (dir:DirectoryInfo) levels = + if isNull (box dir) || levels = 0 then + None + else + let cand = Path.Combine(dir.FullName, "TestData") + if Directory.Exists cand then Some(cand) else search dir.Parent (levels-1) + + match search (DirectoryInfo(asmDir)) 6 with + | None -> failwithf "Failed to locate test data directory at or above: %s" asmDir | Some path -> path - \ No newline at end of file