@@ -29,7 +29,7 @@ tests :: TestTree
29
29
tests = testGroup " watched files"
30
30
[ testGroup " Subscriptions"
31
31
[ testWithDummyPluginEmpty' " workspace files" $ \ sessionDir -> do
32
- liftIO $ writeFile (sessionDir </> " hie.yaml" ) " cradle: {direct: {arguments: [\" -isrc\" , \" A\" , \" WatchedFilesMissingModule\" ]}}"
32
+ liftIO $ atomicFileWriteString (sessionDir </> " hie.yaml" ) " cradle: {direct: {arguments: [\" -isrc\" , \" A\" , \" WatchedFilesMissingModule\" ]}}"
33
33
_doc <- createDoc " A.hs" " haskell" " {-#LANGUAGE NoImplicitPrelude #-}\n module A where\n import WatchedFilesMissingModule"
34
34
setIgnoringRegistrationRequests False
35
35
watchedFileRegs <- getWatchedFilesSubscriptionsUntil SMethod_TextDocumentPublishDiagnostics
@@ -40,7 +40,7 @@ tests = testGroup "watched files"
40
40
, testWithDummyPluginEmpty' " non workspace file" $ \ sessionDir -> do
41
41
tmpDir <- liftIO getTemporaryDirectory
42
42
let yaml = " cradle: {direct: {arguments: [\" -i" <> tail (init (show tmpDir)) <> " \" , \" A\" , \" WatchedFilesMissingModule\" ]}}"
43
- liftIO $ writeFile (sessionDir </> " hie.yaml" ) yaml
43
+ liftIO $ atomicFileWriteString (sessionDir </> " hie.yaml" ) yaml
44
44
_doc <- createDoc " A.hs" " haskell" " {-# LANGUAGE NoImplicitPrelude#-}\n module A where\n import WatchedFilesMissingModule"
45
45
setIgnoringRegistrationRequests False
46
46
watchedFileRegs <- getWatchedFilesSubscriptionsUntil SMethod_TextDocumentPublishDiagnostics
@@ -53,8 +53,8 @@ tests = testGroup "watched files"
53
53
, testGroup " Changes"
54
54
[
55
55
testWithDummyPluginEmpty' " workspace files" $ \ sessionDir -> do
56
- liftIO $ writeFile (sessionDir </> " hie.yaml" ) " cradle: {direct: {arguments: [\" -isrc\" , \" A\" , \" B\" ]}}"
57
- liftIO $ writeFile (sessionDir </> " B.hs" ) $ unlines
56
+ liftIO $ atomicFileWriteString (sessionDir </> " hie.yaml" ) " cradle: {direct: {arguments: [\" -isrc\" , \" A\" , \" B\" ]}}"
57
+ liftIO $ atomicFileWriteString (sessionDir </> " B.hs" ) $ unlines
58
58
[" module B where"
59
59
," b :: Bool"
60
60
," b = False" ]
@@ -66,7 +66,7 @@ tests = testGroup "watched files"
66
66
]
67
67
expectDiagnostics [(" A.hs" , [(DiagnosticSeverity_Error , (3 , 4 ), " Couldn't match expected type '()' with actual type 'Bool'" , Just " GHC-83865" )])]
68
68
-- modify B off editor
69
- liftIO $ writeFile (sessionDir </> " B.hs" ) $ unlines
69
+ liftIO $ atomicFileWriteString (sessionDir </> " B.hs" ) $ unlines
70
70
[" module B where"
71
71
," b :: Int"
72
72
," b = 0" ]
@@ -80,7 +80,7 @@ tests = testGroup "watched files"
80
80
let cabalFile = " reload.cabal"
81
81
cabalContent <- liftIO $ T. readFile cabalFile
82
82
let fix = T. replace " build-depends: base" " build-depends: base, split"
83
- liftIO $ T. writeFile cabalFile (fix cabalContent)
83
+ liftIO $ atomicFileWriteText cabalFile (fix cabalContent)
84
84
sendNotification SMethod_WorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams
85
85
[ FileEvent (filePathToUri $ sessionDir </> cabalFile) FileChangeType_Changed ]
86
86
expectDiagnostics [(hsFile, [] )]
0 commit comments