module Darcs.Commands.Test ( test ) where
import System.Exit ( exitWith )
import Darcs.Commands ( DarcsCommand(..), nodefaults, putInfo )
import Darcs.Arguments ( DarcsFlag(Test)
, leaveTestDir
, workingRepoDir
)
import Darcs.Repository ( Repository, amInHashedRepository, withRepository,
testRecorded, RepoJob(..) )
import Darcs.Patch ( RepoPatch )
import Darcs.Patch.Apply( ApplyState )
import Printer ( text )
import Storage.Hashed.Tree( Tree )
#include "gadts.h"
testDescription :: String
testDescription = "Run regression test."
testHelp :: String
testHelp =
"If a regression test is defined (see `darcs setpref') it will be run.\n"
test :: DarcsCommand
test = DarcsCommand {commandProgramName = "darcs",
commandName = "test",
commandHelp = testHelp,
commandDescription = testDescription,
commandExtraArgs = 0,
commandExtraArgHelp = [],
commandCommand = testCmd,
commandPrereq = amInHashedRepository,
commandGetArgPossibilities = return [],
commandArgdefaults = nodefaults,
commandAdvancedOptions = [],
commandBasicOptions = [ leaveTestDir,
workingRepoDir
]}
testCmd :: [DarcsFlag] -> [String] -> IO ()
testCmd opts _ = withRepository (Test:opts) (RepoJob (test' opts))
test'
:: forall p C(r u t) . (RepoPatch p, ApplyState p ~ Tree)
=> [DarcsFlag] -> Repository p C(r u t) -> IO ()
test' opts repository = do
putInfo opts $ text "Running test on current repository state."
rc <- testRecorded repository
exitWith rc