Skip to content

Commit

Permalink
added tests for reg scripts; some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxPolice committed Feb 15, 2005
1 parent 051034b commit 046168d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
6 changes: 5 additions & 1 deletion Distribution/Simple.hs
Expand Up @@ -73,7 +73,9 @@ import Distribution.Setup
import Distribution.Simple.Build ( build )
import Distribution.Simple.SrcDist ( sdist )
import Distribution.Simple.Register ( register, unregister,
writeInstalledConfig, installedPkgConfigFile )
writeInstalledConfig, installedPkgConfigFile,
regScriptLocation, unregScriptLocation
)

import Distribution.Simple.Configure(LocalBuildInfo(..), getPersistBuildConfig, findProgram,
configure, writePersistBuildConfig, localBuildInfoFile)
Expand Down Expand Up @@ -278,6 +280,8 @@ defaultMainWorker pkg_descr_in action args hooks
try $ removeDirectoryRecursive buildPref
try $ removeFile installedPkgConfigFile
try $ removeFile localBuildInfoFile
try $ removeFile regScriptLocation
try $ removeFile unregScriptLocation
removePreprocessedPackage pkg_descr currentDir (ppSuffixes pps)
postHook postClean args verbose localbuildinfo

Expand Down
6 changes: 4 additions & 2 deletions Distribution/Simple/Register.hs
Expand Up @@ -47,6 +47,8 @@ module Distribution.Simple.Register (
writeInstalledConfig,
removeInstalledConfig,
installedPkgConfigFile,
regScriptLocation,
unregScriptLocation,
#ifdef DEBUG
hunitTests
#endif
Expand Down Expand Up @@ -255,7 +257,7 @@ unregister pkg_descr lbi (user_unreg, verbose) = do
die ("only unregistering with GHC and Hugs is implemented")

-- |Like rawSystemExit, but optionally emits to a script instead of
-- exiting.
-- exiting. FIX: chmod +x?
rawSystemEmit :: FilePath -- ^Script name
-> Bool -- ^if true, emit, if false, run
-> Int -- ^Verbosity
Expand All @@ -270,7 +272,7 @@ rawSystemEmit scriptName True verbosity path args
++ "\n")
>> 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
-> Int -- ^Verbosity
-> String -- ^where to pipe from
Expand Down
2 changes: 2 additions & 0 deletions TODO
Expand Up @@ -30,6 +30,8 @@
command?
** Add a flag to configure to specify where to put them?

* do we have to run configure before clean?

* Preprocessors
** chain of preprocessors
** what other preprocessors can't unlit?
Expand Down
15 changes: 12 additions & 3 deletions tests/ModuleTest.hs
Expand Up @@ -173,6 +173,14 @@ tests currDir comp compConf = [
assertBool "sdist did not put the expected file in place"
doesFileExist "dist/src" >>=
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)
do let targetDir = ",tmp2"
assertCmd' compCmd ("copy --copy-prefix=" ++ targetDir) "copy --copy-prefix failed"
Expand All @@ -186,7 +194,7 @@ tests currDir comp compConf = [
removeDirectoryRecursive ",tmp"
assertCmd' compCmd "install --user" "install --user failed"
libForA ",tmp"
assertCmd "./setup unregister --user" "unregister failed"
assertCmd' compCmd "unregister --user" "unregister failed"
-- HUnit
,TestLabel "testing the HUnit package" $ TestCase $
do setCurrentDirectory $ (testdir `joinFileName` "HUnit-1.0")
Expand Down Expand Up @@ -263,7 +271,7 @@ tests currDir comp compConf = [
,TestLabel ("testing the wash2hs package" ++ compIdent) $ TestCase $
do setCurrentDirectory $ (testdir `joinFileName` "wash2hs")
testPrelude
assertCmdFail "./setup configure --someUnknownFlag"
assertCmdFail (compCmd ++ " configure --someUnknownFlag")
"wash2hs configure with unknown flag"
assertConfigure ",tmp"
assertHaddock
Expand Down Expand Up @@ -303,7 +311,7 @@ tests currDir comp compConf = [
do setCurrentDirectory $ (testdir `joinFileName` "HSQL")
system "make distclean"
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())
assertConfigure "/tmp"
doesFileExist "config.mk" >>=
Expand Down Expand Up @@ -338,6 +346,7 @@ tests currDir comp compConf = [
GHC -> do checkTargetDir ghcTargetDir [".hi"]
doesFileExist (ghcTargetDir `joinFileName` "libHStest-1.0.a")
>>= assertBool "library doesn't exist"
dumpScriptFlag = "-v11"
main :: IO ()
main = do putStrLn "compile successful"
putStrLn "-= Setup Tests =-"
Expand Down

0 comments on commit 046168d

Please sign in to comment.