aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-27 15:48:26 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-27 15:51:28 -0400
commitd23d4ff9d994b4ac4de0ec133601aa03eb01a961 (patch)
treee61d9506ee3654a1d9d7811f2874b00d28677681
parentf812dd12aff241585bad2f4e064e44d795a53813 (diff)
break dependency cycle by special casing running of test command
-rw-r--r--Command/Test.hs20
-rw-r--r--Test.hs4
-rw-r--r--git-annex.hs9
3 files changed, 14 insertions, 19 deletions
diff --git a/Command/Test.hs b/Command/Test.hs
index 839829e0a..7ff9f2963 100644
--- a/Command/Test.hs
+++ b/Command/Test.hs
@@ -7,27 +7,17 @@
module Command.Test where
-import Common.Annex
import Command
-import qualified Command.Init
-import qualified Command.Add
-import qualified Command.Drop
-import qualified Command.Get
-import qualified Command.Move
-import qualified Command.Copy
-import qualified Command.Sync
-import qualified Command.Whereis
-import qualified Command.Fsck
-import qualified Test
def :: [Command]
-def = [noCommit $ noRepo showHelp $ dontCheck repoExists $
+def = [ dontCheck repoExists $
command "test" paramNothing seek "run built-in test suite"]
seek :: [CommandSeek]
seek = [withWords start]
+{- We don't actually run the test suite here because of a dependency loop.
+ - The main program notices when the command is test and runs it; this
+ - function is never run if that works. -}
start :: [String] -> CommandStart
-start _ = do
- liftIO $ Test.main
- stop
+start _ = error "Cannot specify any additional parameters when running test"
diff --git a/Test.hs b/Test.hs
index 6d010917e..eeba44dbb 100644
--- a/Test.hs
+++ b/Test.hs
@@ -941,8 +941,8 @@ unannexed = runchecks [checkregularfile, checkcontent, checkwritable]
prepare :: IO ()
prepare = do
- whenM (doesDirectoryExist) tmpdir $
- error $ "The temporary directory " ++ tmpdir ++ "already exists; cannot run test suite."
+ whenM (doesDirectoryExist tmpdir) $
+ error $ "The temporary directory " ++ tmpdir ++ " already exists; cannot run test suite."
-- While PATH is mostly avoided, the commit hook does run it,
-- and so does git_annex_output. Make sure that the just-built
diff --git a/git-annex.hs b/git-annex.hs
index 60ed6c15e..e2cd80ace 100644
--- a/git-annex.hs
+++ b/git-annex.hs
@@ -1,6 +1,6 @@
{- git-annex main program stub
-
- - Copyright 2010,2012 Joey Hess <joey@kitenet.net>
+ - Copyright 2010-2013 Joey Hess <joey@kitenet.net>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -10,6 +10,7 @@ import System.FilePath
import qualified GitAnnex
import qualified GitAnnexShell
+import qualified Test
main :: IO ()
main = run =<< getProgName
@@ -18,4 +19,8 @@ main = run =<< getProgName
| isshell n = go GitAnnexShell.run
| otherwise = go GitAnnex.run
isshell n = takeFileName n == "git-annex-shell"
- go a = a =<< getArgs
+ go a = do
+ ps <- getArgs
+ if ps == ["test"]
+ then Test.main
+ else a ps