diff options
author | Joey Hess <joey@kitenet.net> | 2013-02-27 15:35:07 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-02-27 15:38:21 -0400 |
commit | 38f9605143c5fc80f0948ec4e579a6b4598e70dd (patch) | |
tree | 1f93e7d42edcafc08e8fbc928fe7f6bcf1deb092 | |
parent | 52573c7b8cd253c43e92decce6cded80d8eca8f3 (diff) |
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.
-rw-r--r-- | Command/Test.hs | 33 | ||||
-rw-r--r-- | GitAnnex.hs | 2 | ||||
-rw-r--r-- | Makefile | 22 | ||||
-rw-r--r-- | Test.hs (renamed from test.hs) | 7 | ||||
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 4 | ||||
-rw-r--r-- | git-annex.cabal | 19 |
7 files changed, 55 insertions, 38 deletions
diff --git a/Command/Test.hs b/Command/Test.hs new file mode 100644 index 000000000..839829e0a --- /dev/null +++ b/Command/Test.hs @@ -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 diff --git a/GitAnnex.hs b/GitAnnex.hs index 8b8b4ad1b..278a66358 100644 --- a/GitAnnex.hs +++ b/GitAnnex.hs @@ -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] @@ -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. diff --git a/debian/changelog b/debian/changelog index 177da816a..fa36003af 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index 3b2af9cb5..a05104fa8 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -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. diff --git a/git-annex.cabal b/git-annex.cabal index d4298612e..3aad55e1a 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -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/ |