Skip to content
Browse files

build on source or target

  • Loading branch information...
1 parent 54767eb commit 51daf9142deeee45bf19b7d031642bb7e19127e3 @JPMoresmau committed Sep 21, 2011
View
6 newbuildutility.txt
@@ -1,6 +1,10 @@
we could have a server listening to requests and always on (one server for all projects) Without the GHC API it shouldn't take much memory.
Calls that use the GHC API should be run in a separate process (one process for each open file???)
+what is the purpose of the synchronized temp folder?
+ - save in there files not saved by the editor so that preprocessing et al can be done (run GHC on new file)
+ - having all files there mean we get an exact replica except of the changed file
+ - BUT we do not need it for builds!
synchronize
create/synchronize sub folder (.dist-toolname) and ensure all files that have changed in base folder are present in folder
@@ -15,12 +19,14 @@ synchronize
can take a reset flag that ensure all files are the same (remove generated files)
configure
+ configure in proper folder
cabal API call
maybe a executable call + parse result is better (warnings and such will just be written to output, so we need to parse it anyway)
with additional flags (enable-tests)
parse errors and warnings
build
+ build in proper folder
require configure
cabal executable/API call?
parse errors and warnings
View
19 src-exe/Language/Haskell/BuildWrapper/CMD.hs
@@ -17,11 +17,11 @@ type CabalFile = FilePath
type CabalPath = FilePath
type TempFolder = FilePath
-data BWCmd=Synchronize {tempFolder::TempFolder, cabalPath::CabalPath, cabalFile::CabalFile}
- | Synchronize1 {tempFolder::TempFolder, cabalPath::CabalPath, cabalFile::CabalFile, file:: FilePath}
+data BWCmd=Synchronize {tempFolder::TempFolder, cabalPath::CabalPath, cabalFile::CabalFile, force::Bool}
+ | Synchronize1 {tempFolder::TempFolder, cabalPath::CabalPath, cabalFile::CabalFile, force::Bool, file:: FilePath}
| Write {tempFolder::TempFolder, cabalPath::CabalPath, cabalFile::CabalFile, file:: FilePath, contents::String}
| Configure {tempFolder::TempFolder, cabalPath::CabalPath, cabalFile::CabalFile,verbosity::Verbosity,cabalTarget::WhichCabal}
- | Build {tempFolder::TempFolder, cabalPath::CabalPath, cabalFile::CabalFile,verbosity::Verbosity,output::Bool}
+ | Build {tempFolder::TempFolder, cabalPath::CabalPath, cabalFile::CabalFile,verbosity::Verbosity,output::Bool,cabalTarget::WhichCabal}
| Outline {tempFolder::TempFolder, cabalPath::CabalPath, cabalFile::CabalFile, file:: FilePath}
| TokenTypes {tempFolder::TempFolder, cabalPath::CabalPath, cabalFile::CabalFile, file:: FilePath}
| Occurrences {tempFolder::TempFolder, cabalPath::CabalPath, cabalFile::CabalFile, file:: FilePath,token::String}
@@ -36,15 +36,16 @@ tf=".dist-buildwrapper" &= typDir &= help "temporary folder, relative to cabal f
cp="cabal" &= typFile &= help "location of cabal executable"
cf=def &= typFile &= help "cabal file"
fp=def &= typFile &= help "relative path of file to process"
+ff=def &= help "overwrite newer file"
v=Normal &= help "verbosity"
wc=Target &= help "which cabal file to use: original or temporary"
-msynchronize = Synchronize tf cp cf
-msynchronize1 = Synchronize1 tf cp cf fp
+msynchronize = Synchronize tf cp cf ff
+msynchronize1 = Synchronize1 tf cp cf ff fp
mconfigure = Configure tf cp cf v wc
mwrite= Write tf cp cf fp (def &= help "file contents")
-mbuild = Build tf cp cf v (def &= help "output compilation and linking result")
+mbuild = Build tf cp cf v (def &= help "output compilation and linking result") wc
moutline = Outline tf cp cf fp
mtokenTypes= TokenTypes tf cp cf fp
moccurrences=Occurrences tf cp cf fp (def &= help "text to search occurrences of" &= name "token")
@@ -66,11 +67,11 @@ cmdMain = (cmdArgs $
>>= handle
where
handle ::BWCmd -> IO ()
- handle (Synchronize tf cp cf)=run tf cp cf synchronize
- handle (Synchronize1 tf cp cf fp)=run tf cp cf (synchronize1 fp)
+ handle (Synchronize tf cp cf ff )=run tf cp cf (synchronize ff)
+ handle (Synchronize1 tf cp cf ff fp)=run tf cp cf (synchronize1 ff fp)
handle (Write tf cp cf fp s)=run tf cp cf (write fp s)
handle (Configure tf cp cf v wc)=runV v tf cp cf (configure wc)
- handle (Build tf cp cf wc output)=runV v tf cp cf (build output)
+ handle (Build tf cp cf v output wc)=runV v tf cp cf (build output wc)
handle (Outline tf cp cf fp)=run tf cp cf (getOutline fp)
handle (TokenTypes tf cp cf fp)=run tf cp cf (getTokenTypes fp)
handle (Occurrences tf cp cf fp token)=run tf cp cf (getOccurrences fp token)
View
18 src/Language/Haskell/BuildWrapper/API.hs
@@ -15,25 +15,25 @@ import Data.Maybe
import System.FilePath
import GHC (TypecheckedSource)
-synchronize :: BuildWrapper(OpResult [FilePath])
-synchronize =do
+synchronize :: Bool -> BuildWrapper(OpResult [FilePath])
+synchronize force =do
cf<-gets cabalFile
- m<-copyFromMain $ takeFileName cf
+ m<-copyFromMain force $ takeFileName cf
(fileList,ns)<-getFilesToCopy
--liftIO $ putStrLn ("filelist:" ++ (show fileList))
--let fileList=case motherFiles of
-- Nothing ->[]
-- Just fps->fps
- m1<-mapM copyFromMain (
+ m1<-mapM (copyFromMain force)(
"Setup.hs":
"Setup.lhs":
fileList)
return $ (catMaybes (m:m1),ns)
-synchronize1 :: FilePath -> BuildWrapper(Maybe FilePath)
-synchronize1 fp = do
- m1<-mapM copyFromMain [fp]
+synchronize1 :: Bool -> FilePath -> BuildWrapper(Maybe FilePath)
+synchronize1 force fp = do
+ m1<-mapM (copyFromMain force) [fp]
return $ head m1
write :: FilePath -> String -> BuildWrapper()
@@ -48,7 +48,7 @@ configure which= do
(mlbi,msgs)<-cabalConfigure which
return $ (isJust mlbi,msgs)
-build :: Bool -> BuildWrapper (OpResult Bool)
+build :: Bool -> WhichCabal -> BuildWrapper (OpResult Bool)
build = cabalBuild
-- (bool,bwns)<-configure
-- if bool
@@ -120,7 +120,7 @@ withGHCAST fp f= do
getOutline :: FilePath -> BuildWrapper (OpResult [OutlineDef])
getOutline fp=do
(mast,bwns)<-getAST fp
- -- liftIO $ putStrLn $ show mast
+ liftIO $ putStrLn $ show mast
case mast of
Just (ParseOk ast)->do
return (getHSEOutline ast,bwns)
View
6 src/Language/Haskell/BuildWrapper/Base.hs
@@ -182,15 +182,15 @@ getFullSrc src=do
let dir=(takeDirectory cf)
return $ (dir </> src)
-copyFromMain :: FilePath -> BuildWrapper(Maybe FilePath)
-copyFromMain src=do
+copyFromMain :: Bool -> FilePath -> BuildWrapper(Maybe FilePath)
+copyFromMain force src=do
fullSrc<-getFullSrc src
exSrc<-liftIO $ doesFileExist fullSrc
if exSrc
then do
fullTgt<-getTargetPath src
ex<-liftIO $ doesFileExist fullTgt
- shouldCopy<-if (not ex )
+ shouldCopy<- if (force || (not ex))
then return True
else do
modSrc<-liftIO $ getModificationTime fullSrc
View
23 src/Language/Haskell/BuildWrapper/Cabal.hs
@@ -90,10 +90,10 @@ cabalV =do
toCabalV Verbose =V.verbose
toCabalV Deafening =V.deafening
-cabalBuild :: Bool -> BuildWrapper (OpResult Bool)
-cabalBuild output= do
- (mr,n)<-withCabal Target (\_->do
- cf<-getCabalFile Target
+cabalBuild :: Bool -> WhichCabal -> BuildWrapper (OpResult Bool)
+cabalBuild output srcOrTgt= do
+ (mr,n)<-withCabal srcOrTgt (\_->do
+ cf<-getCabalFile srcOrTgt
cp<-gets cabalPath
v<-cabalV
dist_dir<-getDistDir
@@ -315,17 +315,22 @@ type CabalBuildInfo=(BuildInfo,ComponentLocalBuildInfo,FilePath,[(ModuleName,Fil
getBuildInfo :: FilePath -> BuildWrapper (OpResult (Maybe (LocalBuildInfo,CabalBuildInfo)))
getBuildInfo fp=do
- (mmr,bwns)<-withCabal Target (\lbi->do
- fps<-getReferencedFiles lbi
+ (mmr,bwns)<-go getReferencedFiles
+ case mmr of
+ Nothing-> do
+ (mmr2,bwns2)<-go getAllFiles
+ return $ case mmr2 of
+ Nothing-> (Nothing,bwns)
+ Just a-> (a,bwns2)
+ Just a->return $ (a,bwns)
+ where go f=withCabal Source (\lbi->do
+ fps<-f lbi
let ok=filter (\(_,_,_,ls)->not $ null ls ) $
map (\(n1,n2,n3,ls)->(n1,n2,n3,filter (\(_,b)->b==fp) ls) )
fps
return $ if null ok
then Nothing
else Just $ (lbi,head ok))
- return $ case mmr of
- Nothing->(Nothing,bwns)
- Just a->(a,bwns)
fileGhcOptions :: (LocalBuildInfo,CabalBuildInfo) -> (ModuleName,[String])
fileGhcOptions (lbi,(bi,clbi,fp,ls))=(fst $ head ls,(ghcOptions lbi bi clbi fp))
View
6 test/Language/Haskell/BuildWrapper/CMDTests.hs
@@ -18,11 +18,11 @@ cmdTests=TestList $ map (\f->f CMDAPI) tests
data CMDAPI=CMDAPI
instance APIFacade CMDAPI where
- synchronize _ r= runAPI r "synchronize" []
- synchronize1 _ r fp= runAPI r "synchronize1" ["--file="++fp]
+ synchronize _ r ff= runAPI r "synchronize" ["--force="++(show ff)]
+ synchronize1 _ r ff fp= runAPI r "synchronize1" ["--force="++(show ff),"--file="++fp]
write _ r fp s= runAPI r "write" ["--file="++fp,"--contents="++s]
configure _ r t= runAPI r "configure" ["--cabaltarget="++(show t)]
- build _ r b= runAPI r "build" ["--output="++(show b)]
+ build _ r b wc= runAPI r "build" ["--output="++(show b),"--cabaltarget="++(show wc)]
getOutline _ r fp= runAPI r "outline" ["--file="++fp]
getTokenTypes _ r fp= runAPI r "tokentypes" ["--file="++fp]
getOccurrences _ r fp s= runAPI r "occurrences" ["--file="++fp,"--token="++s]
View
98 test/Language/Haskell/BuildWrapper/Tests.hs
@@ -35,11 +35,11 @@ tests= [
]
class APIFacade a where
- synchronize :: a -> FilePath -> IO (OpResult [FilePath])
- synchronize1 :: a -> FilePath -> FilePath -> IO (Maybe FilePath)
+ synchronize :: a -> FilePath -> Bool -> IO (OpResult [FilePath])
+ synchronize1 :: a -> FilePath -> Bool -> FilePath -> IO (Maybe FilePath)
write :: a -> FilePath -> FilePath -> String -> IO ()
configure :: a -> FilePath -> WhichCabal -> IO (OpResult Bool)
- build :: a -> FilePath -> Bool -> IO (OpResult Bool)
+ build :: a -> FilePath -> Bool -> WhichCabal -> IO (OpResult Bool)
getOutline :: a -> FilePath -> FilePath -> IO (OpResult [OutlineDef])
getTokenTypes :: a -> FilePath -> FilePath -> IO (OpResult [TokenDef])
getOccurrences :: a -> FilePath -> FilePath -> String -> IO (OpResult [TokenDef])
@@ -51,7 +51,7 @@ class APIFacade a where
testSynchronizeAll :: (APIFacade a)=> a -> Test
testSynchronizeAll api= TestLabel "testSynchronizeAll" (TestCase ( do
root<-createTestProject
- (fps,ns)<-synchronize api root
+ (fps,ns)<-synchronize api root False
assertBool "no file path on creation" (not $ null fps)
assertEqual "no cabal file" (testProjectName <.> ".cabal") (head fps)
assertBool "no A" (elem ("src" </> "A.hs") fps)
@@ -70,15 +70,15 @@ testConfigureErrors api= TestLabel "testConfigureErrors" (TestCase ( do
assertEqual ("no errors or warnings on no cabal") 1 (length nsNoCabal)
assertEqual ("wrong error on no cabal") (BWNote BWError "No cabal file found.\nPlease create a package description file <pkgname>.cabal\n" (BWLocation "" 0 1)) (head nsNoCabal)
- synchronize api root
+ synchronize api root False
(boolOK,nsOK)<-configure api root Target
assertBool ("configure returned false") boolOK
assertBool ("errors or warnings:"++show nsOK) (null nsOK)
let cf=testCabalFile root
let cfn=takeFileName cf
writeFile cf $ unlines ["version:0.1",
"build-type: Simple"]
- synchronize api root
+ synchronize api root False
(bool1,nsErrors1)<-configure api root Target
assertBool ("bool1 returned true") (not bool1)
assertEqual "no errors on no name" 2 (length nsErrors1)
@@ -88,7 +88,7 @@ testConfigureErrors api= TestLabel "testConfigureErrors" (TestCase ( do
writeFile cf $ unlines ["name: 4 P1",
"version:0.1",
"build-type: Simple"]
- synchronize api root
+ synchronize api root False
(bool2,nsErrors2)<-configure api root Target
assertBool ("bool2 returned true") (not bool2)
assertEqual "no errors on invalid name" 1 (length nsErrors2)
@@ -104,7 +104,7 @@ testConfigureErrors api= TestLabel "testConfigureErrors" (TestCase ( do
" exposed-modules: A",
" other-modules: B.C",
" build-depends: base, toto"]
- synchronize api root
+ synchronize api root False
(bool3,nsErrors3)<-configure api root Target
assertBool ("bool3 returned true") (not bool3)
assertEqual "no errors on unknown dependency" 1 (length nsErrors3)
@@ -120,7 +120,7 @@ testConfigureErrors api= TestLabel "testConfigureErrors" (TestCase ( do
" exposed-modules: A",
" other-modules: B.C",
" build-depends: base, toto, titi"]
- synchronize api root
+ synchronize api root False
(bool4,nsErrors4)<-configure api root Target
assertBool ("bool4 returned true") (not bool4)
assertEqual "no errors on unknown dependencies" 1 (length nsErrors4)
@@ -135,7 +135,7 @@ testConfigureErrors api= TestLabel "testConfigureErrors" (TestCase ( do
" hs-source-dirs: src",
" other-modules: B.D",
" build-depends: base"]
- synchronize api root
+ synchronize api root False
(bool5,nsErrors5)<-configure api root Target
assertBool ("bool5 returned true") (not bool5)
assertEqual "no errors on no main" 1 (length nsErrors5)
@@ -147,7 +147,7 @@ testConfigureErrors api= TestLabel "testConfigureErrors" (TestCase ( do
testConfigureWarnings :: (APIFacade a)=> a -> Test
testConfigureWarnings api = TestLabel "testConfigureWarnings" (TestCase ( do
root<-createTestProject
- synchronize api root
+ synchronize api root False
let cf=testCabalFile root
let cfn=takeFileName cf
writeFile cf $ unlines ["name: "++testProjectName,
@@ -161,7 +161,7 @@ testConfigureWarnings api = TestLabel "testConfigureWarnings" (TestCase ( do
" exposed-modules: A",
" other-modules: B.C",
" build-depends: base"]
- synchronize api root
+ synchronize api root False
(bool1,ns1)<- configure api root Target
assertBool ("returned false 1 "++ (show ns1)) bool1
assertEqual ("didn't return 1 warning") 1 (length ns1)
@@ -176,7 +176,7 @@ testConfigureWarnings api = TestLabel "testConfigureWarnings" (TestCase ( do
" exposed-modules: A",
" other-modules: B.C",
" build-depends: base"]
- synchronize api root
+ synchronize api root False
(bool2,ns2)<- configure api root Target
assertBool ("returned false 2 "++ (show ns2)) bool2
assertEqual ("didn't return 1 warning") 1 (length ns2)
@@ -193,7 +193,7 @@ testConfigureWarnings api = TestLabel "testConfigureWarnings" (TestCase ( do
" build-depends: base"]
writeFile ((takeDirectory cf) </> "Setup.hs") $ unlines ["import Distribution.Simple",
"main = defaultMain"]
- synchronize api root
+ synchronize api root False
(bool3,ns3)<- configure api root Target
assertBool ("returned false 3 "++ (show ns3)) bool3
assertEqual ("didn't return 1 warning") 1 (length ns3)
@@ -205,30 +205,30 @@ testConfigureWarnings api = TestLabel "testConfigureWarnings" (TestCase ( do
testBuildErrors :: (APIFacade a)=> a -> Test
testBuildErrors api = TestLabel "testBuildErrors" (TestCase ( do
root<-createTestProject
- synchronize api root
+ synchronize api root False
(boolOKc,nsOKc)<-configure api root Target
assertBool ("returned false on configure") boolOKc
assertBool ("errors or warnings on configure:"++show nsOKc) (null nsOKc)
- (boolOK,nsOK)<-build api root False
+ (boolOK,nsOK)<-build api root False Source
assertBool ("returned false on build") boolOK
assertBool ("errors or warnings on build:"++show nsOK) (null nsOK)
--let srcF=root </> "src"
let rel="src"</>"A.hs"
-- use api to write temp file
- write api root rel $ unlines ["module A where","import toto","fA=undefined"]
- --mf1<-runAPI root $ synchronize1 rel
+ writeFile (root </> rel) $ unlines ["module A where","import toto","fA=undefined"]
+ --mf1<-runAPI root $ synchronize1 rel False
--assertBool ("mf1 not just") (isJust mf1)
- (bool1,nsErrors1)<-build api root False
+ (bool1,nsErrors1)<-build api root False Source
assertBool ("returned true on bool1") (not bool1)
assertBool ("no errors or warnings on nsErrors") (not $ null nsErrors1)
let (nsError1:[])=nsErrors1
assertEqual "not proper error 1" (BWNote BWError "parse error on input `toto'\n" (BWLocation rel 2 8)) nsError1
-- write file and synchronize
writeFile (root </> "src"</>"A.hs")$ unlines ["module A where","import Toto","fA=undefined"]
--runAPI root $ write rel $ unlines ["module A where","import Toto","fA=undefined"]
- mf2<-synchronize1 api root rel
+ mf2<-synchronize1 api root False rel
assertBool ("mf2 not just") (isJust mf2)
- (bool2,nsErrors2)<-build api root False
+ (bool2,nsErrors2)<-build api root False Source
assertBool ("returned true on bool2") (not bool2)
assertBool ("no errors or warnings on nsErrors2") (not $ null nsErrors2)
let (nsError2:[])=nsErrors2
@@ -238,9 +238,9 @@ testBuildErrors api = TestLabel "testBuildErrors" (TestCase ( do
testBuildWarnings :: (APIFacade a)=> a -> Test
testBuildWarnings api = TestLabel "testBuildWarnings" (TestCase ( do
root<-createTestProject
- synchronize api root
+ synchronize api root False
--let cf=testCabalFile root
- write api root(testProjectName <.> ".cabal") $ unlines ["name: "++testProjectName,
+ writeFile (root </> (testProjectName <.> ".cabal")) $ unlines ["name: "++testProjectName,
"version:0.1",
"cabal-version: >= 1.8",
"build-type: Simple",
@@ -251,13 +251,12 @@ testBuildWarnings api = TestLabel "testBuildWarnings" (TestCase ( do
" build-depends: base",
" ghc-options: -Wall"]
--let srcF=root </> "src"
- (boolOK,nsOK)<-configure api root Target
+ (boolOK,nsOK)<-configure api root Source
assertBool ("returned false") boolOK
assertBool ("errors or warnings:"++show nsOK) (null nsOK)
let rel="src"</>"A.hs"
- write api root rel $ unlines ["module A where","import Data.List","fA=undefined"]
-
- (bool1,nsErrors1)<-build api root False
+ writeFile (root </> rel) $ unlines ["module A where","import Data.List","fA=undefined"]
+ (bool1,nsErrors1)<-build api root False Source
assertBool ("returned false on bool1") bool1
assertBool ("no errors or warnings on nsErrors1") (not $ null nsErrors1)
let (nsError1:nsError2:[])=nsErrors1
@@ -269,8 +268,8 @@ testBuildWarnings api = TestLabel "testBuildWarnings" (TestCase ( do
testBuildOutput :: (APIFacade a)=> a -> Test
testBuildOutput api = TestLabel "testBuildOutput" (TestCase ( do
root<-createTestProject
- synchronize api root
- build api root True
+ synchronize api root False
+ build api root True Source
let exeN=case os of
"mingw32"->(addExtension testProjectName "exe")
_->testProjectName
@@ -280,24 +279,24 @@ testBuildOutput api = TestLabel "testBuildOutput" (TestCase ( do
removeFile exeF
exeE2<-doesFileExist exeF
assertBool ("exe does still exist after deletion: "++exeF) (not exeE2)
- build api root False
+ build api root False Source
exeE3<-doesFileExist exeF
assertBool ("exe exists after build no output: "++exeF) (not exeE3)
))
testModuleNotInCabal :: (APIFacade a)=> a -> Test
testModuleNotInCabal api = TestLabel "testModuleNotInCabal" (TestCase ( do
root<-createTestProject
- synchronize api root
+ synchronize api root False
let rel="src"</>"A.hs"
write api root rel $ unlines ["module A where","import Auto","fA=undefined"]
let rel2="src"</>"Auto.hs"
putStrLn (root </> rel2)
writeFile (root </> rel2) $ unlines ["module Auto where","fAuto=undefined"]
- (fps,ns)<-synchronize api root
+ (fps,ns)<-synchronize api root False
putStrLn $ show fps
putStrLn $ show ns
- (bool1,nsErrors1)<-build api root False
+ (bool1,nsErrors1)<-build api root False Source
putStrLn $ show nsErrors1
assertBool ("returned false on bool1") bool1
assertBool ("errors or warnings on nsErrors1") (null nsErrors1)
@@ -306,7 +305,7 @@ testModuleNotInCabal api = TestLabel "testModuleNotInCabal" (TestCase ( do
--testAST :: Test
--testAST = TestLabel "testAST" (TestCase ( do
-- root<-createTestProject
--- runAPI root synchronize
+-- runAPI root synchronize False
-- (boolOKc,nsOKc)<-runAPI root $ configure Target
-- assertBool ("returned false on configure") boolOKc
-- assertBool ("errors or warnings on configure:"++show nsOKc) (null nsOKc)
@@ -326,7 +325,7 @@ testModuleNotInCabal api = TestLabel "testModuleNotInCabal" (TestCase ( do
testOutline :: (APIFacade a)=> a -> Test
testOutline api= TestLabel "testOutline" (TestCase ( do
root<-createTestProject
- synchronize api root
+ synchronize api root False
let rel="src"</>"A.hs"
-- use api to write temp file
write api root rel $ unlines [
@@ -408,7 +407,7 @@ testOutline api= TestLabel "testOutline" (TestCase ( do
testOutlinePreproc :: (APIFacade a)=> a -> Test
testOutlinePreproc api= TestLabel "testOutlinePreproc" (TestCase ( do
root<-createTestProject
- synchronize api root
+ synchronize api root False
let rel="src"</>"A.hs"
write api root (testProjectName <.> ".cabal") $ unlines ["name: "++testProjectName,
"version:0.1",
@@ -490,7 +489,7 @@ testOutlinePreproc api= TestLabel "testOutlinePreproc" (TestCase ( do
testPreviewTokenTypes :: (APIFacade a)=> a -> Test
testPreviewTokenTypes api= TestLabel "testPreviewTokenTypes" (TestCase ( do
root<-createTestProject
- synchronize api root
+ synchronize api root False
configure api root Target
let rel="src"</>"Main.hs"
write api root rel $ unlines [
@@ -517,7 +516,7 @@ testPreviewTokenTypes api= TestLabel "testPreviewTokenTypes" (TestCase ( do
testThingAtPoint :: (APIFacade a)=> a -> Test
testThingAtPoint api= TestLabel "testThingAtPoint" (TestCase ( do
root<-createTestProject
- synchronize api root
+ synchronize api root False
configure api root Target
let rel="src"</>"Main.hs"
write api root rel $ unlines [
@@ -543,15 +542,16 @@ testThingAtPoint api= TestLabel "testThingAtPoint" (TestCase ( do
testNamesInScope :: (APIFacade a)=> a -> Test
testNamesInScope api= TestLabel "testNamesInScope" (TestCase ( do
root<-createTestProject
- synchronize api root
- configure api root Target
+ synchronize api root False
+ configure api root Source
let rel="src"</>"Main.hs"
- write api root rel $ unlines [
+ writeFile (root </> rel) $ unlines [
"module Main where",
"import B.D",
"main=return $ map id \"toto\""
]
- build api root True
+ build api root True Source
+ synchronize api root False
--c1<-getClockTime
(mtts,nsErrors1)<-getNamesInScope api root rel
--c2<-getClockTime
@@ -567,8 +567,8 @@ testNamesInScope api= TestLabel "testNamesInScope" (TestCase ( do
testInPlaceReference :: (APIFacade a)=> a -> Test
testInPlaceReference api= TestLabel "testInPlaceReference" (TestCase ( do
root<-createTestProject
- synchronize api root
- write api root (testProjectName <.> ".cabal") $ unlines ["name: "++testProjectName,
+ synchronize api root False
+ writeFile (root </> (testProjectName <.> ".cabal")) $ unlines ["name: "++testProjectName,
"version:0.1",
"cabal-version: >= 1.8",
"build-type: Simple",
@@ -593,18 +593,18 @@ testInPlaceReference api= TestLabel "testInPlaceReference" (TestCase ( do
" build-depends: base, BWTest",
""
]
- (boolOKc,nsOKc)<-configure api root Target
+ (boolOKc,nsOKc)<-configure api root Source
assertBool ("returned false on configure") boolOKc
assertBool ("errors or warnings on configure:"++show nsOKc) (null nsOKc)
- (boolOK,nsOK)<-build api root False
+ (boolOK,nsOK)<-build api root False Source
assertBool ("returned false on build") boolOK
assertBool ("errors or warnings on build:"++show nsOK) (null nsOK)
))
testCabalComponents :: (APIFacade a)=> a -> Test
testCabalComponents api= TestLabel "testCabalComponents" (TestCase ( do
root<-createTestProject
- synchronize api root
+ synchronize api root False
(cps,nsOK)<-getCabalComponents api root
assertBool ("errors or warnings on getCabalComponents:"++show nsOK) (null nsOK)
assertEqual "not three components" 3 (length cps)
@@ -641,7 +641,7 @@ testCabalComponents api= TestLabel "testCabalComponents" (TestCase ( do
" buildable: False",
""
]
- synchronize api root
+ configure api root Source
(cps2,nsOK2)<-getCabalComponents api root
assertBool ("errors or warnings on getCabalComponents:"++show nsOK2) (null nsOK2)
assertEqual "not three components" 3 (length cps2)
@@ -654,7 +654,7 @@ testCabalComponents api= TestLabel "testCabalComponents" (TestCase ( do
testCabalDependencies :: (APIFacade a)=> a -> Test
testCabalDependencies api= TestLabel "testCabalDependencies" (TestCase ( do
root<-createTestProject
- synchronize api root
+ synchronize api root False
(cps,nsOK)<-getCabalDependencies api root
assertBool ("errors or warnings on getCabalDependencies:"++show nsOK) (null nsOK)
assertEqual "not two databases" 2 (length cps)

0 comments on commit 51daf91

Please sign in to comment.
Something went wrong with that request. Please try again.