@@ -778,25 +778,51 @@ codeLensesTests = testGroup "code lenses"
778
778
779
779
watchedFilesTests :: TestTree
780
780
watchedFilesTests = testGroup " watched files"
781
- [ testSession' " workspace files" $ \ sessionDir -> do
782
- liftIO $ writeFile (sessionDir </> " hie.yaml" ) " cradle: {direct: {arguments: [\" -isrc\" , \" A\" , \" WatchedFilesMissingModule\" ]}}"
783
- _doc <- createDoc " A.hs" " haskell" " {-#LANGUAGE NoImplicitPrelude #-}\n module A where\n import WatchedFilesMissingModule"
784
- watchedFileRegs <- getWatchedFilesSubscriptionsUntil STextDocumentPublishDiagnostics
785
-
786
- -- Expect 2 subscriptions: one for all .hs files and one for the hie.yaml cradle
787
- liftIO $ length watchedFileRegs @?= 2
788
-
789
- , testSession' " non workspace file" $ \ sessionDir -> do
790
- tmpDir <- liftIO getTemporaryDirectory
791
- let yaml = " cradle: {direct: {arguments: [\" -i" <> tail (init (show tmpDir)) <> " \" , \" A\" , \" WatchedFilesMissingModule\" ]}}"
792
- liftIO $ writeFile (sessionDir </> " hie.yaml" ) yaml
793
- _doc <- createDoc " A.hs" " haskell" " {-# LANGUAGE NoImplicitPrelude#-}\n module A where\n import WatchedFilesMissingModule"
794
- watchedFileRegs <- getWatchedFilesSubscriptionsUntil STextDocumentPublishDiagnostics
795
-
796
- -- Expect 2 subscriptions: one for all .hs files and one for the hie.yaml cradle
797
- liftIO $ length watchedFileRegs @?= 2
798
-
799
- -- TODO add a test for didChangeWorkspaceFolder
781
+ [ testGroup " Subscriptions"
782
+ [ testSession' " workspace files" $ \ sessionDir -> do
783
+ liftIO $ writeFile (sessionDir </> " hie.yaml" ) " cradle: {direct: {arguments: [\" -isrc\" , \" A\" , \" WatchedFilesMissingModule\" ]}}"
784
+ _doc <- createDoc " A.hs" " haskell" " {-#LANGUAGE NoImplicitPrelude #-}\n module A where\n import WatchedFilesMissingModule"
785
+ watchedFileRegs <- getWatchedFilesSubscriptionsUntil STextDocumentPublishDiagnostics
786
+
787
+ -- Expect 2 subscriptions: one for all .hs files and one for the hie.yaml cradle
788
+ liftIO $ length watchedFileRegs @?= 2
789
+
790
+ , testSession' " non workspace file" $ \ sessionDir -> do
791
+ tmpDir <- liftIO getTemporaryDirectory
792
+ let yaml = " cradle: {direct: {arguments: [\" -i" <> tail (init (show tmpDir)) <> " \" , \" A\" , \" WatchedFilesMissingModule\" ]}}"
793
+ liftIO $ writeFile (sessionDir </> " hie.yaml" ) yaml
794
+ _doc <- createDoc " A.hs" " haskell" " {-# LANGUAGE NoImplicitPrelude#-}\n module A where\n import WatchedFilesMissingModule"
795
+ watchedFileRegs <- getWatchedFilesSubscriptionsUntil STextDocumentPublishDiagnostics
796
+
797
+ -- Expect 2 subscriptions: one for all .hs files and one for the hie.yaml cradle
798
+ liftIO $ length watchedFileRegs @?= 2
799
+
800
+ -- TODO add a test for didChangeWorkspaceFolder
801
+ ]
802
+ , testGroup " Changes"
803
+ [
804
+ testSession' " workspace files" $ \ sessionDir -> do
805
+ liftIO $ writeFile (sessionDir </> " hie.yaml" ) " cradle: {direct: {arguments: [\" -isrc\" , \" A\" , \" B\" ]}}"
806
+ liftIO $ writeFile (sessionDir </> " B.hs" ) $ unlines
807
+ [" module B where"
808
+ ," b :: Bool"
809
+ ," b = False" ]
810
+ _doc <- createDoc " A.hs" " haskell" $ T. unlines
811
+ [" module A where"
812
+ ," import B"
813
+ ," a :: ()"
814
+ ," a = b"
815
+ ]
816
+ expectDiagnostics [(" A.hs" , [(DsError , (3 , 4 ), " Couldn't match expected type '()' with actual type 'Bool'" )])]
817
+ -- modify B off editor
818
+ liftIO $ writeFile (sessionDir </> " B.hs" ) $ unlines
819
+ [" module B where"
820
+ ," b :: Int"
821
+ ," b = 0" ]
822
+ sendNotification SWorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
823
+ List [FileEvent (filePathToUri $ sessionDir </> " B.hs" ) FcChanged ]
824
+ expectDiagnostics [(" A.hs" , [(DsError , (3 , 4 ), " Couldn't match expected type '()' with actual type 'Int'" )])]
825
+ ]
800
826
]
801
827
802
828
insertImportTests :: TestTree
0 commit comments