Commit c9409ffe authored by ijones's avatar ijones
Browse files

mostly testing, some tweaks to install and build

** Added some tests
** moved build output to dist/build
** helped ar find objects
** eurohaskell todo list
parent babef8d0
......@@ -60,7 +60,14 @@ import qualified Distribution.Simple.Utils(hunitTests)
import Distribution.Simple.Configure()
import Distribution.Simple.Register()
import HUnit(runTestTT, Test(..))
-- base
import Control.Monad(when)
import Directory(setCurrentDirectory, doesFileExist,
doesDirectoryExist, removeDirectory)
import System.Cmd(system)
import System.Exit(ExitCode(..))
import HUnit(runTestTT, Test(..), assertBool)
label t = "-= " ++ t ++ " =-"
......@@ -69,13 +76,34 @@ runTestTT' (TestLabel l t)
= putStrLn (label l) >> runTestTT t
runTestTT' t = runTestTT t
tests = [TestCase $
do setCurrentDirectory "test"
dirE1 <- doesDirectoryExist ",tmp"
when dirE1 (system "rm -r ,tmp">>return())
system "ls"
system "./setup configure --prefix=,tmp"
let targetDir = ",tmp/lib/test-1.0/"
system "./setup build"
instRetCode <- system "./setup install --user"
dirE <- doesDirectoryExist targetDir
assertBool "target dir exists" dirE
let files = ["A.hs", "B/A.hs", "libHStest-1.0.a"]
allFilesE <- sequence [doesFileExist (targetDir ++ t)
| t <- files]
sequence [assertBool ("target file missing: " ++ targetDir ++ f) e
| (e, f) <- zip allFilesE files]
assertBool "install returned error code" (instRetCode == ExitSuccess)
]
main :: IO ()
main = do putStrLn "compile successful"
putStrLn "-= Setup Tests =-"
setupTests <- Distribution.Setup.hunitTests
mapM runTestTT' setupTests
Distribution.Simple.Utils.hunitTests >>= runTestTT'
runTestTT' $ TestList tests
return ()
-- Local Variables:
......
......@@ -49,9 +49,12 @@ import Distribution.Setup (CompilerFlavor(..), compilerFlavor, compilerPath)
import Distribution.Package (PackageDescription(..), showPackageId)
import Distribution.Simple.Configure (LocalBuildInfo, compiler)
import Distribution.Simple.Utils (rawSystemExit, setupMessage,
die, rawSystemPathExit)
die, rawSystemPathExit,
pathSeperatorStr, split, createIfNotExists)
import Control.Monad (when)
import Data.List(intersperse)
-- -----------------------------------------------------------------------------
-- Build the library
......@@ -59,9 +62,10 @@ import Control.Monad (when)
build :: PackageDescription -> LocalBuildInfo -> IO ()
build pkg_descr lbi = do
setupMessage "Building" pkg_descr
let pref = ("dist" ++ pathSeperatorStr ++ "build")
createIfNotExists True pref
case compilerFlavor (compiler lbi) of
GHC -> buildGHC pkg_descr lbi
GHC -> buildGHC pref pkg_descr lbi
NHC -> buildNHC pkg_descr lbi
_ -> die ("only building with GHC is implemented")
......@@ -75,11 +79,11 @@ buildNHC pkg_descr lbi = do
++ allModules pkg_descr)
-- |Building for GHC
buildGHC :: PackageDescription -> LocalBuildInfo -> IO ()
buildGHC pkg_descr lbi = do
buildGHC :: FilePath -> PackageDescription -> LocalBuildInfo -> IO ()
buildGHC pref pkg_descr lbi = do
-- first, build the modules
let args = constructGHCCmdLine pkg_descr lbi
let args = constructGHCCmdLine pref pkg_descr lbi
rawSystemExit (compilerPath (compiler lbi)) args
-- build any C sources
......@@ -87,14 +91,14 @@ buildGHC pkg_descr lbi = do
rawSystemExit (compilerPath (compiler lbi)) (cSources pkg_descr)
-- now, build the library
let objs = map (++objsuffix) (allModules pkg_descr)
let objs = map (++objsuffix) (map dotToSep (allModules pkg_descr))
lib = mkLibName (showPackageId (package pkg_descr))
rawSystemPathExit "ar" (["q", lib] ++ objs)
rawSystemPathExit "ar" (["q", lib] ++ (map (pref ++) objs))
constructGHCCmdLine :: PackageDescription -> LocalBuildInfo -> [String]
constructGHCCmdLine pkg_descr _ =
constructGHCCmdLine :: FilePath -> PackageDescription -> LocalBuildInfo -> [String]
constructGHCCmdLine pref pkg_descr _ =
[
"--make",
"--make", "-odir " ++ pref, "-hidir " ++ pref,
"-package-name", showPackageId (package pkg_descr)
]
++ extensionsToGHCFlag (extensions pkg_descr)
......@@ -117,4 +121,7 @@ objsuffix = ".o"
mkLibName :: String -> String
mkLibName lib = "libHS" ++ lib ++ ".a"
-- ToDo: includes, includeDirs
dotToSep :: String -> String
dotToSep s = concat $ intersperse pathSeperatorStr (split '.' s)
-- Todo: includes, includeDirs
......@@ -54,7 +54,8 @@ module Distribution.Simple.Utils (
rawSystemExit,
rawSystemPathExit,
moveSources,
hunitTests
hunitTests,
createIfNotExists
) where
import Distribution.Package
......
* euroHaskell
** setup test suite to run on --push?
** Possibly create a (native?) zib library?
** port code to windows
** test / port code for Hugs and nhc
** ./Setup.lhs build for nhc
** nhc-pkg (see old package manager code)
** hugs-pkg
** make -Wall clean
** better command-line parsing interface
** ./Setup.lhs bdist
* Code
** Write top-level Setup test cases (like "make check" under the test directory)
......
......@@ -2,6 +2,7 @@ all: tests
tests:
ghc -Wall --make -i../:/usr/local/src/HUnit-1.0 Distribution/ModuleTest -o moduleTest
cd test && make
check: tests
./moduleTest
......
module B.A where
a = 42 :: Int
main = print a
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment