break dependency cycle by special casing running of test command

This commit is contained in:
Joey Hess 2013-02-27 15:48:26 -04:00
parent 2b805b9589
commit 3a32454b13
3 changed files with 14 additions and 19 deletions

View file

@ -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"

View file

@ -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

View file

@ -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