From ccc9c7b50863ea2835527280da36e71d30143ead Mon Sep 17 00:00:00 2001 From: Eugene Auduchinok Date: Fri, 13 Dec 2024 19:10:04 +0100 Subject: [PATCH] Tests: fix setting the original shim in the FileSystem shim tests --- .../FSharp.Compiler.Service.Tests/FileSystemTests.fs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/FSharp.Compiler.Service.Tests/FileSystemTests.fs b/tests/FSharp.Compiler.Service.Tests/FileSystemTests.fs index ff62594067..514b1e2216 100644 --- a/tests/FSharp.Compiler.Service.Tests/FileSystemTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/FileSystemTests.fs @@ -38,17 +38,16 @@ type internal MyFileSystem() = | _ -> base.OpenFileForReadShim(filePath, useMemoryMappedFile, shouldShadowCopy) override _.FileExistsShim(fileName) = MyFileSystem.FilesCache.ContainsKey(fileName) || base.FileExistsShim(fileName) -let UseMyFileSystem() = - let myFileSystem = MyFileSystem() - FileSystemAutoOpens.FileSystem <- myFileSystem - { new IDisposable with member x.Dispose() = FileSystemAutoOpens.FileSystem <- myFileSystem } +let useFileSystemShim (shim: IFileSystem) = + let originalShim = FileSystem + FileSystem <- shim + { new IDisposable with member x.Dispose() = FileSystem <- originalShim } // .NET Core SKIPPED: need to check if these tests can be enabled for .NET Core testing of FSharp.Compiler.Service" [] let ``FileSystem compilation test``() = if Environment.OSVersion.Platform = PlatformID.Win32NT then // file references only valid on Windows - use myFileSystem = UseMyFileSystem() - let programFilesx86Folder = Environment.GetEnvironmentVariable("PROGRAMFILES(X86)") + use myFileSystem = useFileSystemShim (MyFileSystem()) let projectOptions = let allFlags =