git-annex/configure.hs

45 lines
1 KiB
Haskell
Raw Normal View History

{- Checks system configuration and generates SysConfig.hs. -}
import System.Directory
2011-01-20 00:02:48 +00:00
import TestConfig
2010-11-18 18:07:22 +00:00
2010-11-27 21:31:20 +00:00
tests :: [TestCase]
tests = [
2011-01-20 00:02:48 +00:00
testCp "cp_a" "-a"
, testCp "cp_p" "-p"
, testCp "cp_reflink_auto" "--reflink=auto"
, TestCase "uuid generator" $ selectCmd "uuid" ["uuid", "uuidgen"]
2011-02-08 23:31:27 +00:00
, TestCase "sha1sum" $ requireCmd "sha1sum" "sha1sum </dev/null"
2011-01-20 00:02:48 +00:00
, TestCase "xargs -0" $ requireCmd "xargs_0" "xargs -0 </dev/null"
, TestCase "rsync" $ requireCmd "rsync" "rsync --version >/dev/null"
]
tmpDir :: String
tmpDir = "tmp"
testFile :: String
testFile = tmpDir ++ "/testfile"
2011-01-20 00:02:48 +00:00
testCp :: ConfigKey -> String -> TestCase
testCp k option = TestCase cmd $ testCmd k run
where
2011-01-20 00:02:48 +00:00
cmd = "cp " ++ option
run = cmd ++ " " ++ testFile ++ " " ++ testFile ++ ".new"
2010-11-18 18:11:18 +00:00
setup :: IO ()
setup = do
createDirectoryIfMissing True tmpDir
writeFile testFile "test file contents"
2010-11-18 18:11:18 +00:00
cleanup :: IO ()
cleanup = do
removeDirectoryRecursive tmpDir
2010-11-18 18:11:18 +00:00
main :: IO ()
main = do
setup
config <- runTests tests
writeSysConfig config
2010-11-18 18:11:18 +00:00
cleanup