git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
#1712, fast recompilation in psc-ide-server (#2013)
8bab509Christoph Hegemann
psc-ide-server/Main.hs+1−1
@@ -125,7 +125,7 @@ startServer port env = withSocketsDo $ do
125 case decodeT cmd of
125 case decodeT cmd of
126 Just cmd' -> do
126 Just cmd' -> do
127 result <- runExceptT (handleCommand cmd')
127 result <- runExceptT (handleCommand cmd')
128− $(logDebug) ("Answer was: " <> T.pack (show result))
128+ -- $(logDebug) ("Answer was: " <> T.pack (show result))
129 liftIO (hFlush stdout)
129 liftIO (hFlush stdout)
130 case result of
130 case result of
131 -- What function can I use to clean this up?
131 -- What function can I use to clean this up?
psc-ide-server/PROTOCOL.md+24
@@ -240,6 +240,30 @@ Example:
240}
240}
241```
241```
242
242
243+### Rebuild
244+
245+The `rebuild` command provides a fast rebuild for a single module. It doesn't
246+recompile the entire project though. All the modules dependencies need to be
247+loaded.
248+
249+Arguments:
250+- `file :: String` the path to the module to rebuild
251+
252+```json
253+{
254+ "command": "rebuild",
255+ "params": {
256+ "file": "/path/to/file.purs"
257+ }
258+}
259+```
260+
261+**Result**
262+
263+In the Success case you get a list of warnings in the compilers json format.
264+
265+In the Error case you get the errors in the compilers json format
266+
243### Pursuit
267### Pursuit
244The `pursuit` command looks up the packages/completions for a given identifier from Pursuit.
268The `pursuit` command looks up the packages/completions for a given identifier from Pursuit.
245
269
psc/Main.hs+1−2
@@ -28,8 +28,7 @@ import qualified Language.PureScript as P
28import qualified Paths_purescript as Paths
28import qualified Paths_purescript as Paths
29
29
30import Language.PureScript.Make
30import Language.PureScript.Make
31−
32−import JSON
31+import Language.PureScript.Errors.JSON
33
32
34data PSCMakeOptions = PSCMakeOptions
33data PSCMakeOptions = PSCMakeOptions
35 { pscmInput :: [FilePath]
34 { pscmInput :: [FilePath]
purescript.cabal+6−1
@@ -37,6 +37,8 @@ extra-source-files: examples/passing/*.purs
37 , tests/support/flattened/*.js
37 , tests/support/flattened/*.js
38 , tests/support/psci/*.purs
38 , tests/support/psci/*.purs
39 , tests/support/pscide/src/*.purs
39 , tests/support/pscide/src/*.purs
40+ , tests/support/pscide/src/*.js
41+ , tests/support/pscide/src/*.fail
40 , stack.yaml
42 , stack.yaml
41 , stack-lts-5.yaml
43 , stack-lts-5.yaml
42 , stack-nightly.yaml
44 , stack-nightly.yaml
@@ -127,6 +129,7 @@ library
127 Language.PureScript.Comments
129 Language.PureScript.Comments
128 Language.PureScript.Environment
130 Language.PureScript.Environment
129 Language.PureScript.Errors
131 Language.PureScript.Errors
132+ Language.PureScript.Errors.JSON
130 Language.PureScript.Kinds
133 Language.PureScript.Kinds
131 Language.PureScript.Linter
134 Language.PureScript.Linter
132 Language.PureScript.Linter.Exhaustive
135 Language.PureScript.Linter.Exhaustive
@@ -215,6 +218,7 @@ library
215 Language.PureScript.Ide.Reexports
218 Language.PureScript.Ide.Reexports
216 Language.PureScript.Ide.Imports
219 Language.PureScript.Ide.Imports
217 Language.PureScript.Ide.Util
220 Language.PureScript.Ide.Util
221+ Language.PureScript.Ide.Rebuild
218
222
219 Control.Monad.Logger
223 Control.Monad.Logger
220 Control.Monad.Supply
224 Control.Monad.Supply
@@ -238,7 +242,7 @@ executable psc
238 main-is: Main.hs
242 main-is: Main.hs
239 buildable: True
243 buildable: True
240 hs-source-dirs: psc
244 hs-source-dirs: psc
241− other-modules: JSON, Paths_purescript
245+ other-modules: Paths_purescript
242 ghc-options: -Wall -O2 -fno-warn-unused-do-bind -threaded -rtsopts "-with-rtsopts=-N"
246 ghc-options: -Wall -O2 -fno-warn-unused-do-bind -threaded -rtsopts "-with-rtsopts=-N"
243
247
244executable psci
248executable psci
@@ -370,6 +374,7 @@ test-suite tests
370 Language.PureScript.Ide.Imports.IntegrationSpec
374 Language.PureScript.Ide.Imports.IntegrationSpec
371 Language.PureScript.Ide.Integration
375 Language.PureScript.Ide.Integration
372 Language.PureScript.Ide.MatcherSpec
376 Language.PureScript.Ide.MatcherSpec
377+ Language.PureScript.Ide.RebuildSpec
373 Language.PureScript.Ide.ReexportsSpec
378 Language.PureScript.Ide.ReexportsSpec
374 Language.PureScript.IdeSpec
379 Language.PureScript.IdeSpec
375 PSCi.Completion
380 PSCi.Completion
psc/JSON.hs → src/Language/PureScript/Errors/JSON.hsrenamed+7−7
@@ -1,6 +1,6 @@
1-----------------------------------------------------------------------------
1-----------------------------------------------------------------------------
2--
2--
3−-- Module : Main
3+-- Module : Language.PureScript.Errors.JSON
4-- Copyright : (c) 2013-15 Phil Freeman, (c) 2014-15 Gary Burgess
4-- Copyright : (c) 2013-15 Phil Freeman, (c) 2014-15 Gary Burgess
5-- License : MIT (http://opensource.org/licenses/MIT)
5-- License : MIT (http://opensource.org/licenses/MIT)
6--
6--
@@ -14,7 +14,7 @@
14
14
15{-# LANGUAGE TemplateHaskell #-}
15{-# LANGUAGE TemplateHaskell #-}
16
16
17−module JSON where
17+module Language.PureScript.Errors.JSON where
18
18
19import Prelude ()
19import Prelude ()
20import Prelude.Compat
20import Prelude.Compat
@@ -28,9 +28,9 @@ data ErrorPosition = ErrorPosition
28 , startColumn :: Int
28 , startColumn :: Int
29 , endLine :: Int
29 , endLine :: Int
30 , endColumn :: Int
30 , endColumn :: Int
31− }
31+ } deriving (Show, Eq, Ord)
32
32
33−data ErrorSuggestion = ErrorSuggestion { replacement :: String }
33+data ErrorSuggestion = ErrorSuggestion { replacement :: String } deriving (Show, Eq)
34
34
35data JSONError = JSONError
35data JSONError = JSONError
36 { position :: Maybe ErrorPosition
36 { position :: Maybe ErrorPosition
@@ -40,12 +40,12 @@ data JSONError = JSONError
40 , filename :: Maybe String
40 , filename :: Maybe String
41 , moduleName :: Maybe String
41 , moduleName :: Maybe String
42 , suggestion :: Maybe ErrorSuggestion
42 , suggestion :: Maybe ErrorSuggestion
43− }
43+ } deriving (Show, Eq)
44
44
45data JSONResult = JSONResult
45data JSONResult = JSONResult
46 { warnings :: [JSONError]
46 { warnings :: [JSONError]
47 , errors :: [JSONError]
47 , errors :: [JSONError]
48− }
48+ } deriving (Show, Eq)
49
49
50$(A.deriveJSON A.defaultOptions ''ErrorPosition)
50$(A.deriveJSON A.defaultOptions ''ErrorPosition)
51$(A.deriveJSON A.defaultOptions ''JSONError)
51$(A.deriveJSON A.defaultOptions ''JSONError)
@@ -64,7 +64,7 @@ toJSONError verbose level e =
64 (P.wikiUri e)
64 (P.wikiUri e)
65 (P.spanName <$> sspan)
65 (P.spanName <$> sspan)
66 (P.runModuleName <$> P.errorModule e)
66 (P.runModuleName <$> P.errorModule e)
67− (toSuggestion <$> (P.errorSuggestion $ P.unwrapErrorMessage e))
67+ (toSuggestion <$> P.errorSuggestion (P.unwrapErrorMessage e))
68 where
68 where
69 sspan :: Maybe P.SourceSpan
69 sspan :: Maybe P.SourceSpan
70 sspan = P.errorSpan e
70 sspan = P.errorSpan e
src/Language/PureScript/Ide.hs+3−2
@@ -53,11 +53,11 @@ import Language.PureScript.Ide.SourceFile
53import Language.PureScript.Ide.State
53import Language.PureScript.Ide.State
54import Language.PureScript.Ide.Types
54import Language.PureScript.Ide.Types
55import Language.PureScript.Ide.Util
55import Language.PureScript.Ide.Util
56+import Language.PureScript.Ide.Rebuild
56import System.Directory
57import System.Directory
57import System.FilePath
58import System.FilePath
58import System.Exit
59import System.Exit
59
60
60−
61handleCommand :: (PscIde m, MonadLogger m, MonadError PscIdeError m) =>
61handleCommand :: (PscIde m, MonadLogger m, MonadError PscIdeError m) =>
62 Command -> m Success
62 Command -> m Success
63handleCommand (Load [] []) = loadAllModules
63handleCommand (Load [] []) = loadAllModules
@@ -89,6 +89,8 @@ handleCommand (Import fp outfp filters (AddImportForIdentifier ident)) = do
89 case rs of
89 case rs of
90 Right rs' -> answerRequest outfp rs'
90 Right rs' -> answerRequest outfp rs'
91 Left question -> pure $ CompletionResult (mapMaybe completionFromMatch question)
91 Left question -> pure $ CompletionResult (mapMaybe completionFromMatch question)
92+handleCommand (Rebuild file) =
93+ rebuildFile file
92handleCommand Cwd =
94handleCommand Cwd =
93 TextResult . T.pack <$> liftIO getCurrentDirectory
95 TextResult . T.pack <$> liftIO getCurrentDirectory
94handleCommand Quit = liftIO exitSuccess
96handleCommand Quit = liftIO exitSuccess
@@ -238,4 +240,3 @@ filePathFromModule moduleName = do
238 if ex
240 if ex
239 then pure path
241 then pure path
240 else throwError (ModuleFileNotFound moduleName)
242 else throwError (ModuleFileNotFound moduleName)
241−
src/Language/PureScript/Ide/Command.hs+5−1
@@ -63,6 +63,7 @@ data Command
63 -- Import InputFile OutputFile
63 -- Import InputFile OutputFile
64 | Import FilePath (Maybe FilePath) [Filter] ImportCommand
64 | Import FilePath (Maybe FilePath) [Filter] ImportCommand
65 | List { listType :: ListType }
65 | List { listType :: ListType }
66+ | Rebuild FilePath -- ^ Rebuild the specified file using the loaded externs
66 | Cwd
67 | Cwd
67 | Quit
68 | Quit
68
69
@@ -149,5 +150,8 @@ instance FromJSON Command where
149 filters <- params .:? "filters"
150 filters <- params .:? "filters"
150 importCommand <- params .: "importCommand"
151 importCommand <- params .: "importCommand"
151 pure $ Import fp out (fromMaybe [] filters) importCommand
152 pure $ Import fp out (fromMaybe [] filters) importCommand
153+ "rebuild" -> do
154+ params <- o .: "params"
155+ filePath <- params .: "file"
156+ return $ Rebuild filePath
152 _ -> mzero
157 _ -> mzero
153−
src/Language/PureScript/Ide/Error.hs+12−6
@@ -20,6 +20,7 @@ module Language.PureScript.Ide.Error
20import Data.Aeson
20import Data.Aeson
21import Data.Monoid
21import Data.Monoid
22import Data.Text (Text, pack)
22import Data.Text (Text, pack)
23+import Language.PureScript.Errors.JSON
23import Language.PureScript.Ide.Types (ModuleIdent)
24import Language.PureScript.Ide.Types (ModuleIdent)
24import qualified Text.Parsec.Error as P
25import qualified Text.Parsec.Error as P
25
26
@@ -31,9 +32,13 @@ data PscIdeError
31 | ModuleNotFound ModuleIdent
32 | ModuleNotFound ModuleIdent
32 | ModuleFileNotFound ModuleIdent
33 | ModuleFileNotFound ModuleIdent
33 | ParseError P.ParseError ErrorMsg
34 | ParseError P.ParseError ErrorMsg
34− deriving (Show, Eq)
35+ | RebuildError [JSONError]
35
36
36instance ToJSON PscIdeError where
37instance ToJSON PscIdeError where
38+ toJSON (RebuildError errs) = object
39+ [ "resultType" .= ("error" :: Text)
40+ , "result" .= errs
41+ ]
37 toJSON err = object
42 toJSON err = object
38 [ "resultType" .= ("error" :: Text)
43 [ "resultType" .= ("error" :: Text)
39 , "result" .= textError err
44 , "result" .= textError err
@@ -44,8 +49,9 @@ textError (GeneralError msg) = pack msg
44textError (NotFound ident) = "Symbol '" <> ident <> "' not found."
49textError (NotFound ident) = "Symbol '" <> ident <> "' not found."
45textError (ModuleNotFound ident) = "Module '" <> ident <> "' not found."
50textError (ModuleNotFound ident) = "Module '" <> ident <> "' not found."
46textError (ModuleFileNotFound ident) = "Extern file for module " <> ident <>" could not be found"
51textError (ModuleFileNotFound ident) = "Extern file for module " <> ident <>" could not be found"
47−textError (ParseError parseError msg) = pack $ msg <> ": " <> show (escape parseError)
52+textError (ParseError parseError msg) = let escape = show
48− where
49− -- escape newlines and other special chars so we can send the error over the socket as a single line
53+ -- escape newlines and other special
50− escape :: P.ParseError -> String
54+ -- chars so we can send the error
51− escape = show
55+ -- over the socket as a single line
56+ in pack $ msg <> ": " <> show (escape parseError)
57+textError (RebuildError err) = pack (show err)
src/Language/PureScript/Ide/Rebuild.hsnew file

Binary file not shown.

src/Language/PureScript/Ide/State.hs+4
@@ -51,6 +51,10 @@ getExternFiles = do
51 stateVar <- envStateVar <$> ask
51 stateVar <- envStateVar <$> ask
52 liftIO (externsFiles <$> readTVarIO stateVar)
52 liftIO (externsFiles <$> readTVarIO stateVar)
53
53
54+getExternFile :: (PscIde m) =>
55+ ModuleName -> m (Maybe ExternsFile)
56+getExternFile mn = M.lookup mn <$> getExternFiles
57+
54getAllDecls :: (PscIde m) => m [ExternDecl]
58getAllDecls :: (PscIde m) => m [ExternDecl]
55getAllDecls = concat <$> getPscIdeState
59getAllDecls = concat <$> getPscIdeState
56
60
src/Language/PureScript/Ide/Types.hs+3
@@ -33,6 +33,7 @@ import Data.Maybe (maybeToList)
33import Data.Text (Text (), pack, unpack)
33import Data.Text (Text (), pack, unpack)
34import qualified Language.PureScript.AST.Declarations as D
34import qualified Language.PureScript.AST.Declarations as D
35import Language.PureScript.Externs
35import Language.PureScript.Externs
36+import qualified Language.PureScript.Errors.JSON as P
36import qualified Language.PureScript.Names as N
37import qualified Language.PureScript.Names as N
37import qualified Language.PureScript as P
38import qualified Language.PureScript as P
38
39
@@ -144,6 +145,7 @@ data Success =
144 | PursuitResult [PursuitResponse]
145 | PursuitResult [PursuitResponse]
145 | ImportList [ModuleImport]
146 | ImportList [ModuleImport]
146 | ModuleList [ModuleIdent]
147 | ModuleList [ModuleIdent]
148+ | RebuildSuccess [P.JSONError]
147 deriving(Show, Eq)
149 deriving(Show, Eq)
148
150
149encodeSuccess :: (ToJSON a) => a -> Value
151encodeSuccess :: (ToJSON a) => a -> Value
@@ -157,6 +159,7 @@ instance ToJSON Success where
157 toJSON (PursuitResult resp) = encodeSuccess resp
159 toJSON (PursuitResult resp) = encodeSuccess resp
158 toJSON (ImportList decls) = encodeSuccess decls
160 toJSON (ImportList decls) = encodeSuccess decls
159 toJSON (ModuleList modules) = encodeSuccess modules
161 toJSON (ModuleList modules) = encodeSuccess modules
162+ toJSON (RebuildSuccess modules) = encodeSuccess modules
160
163
161newtype PursuitQuery = PursuitQuery Text
164newtype PursuitQuery = PursuitQuery Text
162 deriving (Show, Eq)
165 deriving (Show, Eq)
src/Language/PureScript/Make.hs+25−16
@@ -14,6 +14,7 @@ module Language.PureScript.Make
14 , ProgressMessage(..), renderProgressMessage
14 , ProgressMessage(..), renderProgressMessage
15 , MakeActions(..)
15 , MakeActions(..)
16 , Externs()
16 , Externs()
17+ , rebuildModule
17 , make
18 , make
18
19
19 -- * Implementation of Make API using files on disk
20 -- * Implementation of Make API using files on disk
@@ -147,6 +148,28 @@ data RebuildPolicy
147 -- | Always rebuild this module
148 -- | Always rebuild this module
148 | RebuildAlways deriving (Show, Read, Eq, Ord)
149 | RebuildAlways deriving (Show, Read, Eq, Ord)
149
150
151+-- | Rebuild a single module
152+rebuildModule :: forall m. (Monad m, MonadBaseControl IO m, MonadReader Options m, MonadError MultipleErrors m, MonadWriter MultipleErrors m)
153+ => MakeActions m
154+ -> [ExternsFile]
155+ -> Module
156+ -> m ExternsFile
157+rebuildModule MakeActions{..} externs m@(Module _ _ moduleName _ _) = do
158+ progress $ CompilingModule moduleName
159+ let env = foldl' (flip applyExternsFileToEnvironment) initEnvironment externs
160+ lint m
161+ ((checked@(Module ss coms _ elaborated exps), env'), nextVar) <- runSupplyT 0 $ do
162+ [desugared] <- desugar externs [m]
163+ runCheck' env $ typeCheckModule desugared
164+ checkExhaustiveModule env' checked
165+ regrouped <- createBindingGroups moduleName . collapseBindingGroups $ elaborated
166+ let mod' = Module ss coms moduleName regrouped exps
167+ corefn = CF.moduleToCoreFn env' mod'
168+ [renamed] = renameInModules [corefn]
169+ exts = moduleToExternsFile mod' env'
170+ evalSupplyT nextVar . codegen renamed env' . BU8.toString . B.toStrict . encode $ exts
171+ return exts
172+
150-- |
173-- |
151-- Compiles in "make" mode, compiling each module separately to a js files and an externs file
174-- Compiles in "make" mode, compiling each module separately to a js files and an externs file
152--
175--
@@ -157,7 +180,7 @@ make :: forall m. (Monad m, MonadBaseControl IO m, MonadReader Options m, MonadE
157 => MakeActions m
180 => MakeActions m
158 -> [Module]
181 -> [Module]
159 -> m Environment
182 -> m Environment
160−make MakeActions{..} ms = do
183+make ma@MakeActions{..} ms = do
161 requirePath <- asks optionsRequirePath
184 requirePath <- asks optionsRequirePath
162 when (isJust requirePath) $ tell $ errorMessage DeprecatedRequirePath
185 when (isJust requirePath) $ tell $ errorMessage DeprecatedRequirePath
163
186
@@ -221,21 +244,7 @@ make MakeActions{..} ms = do
221 _ -> True
244 _ -> True
222
245
223 let rebuild = do
246 let rebuild = do
224− (exts, warnings) <- listen $ do
247+ (exts, warnings) <- listen $ rebuildModule ma externs m
225− progress $ CompilingModule moduleName
226− let env = foldl' (flip applyExternsFileToEnvironment) initEnvironment externs
227− lint m
228− ((checked@(Module ss coms _ elaborated exps), env'), nextVar) <- runSupplyT 0 $ do
229− [desugared] <- desugar externs [m]
230− runCheck' env $ typeCheckModule desugared
231− checkExhaustiveModule env' checked
232− regrouped <- createBindingGroups moduleName . collapseBindingGroups $ elaborated
233− let mod' = Module ss coms moduleName regrouped exps
234− corefn = CF.moduleToCoreFn env' mod'
235− [renamed] = renameInModules [corefn]
236− exts = moduleToExternsFile mod' env'
237− evalSupplyT nextVar . codegen renamed env' . BU8.toString . B.toStrict . encode $ exts
238− return exts
239 markComplete (Just (warnings, exts)) Nothing
248 markComplete (Just (warnings, exts)) Nothing
240
249
241 if shouldRebuild
250 if shouldRebuild
tests/Language/PureScript/Ide/Integration.hs+14
@@ -27,11 +27,13 @@ module Language.PureScript.Ide.Integration
27 , projectDirectory
27 , projectDirectory
28 , deleteFileIfExists
28 , deleteFileIfExists
29 -- sending commands
29 -- sending commands
30+ , loadModule
30 , loadModuleWithDeps
31 , loadModuleWithDeps
31 , getFlexCompletions
32 , getFlexCompletions
32 , getType
33 , getType
33 , addImport
34 , addImport
34 , addImplicitImport
35 , addImplicitImport
36+ , rebuildModule
35 -- checking results
37 -- checking results
36 , resultIsSuccess
38 , resultIsSuccess
37 , parseCompletions
39 , parseCompletions
@@ -131,6 +133,9 @@ quitServer = do
131loadModuleWithDeps :: String -> IO String
133loadModuleWithDeps :: String -> IO String
132loadModuleWithDeps m = sendCommand $ load [] [m]
134loadModuleWithDeps m = sendCommand $ load [] [m]
133
135
136+loadModule :: String -> IO String
137+loadModule m = sendCommand $ load [m] []
138+
134getFlexCompletions :: String -> IO [(String, String, String)]
139getFlexCompletions :: String -> IO [(String, String, String)]
135getFlexCompletions q = parseCompletions <$> sendCommand (completion [] (Just (flexMatcher q)))
140getFlexCompletions q = parseCompletions <$> sendCommand (completion [] (Just (flexMatcher q)))
136
141
@@ -143,6 +148,9 @@ addImport identifier fp outfp = sendCommand (addImportC identifier fp outfp)
143addImplicitImport :: String -> FilePath -> FilePath -> IO String
148addImplicitImport :: String -> FilePath -> FilePath -> IO String
144addImplicitImport mn fp outfp = sendCommand (addImplicitImportC mn fp outfp)
149addImplicitImport mn fp outfp = sendCommand (addImplicitImportC mn fp outfp)
145
150
151+rebuildModule :: FilePath -> IO String
152+rebuildModule m = sendCommand (rebuildC m Nothing)
153+
146-- Command Encoding
154-- Command Encoding
147
155
148commandWrapper :: String -> Value -> Value
156commandWrapper :: String -> Value -> Value
@@ -166,6 +174,12 @@ addImplicitImportC mn = addImportW $
166 , "module" .= mn
174 , "module" .= mn
167 ]
175 ]
168
176
177+rebuildC :: FilePath -> Maybe FilePath -> Value
178+rebuildC file outFile =
179+ commandWrapper "rebuild" (object [ "file" .= file
180+ , "outfile" .= outFile
181+ ])
182+
169addImportW :: Value -> FilePath -> FilePath -> Value
183addImportW :: Value -> FilePath -> FilePath -> Value
170addImportW importCommand fp outfp =
184addImportW importCommand fp outfp =
171 commandWrapper "import" (object [ "file" .= fp
185 commandWrapper "import" (object [ "file" .= fp
tests/Language/PureScript/Ide/RebuildSpec.hsnew file+62
@@ -0,0 +1,62 @@
1+module Language.PureScript.Ide.RebuildSpec where
2+
3+import Control.Monad
4+import qualified Language.PureScript.Ide.Integration as Integration
5+import Test.Hspec
6+
7+import System.FilePath
8+
9+compile :: IO ()
10+compile = do
11+ Integration.deleteOutputFolder
12+ s <- Integration.compileTestProject
13+ unless s $ fail "Failed to compile .purs sources"
14+
15+teardown :: IO ()
16+teardown = Integration.quitServer
17+
18+restart :: IO ()
19+restart = Integration.quitServer *> (void Integration.startServer)
20+
21+shouldBeSuccess :: String -> IO ()
22+shouldBeSuccess = shouldBe True . Integration.resultIsSuccess
23+
24+shouldBeFailure :: String -> IO ()
25+shouldBeFailure = shouldBe False . Integration.resultIsSuccess
26+
27+spec :: Spec
28+spec = beforeAll_ compile $ afterAll_ teardown $ before_ restart $ do
29+ describe "Rebuilding single modules" $ do
30+ it "rebuilds a correct module without dependencies successfully" $ do
31+ _ <- Integration.loadModuleWithDeps "RebuildSpecSingleModule"
32+ pdir <- Integration.projectDirectory
33+ let file = pdir </> "src" </> "RebuildSpecSingleModule.purs"
34+ Integration.rebuildModule file >>= shouldBeSuccess
35+ it "fails to rebuild an incorrect module without dependencies and returns the errors" $ do
36+ pdir <- Integration.projectDirectory
37+ let file = pdir </> "src" </> "RebuildSpecSingleModule.fail"
38+ Integration.rebuildModule file >>= shouldBeFailure
39+ it "rebuilds a correct module with its dependencies successfully" $ do
40+ _ <- Integration.loadModuleWithDeps "RebuildSpecWithDeps"
41+ pdir <- Integration.projectDirectory
42+ let file = pdir </> "src" </> "RebuildSpecWithDeps.purs"
43+ Integration.rebuildModule file >>= shouldBeSuccess
44+ it "rebuilds a correct module that has reverse dependencies" $ do
45+ _ <- Integration.loadModuleWithDeps "RebuildSpecWithDeps"
46+ pdir <- Integration.projectDirectory
47+ let file = pdir </> "src" </> "RebuildSpecDep.purs"
48+ Integration.rebuildModule file >>= shouldBeSuccess
49+ it "fails to rebuild a module if its dependencies are not loaded" $ do
50+ _ <- Integration.loadModule "RebuildSpecWithDeps"
51+ pdir <- Integration.projectDirectory
52+ let file = pdir </> "src" </> "RebuildSpecWithDeps.purs"
53+ Integration.rebuildModule file >>= shouldBeFailure
54+ it "rebuilds a correct module with a foreign file" $ do
55+ _ <- Integration.loadModuleWithDeps "RebuildSpecWithForeign"
56+ pdir <- Integration.projectDirectory
57+ let file = pdir </> "src" </> "RebuildSpecWithForeign.purs"
58+ Integration.rebuildModule file >>= shouldBeSuccess
59+ it "fails to rebuild a module with a foreign import but no file" $ do
60+ pdir <- Integration.projectDirectory
61+ let file = pdir </> "src" </> "RebuildSpecWithMissingForeign.fail"
62+ Integration.rebuildModule file >>= shouldBeFailure
tests/support/pscide/src/RebuildSpecDep.pursnew file+3
@@ -0,0 +1,3 @@
1+module RebuildSpecDep where
2+
3+dep = 42
tests/support/pscide/src/RebuildSpecSingleModule.failnew file+3
@@ -0,0 +1,3 @@
1+module RebuildSpecSingleModule where
2+
3+let anerror
tests/support/pscide/src/RebuildSpecSingleModule.pursnew file+4
@@ -0,0 +1,4 @@
1+module RebuildSpecSingleModule where
2+
3+id x = x
4+const x y = x
tests/support/pscide/src/RebuildSpecWithDeps.pursnew file+5
@@ -0,0 +1,5 @@
1+module RebuildSpecWithDeps where
2+
3+import RebuildSpecDep (dep)
4+
5+x = dep
tests/support/pscide/src/RebuildSpecWithForeign.jsnew file+3
@@ -0,0 +1,3 @@
1+// module RebuildSpecWithForeign
2+
3+exports.f = 5;
tests/support/pscide/src/RebuildSpecWithForeign.pursnew file+3
@@ -0,0 +1,3 @@
1+module RebuildSpecWithForeign where
2+
3+foreign import f :: Int
tests/support/pscide/src/RebuildSpecWithMissingForeign.failnew file+3
@@ -0,0 +1,3 @@
1+module RebuildSpecWithMissingForeign where
2+
3+foreign import f :: Int