embed test suite into git annex; available by running: git annex test
I have seen some other programs do this, and think it's pretty cool. Means you can test wherever it's deployed, as well as at build time. My other reason for doing it is less happy. Cabal's handling of test suites sucks, requiring duplicated info, and even when that's done, it fails to preprocess hsc files here. Building it in avoids that and avoids having to explicitly tell cabal to enable test suites, which would then make it link the test executable every time, which is unnecessarily slow. This also has the benefit that now "make fast test" does a max speed build and tests it.
This commit is contained in:
parent
092f6aa48d
commit
d1dbf266f6
7 changed files with 55 additions and 38 deletions
33
Command/Test.hs
Normal file
33
Command/Test.hs
Normal file
|
@ -0,0 +1,33 @@
|
|||
{- git-annex command
|
||||
-
|
||||
- Copyright 2013 Joey Hess <joey@kitenet.net>
|
||||
-
|
||||
- Licensed under the GNU GPL version 3 or higher.
|
||||
-}
|
||||
|
||||
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 $
|
||||
command "test" paramNothing seek "run built-in test suite"]
|
||||
|
||||
seek :: [CommandSeek]
|
||||
seek = [withWords start]
|
||||
|
||||
start :: [String] -> CommandStart
|
||||
start _ = do
|
||||
liftIO $ Test.main
|
||||
stop
|
|
@ -77,6 +77,7 @@ import qualified Command.WebApp
|
|||
import qualified Command.XMPPGit
|
||||
#endif
|
||||
#endif
|
||||
import qualified Command.Test
|
||||
|
||||
cmds :: [Command]
|
||||
cmds = concat
|
||||
|
@ -135,6 +136,7 @@ cmds = concat
|
|||
, Command.XMPPGit.def
|
||||
#endif
|
||||
#endif
|
||||
, Command.Test.def
|
||||
]
|
||||
|
||||
options :: [Option]
|
||||
|
|
22
Makefile
22
Makefile
|
@ -47,22 +47,8 @@ install: build-stamp install-docs
|
|||
ln -sf git-annex $(DESTDIR)$(PREFIX)/bin/git-annex-shell
|
||||
runghc Build/InstallDesktopFile.hs $(PREFIX)/bin/git-annex || true
|
||||
|
||||
test:
|
||||
# workaround for, apparently, a cabal bug
|
||||
hsc2hs Utility/Touch.hsc
|
||||
cabal configure --enable-tests
|
||||
cabal build
|
||||
rm -f Utility/Touch.hs
|
||||
cabal test
|
||||
|
||||
testcoverage:
|
||||
rm -f test.tix test
|
||||
$(GHC) $(GHCFLAGS) -outputdir tmp/testcoverage --make -fhpc test
|
||||
./test
|
||||
@echo ""
|
||||
@hpc report test --exclude=Main --exclude=QC
|
||||
@hpc markup test --exclude=Main --exclude=QC --destdir=.hpc >/dev/null
|
||||
@echo "(See .hpc/ for test coverage details.)"
|
||||
test: git-annex
|
||||
./git-annex test
|
||||
|
||||
# hothasktags chokes on some tempolate haskell etc, so ignore errors
|
||||
tags:
|
||||
|
@ -86,7 +72,7 @@ docs: $(mans)
|
|||
--exclude='bugs/*' --exclude='todo/*' --exclude='forum/*'
|
||||
|
||||
clean:
|
||||
rm -rf tmp dist git-annex $(mans) test configure *.tix .hpc \
|
||||
rm -rf tmp dist git-annex $(mans) configure *.tix .hpc \
|
||||
doc/.ikiwiki html dist build-stamp tags Build/SysConfig.hs
|
||||
|
||||
sdist: clean $(mans)
|
||||
|
@ -175,4 +161,4 @@ androidapp:
|
|||
$(MAKE) -C standalone/android
|
||||
cp standalone/android/source/term/bin/Term-debug.apk tmp/git-annex.apk
|
||||
|
||||
.PHONY: git-annex test install tags
|
||||
.PHONY: git-annex install tags
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
{- git-annex test suite
|
||||
-
|
||||
- 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.
|
||||
-}
|
||||
|
||||
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
||||
|
||||
module Test where
|
||||
|
||||
import Test.HUnit
|
||||
import Test.HUnit.Tools
|
||||
import Test.QuickCheck
|
||||
|
@ -939,6 +941,9 @@ unannexed = runchecks [checkregularfile, checkcontent, checkwritable]
|
|||
|
||||
prepare :: IO ()
|
||||
prepare = do
|
||||
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
|
||||
-- git annex is used.
|
6
debian/changelog
vendored
6
debian/changelog
vendored
|
@ -1,4 +1,4 @@
|
|||
git-annex (4.20130217) UNRELEASED; urgency=low
|
||||
git-annex (4.20130227) unstable; urgency=low
|
||||
|
||||
* annex.version is now set to 4 for direct mode repositories.
|
||||
* Should now fully support git repositories with core.symlinks=false;
|
||||
|
@ -24,8 +24,10 @@ git-annex (4.20130217) UNRELEASED; urgency=low
|
|||
log was out of date.
|
||||
* Makefile now builds using cabal, taking advantage of cabal's automatic
|
||||
detection of appropriate build flags.
|
||||
* test: The test suite is now built into the git-annex binary, and can
|
||||
be run at any time.
|
||||
|
||||
-- Joey Hess <joeyh@debian.org> Sun, 17 Feb 2013 16:42:16 -0400
|
||||
-- Joey Hess <joeyh@debian.org> Wed, 27 Feb 2013 14:07:24 -0400
|
||||
|
||||
git-annex (3.20130216) unstable; urgency=low
|
||||
|
||||
|
|
|
@ -506,6 +506,10 @@ subdirectories).
|
|||
With --force, even files whose content is not currently available will
|
||||
be rekeyed. Use with caution.
|
||||
|
||||
* test
|
||||
|
||||
This runs git-annex's built-in test suite.
|
||||
|
||||
* xmppgit
|
||||
|
||||
This command is used internally to perform git pulls over XMPP.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Name: git-annex
|
||||
Version: 4.20130217
|
||||
Version: 4.20130227
|
||||
Cabal-Version: >= 1.8
|
||||
License: GPL
|
||||
Maintainer: Joey Hess <joey@kitenet.net>
|
||||
|
@ -63,7 +63,7 @@ Executable git-annex
|
|||
Main-Is: git-annex.hs
|
||||
Build-Depends: MissingH, hslogger, directory, filepath,
|
||||
unix, containers, utf8-string, network (>= 2.0), mtl (>= 2.1.1),
|
||||
bytestring, old-locale, time,
|
||||
bytestring, old-locale, time, testpack, HUnit,
|
||||
extensible-exceptions, dataenc, SHA, process, json,
|
||||
base (>= 4.5 && < 4.8), monad-control, transformers-base, lifted-base,
|
||||
IfElse, text, QuickCheck >= 2.1, bloomfilter, edit-distance, process,
|
||||
|
@ -128,21 +128,6 @@ Executable git-annex
|
|||
Build-Depends: dns
|
||||
CPP-Options: -DWITH_DNS
|
||||
|
||||
Test-Suite test
|
||||
Type: exitcode-stdio-1.0
|
||||
Main-Is: test.hs
|
||||
Build-Depends: testpack, HUnit, MissingH, hslogger, directory, filepath,
|
||||
unix, containers, utf8-string, network, mtl (>= 2.1.1), bytestring,
|
||||
old-locale, time, extensible-exceptions, dataenc, SHA,
|
||||
process, json, base (>= 4.5 && < 4.7), monad-control,
|
||||
transformers-base, lifted-base, IfElse, text, QuickCheck (>= 2.1),
|
||||
bloomfilter, edit-distance, process, SafeSemaphore,
|
||||
uuid, random, regex-compat
|
||||
Other-Modules: Utility.Touch
|
||||
Include-Dirs: Utility
|
||||
C-Sources: Utility/libdiskfree.c
|
||||
GHC-Options: -threaded
|
||||
|
||||
source-repository head
|
||||
type: git
|
||||
location: git://git-annex.branchable.com/
|
||||
|
|
Loading…
Add table
Reference in a new issue