From d23d4ff9d994b4ac4de0ec133601aa03eb01a961 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 27 Feb 2013 15:48:26 -0400 Subject: break dependency cycle by special casing running of test command --- Command/Test.hs | 20 +++++--------------- Test.hs | 4 ++-- git-annex.hs | 9 +++++++-- 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 + - Copyright 2010-2013 Joey Hess - - 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 -- cgit v1.2.3