Skip to content

Tests: fix setting the original shim in the FileSystem shim tests #18142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions tests/FSharp.Compiler.Service.Tests/FileSystemTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
[<FactForDESKTOP>]
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 =
Expand Down
Loading