Skip to content
Snippets Groups Projects
Commit 046168d0 authored by Isaac Potoczny-Jones's avatar Isaac Potoczny-Jones
Browse files

added tests for reg scripts; some cleanup

parent 051034b5
No related merge requests found
...@@ -73,7 +73,9 @@ import Distribution.Setup ...@@ -73,7 +73,9 @@ import Distribution.Setup
import Distribution.Simple.Build ( build ) import Distribution.Simple.Build ( build )
import Distribution.Simple.SrcDist ( sdist ) import Distribution.Simple.SrcDist ( sdist )
import Distribution.Simple.Register ( register, unregister, import Distribution.Simple.Register ( register, unregister,
writeInstalledConfig, installedPkgConfigFile ) writeInstalledConfig, installedPkgConfigFile,
regScriptLocation, unregScriptLocation
)
import Distribution.Simple.Configure(LocalBuildInfo(..), getPersistBuildConfig, findProgram, import Distribution.Simple.Configure(LocalBuildInfo(..), getPersistBuildConfig, findProgram,
configure, writePersistBuildConfig, localBuildInfoFile) configure, writePersistBuildConfig, localBuildInfoFile)
...@@ -278,6 +280,8 @@ defaultMainWorker pkg_descr_in action args hooks ...@@ -278,6 +280,8 @@ defaultMainWorker pkg_descr_in action args hooks
try $ removeDirectoryRecursive buildPref try $ removeDirectoryRecursive buildPref
try $ removeFile installedPkgConfigFile try $ removeFile installedPkgConfigFile
try $ removeFile localBuildInfoFile try $ removeFile localBuildInfoFile
try $ removeFile regScriptLocation
try $ removeFile unregScriptLocation
removePreprocessedPackage pkg_descr currentDir (ppSuffixes pps) removePreprocessedPackage pkg_descr currentDir (ppSuffixes pps)
postHook postClean args verbose localbuildinfo postHook postClean args verbose localbuildinfo
......
...@@ -47,6 +47,8 @@ module Distribution.Simple.Register ( ...@@ -47,6 +47,8 @@ module Distribution.Simple.Register (
writeInstalledConfig, writeInstalledConfig,
removeInstalledConfig, removeInstalledConfig,
installedPkgConfigFile, installedPkgConfigFile,
regScriptLocation,
unregScriptLocation,
#ifdef DEBUG #ifdef DEBUG
hunitTests hunitTests
#endif #endif
...@@ -255,7 +257,7 @@ unregister pkg_descr lbi (user_unreg, verbose) = do ...@@ -255,7 +257,7 @@ unregister pkg_descr lbi (user_unreg, verbose) = do
die ("only unregistering with GHC and Hugs is implemented") die ("only unregistering with GHC and Hugs is implemented")
-- |Like rawSystemExit, but optionally emits to a script instead of -- |Like rawSystemExit, but optionally emits to a script instead of
-- exiting. -- exiting. FIX: chmod +x?
rawSystemEmit :: FilePath -- ^Script name rawSystemEmit :: FilePath -- ^Script name
-> Bool -- ^if true, emit, if false, run -> Bool -- ^if true, emit, if false, run
-> Int -- ^Verbosity -> Int -- ^Verbosity
...@@ -270,7 +272,7 @@ rawSystemEmit scriptName True verbosity path args ...@@ -270,7 +272,7 @@ rawSystemEmit scriptName True verbosity path args
++ "\n") ++ "\n")
>> putStrLn (path ++ concatMap (' ':) args) >> putStrLn (path ++ concatMap (' ':) args)
-- |Like rawSystemEmit, except it has string for pipeFrom -- |Like rawSystemEmit, except it has string for pipeFrom. FIX: chmod +x
rawSystemPipe :: FilePath -- ^Script location rawSystemPipe :: FilePath -- ^Script location
-> Int -- ^Verbosity -> Int -- ^Verbosity
-> String -- ^where to pipe from -> String -- ^where to pipe from
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
command? command?
** Add a flag to configure to specify where to put them? ** Add a flag to configure to specify where to put them?
* do we have to run configure before clean?
* Preprocessors * Preprocessors
** chain of preprocessors ** chain of preprocessors
** what other preprocessors can't unlit? ** what other preprocessors can't unlit?
......
...@@ -173,6 +173,14 @@ tests currDir comp compConf = [ ...@@ -173,6 +173,14 @@ tests currDir comp compConf = [
assertBool "sdist did not put the expected file in place" assertBool "sdist did not put the expected file in place"
doesFileExist "dist/src" >>= doesFileExist "dist/src" >>=
assertEqual "dist/src exists" False assertEqual "dist/src exists" False
assertCmd' compCmd "register --user" "pkg A, register failed"
assertCmd' compCmd "unregister --user" "pkg A, unregister failed"
assertCmd' compCmd ("register --user "++dumpScriptFlag)
"pkg A, register dump script failed"
assertCmd' compCmd ("unregister --user "++dumpScriptFlag)
"pkg A, register dump script failed"
assertCmd' "source" "register.sh" "reg script failed" -- FIX: chmod +x instead of source
assertCmd' "source" "unregister.sh" "unreg script failed" -- FIX: chmod +x instead of source
,TestLabel ("package A copy-prefix: " ++ compIdent) $ TestCase $ -- (uses above config) ,TestLabel ("package A copy-prefix: " ++ compIdent) $ TestCase $ -- (uses above config)
do let targetDir = ",tmp2" do let targetDir = ",tmp2"
assertCmd' compCmd ("copy --copy-prefix=" ++ targetDir) "copy --copy-prefix failed" assertCmd' compCmd ("copy --copy-prefix=" ++ targetDir) "copy --copy-prefix failed"
...@@ -186,7 +194,7 @@ tests currDir comp compConf = [ ...@@ -186,7 +194,7 @@ tests currDir comp compConf = [
removeDirectoryRecursive ",tmp" removeDirectoryRecursive ",tmp"
assertCmd' compCmd "install --user" "install --user failed" assertCmd' compCmd "install --user" "install --user failed"
libForA ",tmp" libForA ",tmp"
assertCmd "./setup unregister --user" "unregister failed" assertCmd' compCmd "unregister --user" "unregister failed"
-- HUnit -- HUnit
,TestLabel "testing the HUnit package" $ TestCase $ ,TestLabel "testing the HUnit package" $ TestCase $
do setCurrentDirectory $ (testdir `joinFileName` "HUnit-1.0") do setCurrentDirectory $ (testdir `joinFileName` "HUnit-1.0")
...@@ -263,7 +271,7 @@ tests currDir comp compConf = [ ...@@ -263,7 +271,7 @@ tests currDir comp compConf = [
,TestLabel ("testing the wash2hs package" ++ compIdent) $ TestCase $ ,TestLabel ("testing the wash2hs package" ++ compIdent) $ TestCase $
do setCurrentDirectory $ (testdir `joinFileName` "wash2hs") do setCurrentDirectory $ (testdir `joinFileName` "wash2hs")
testPrelude testPrelude
assertCmdFail "./setup configure --someUnknownFlag" assertCmdFail (compCmd ++ " configure --someUnknownFlag")
"wash2hs configure with unknown flag" "wash2hs configure with unknown flag"
assertConfigure ",tmp" assertConfigure ",tmp"
assertHaddock assertHaddock
...@@ -303,7 +311,7 @@ tests currDir comp compConf = [ ...@@ -303,7 +311,7 @@ tests currDir comp compConf = [
do setCurrentDirectory $ (testdir `joinFileName` "HSQL") do setCurrentDirectory $ (testdir `joinFileName` "HSQL")
system "make distclean" system "make distclean"
system "rm -rf /tmp/lib/HSQL" system "rm -rf /tmp/lib/HSQL"
when (comp== GHC) when (comp == GHC)
(system "ghc -cpp --make -i../.. Setup.lhs -o setup 2>out.build" >> return()) (system "ghc -cpp --make -i../.. Setup.lhs -o setup 2>out.build" >> return())
assertConfigure "/tmp" assertConfigure "/tmp"
doesFileExist "config.mk" >>= doesFileExist "config.mk" >>=
...@@ -338,6 +346,7 @@ tests currDir comp compConf = [ ...@@ -338,6 +346,7 @@ tests currDir comp compConf = [
GHC -> do checkTargetDir ghcTargetDir [".hi"] GHC -> do checkTargetDir ghcTargetDir [".hi"]
doesFileExist (ghcTargetDir `joinFileName` "libHStest-1.0.a") doesFileExist (ghcTargetDir `joinFileName` "libHStest-1.0.a")
>>= assertBool "library doesn't exist" >>= assertBool "library doesn't exist"
dumpScriptFlag = "-v11"
main :: IO () main :: IO ()
main = do putStrLn "compile successful" main = do putStrLn "compile successful"
putStrLn "-= Setup Tests =-" putStrLn "-= Setup Tests =-"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment