Skip to content

Commit 218dcc6

Browse files
committed
tests/CSharpLanguageServer.Tests/Tooling.fs: fix race in prepareTempTestDirFrom
also, fail early when test data dir is missing
1 parent eebd3ff commit 218dcc6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/CSharpLanguageServer.Tests/Tooling.fs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ let prepareTempTestDirFrom (sourceTestDir: DirectoryInfo) : string =
544544
failwith (sprintf "%s does not exist!" (sourceTestDir.ToString()))
545545

546546
let tempDir =
547-
Path.Combine(Path.GetTempPath(), "CSharpLanguageServer.Tests." + System.DateTime.Now.Ticks.ToString())
547+
Path.Combine(Path.GetTempPath(), sprintf "CSharpLanguageServer.Tests.%s" (Guid.NewGuid() |> string))
548548

549549
// a hack for macOS
550550
let tempTestDirName =
@@ -865,10 +865,13 @@ let setupServerClient (clientProfile: ClientProfile) (testDataDirName: string) =
865865
let testAssemblyLocationDir =
866866
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
867867

868-
let actualTestDataDirName =
868+
let actualTestDataDir =
869869
DirectoryInfo(Path.Combine(testAssemblyLocationDir, "..", "..", "..", testDataDirName))
870870

871-
new ClientController(clientActor, actualTestDataDirName)
871+
if not actualTestDataDir.Exists then
872+
failwithf "setupServerClient: no such test data dir \"%s\"" actualTestDataDir.FullName
873+
874+
new ClientController(clientActor, actualTestDataDir)
872875

873876

874877
module TextEdit =

0 commit comments

Comments
 (0)