2011-01-07 00:09:49 +00:00
|
|
|
{- git-annex test suite
|
|
|
|
-
|
2011-01-08 20:09:17 +00:00
|
|
|
- Copyright 2010,2011 Joey Hess <joey@kitenet.net>
|
2011-01-07 00:09:49 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
2010-11-02 21:08:16 +00:00
|
|
|
import Test.HUnit
|
|
|
|
import Test.HUnit.Tools
|
2011-04-25 19:28:41 +00:00
|
|
|
import Test.QuickCheck
|
|
|
|
|
2011-01-07 00:09:49 +00:00
|
|
|
import System.Posix.Directory (changeWorkingDirectory)
|
|
|
|
import System.Posix.Files
|
2011-12-09 05:57:13 +00:00
|
|
|
import Control.Exception (bracket_, bracket, throw)
|
2011-01-07 00:09:49 +00:00
|
|
|
import System.IO.Error
|
2011-01-07 06:14:48 +00:00
|
|
|
import System.Posix.Env
|
2011-01-07 01:39:26 +00:00
|
|
|
import qualified Control.Exception.Extensible as E
|
2011-01-12 05:58:23 +00:00
|
|
|
import qualified Data.Map as M
|
2011-02-09 04:12:45 +00:00
|
|
|
import System.IO.HVFS (SystemFS(..))
|
2011-12-21 06:32:40 +00:00
|
|
|
import Text.JSON
|
2010-11-02 21:08:16 +00:00
|
|
|
|
2011-10-04 02:24:57 +00:00
|
|
|
import Common
|
2011-08-22 20:14:12 +00:00
|
|
|
|
2011-10-04 02:24:57 +00:00
|
|
|
import qualified Utility.SafeCommand
|
2011-01-11 19:43:29 +00:00
|
|
|
import qualified Annex
|
2011-10-15 21:47:03 +00:00
|
|
|
import qualified Annex.UUID
|
2011-01-11 19:43:29 +00:00
|
|
|
import qualified Backend
|
2011-12-13 19:05:07 +00:00
|
|
|
import qualified Git.Config
|
|
|
|
import qualified Git.Construct
|
2011-12-13 19:22:43 +00:00
|
|
|
import qualified Git.Filename
|
2011-01-07 00:26:57 +00:00
|
|
|
import qualified Locations
|
2011-06-14 01:51:52 +00:00
|
|
|
import qualified Types.Backend
|
2011-01-26 01:49:04 +00:00
|
|
|
import qualified Types
|
2011-01-07 00:26:57 +00:00
|
|
|
import qualified GitAnnex
|
2011-10-15 20:21:08 +00:00
|
|
|
import qualified Logs.Location
|
|
|
|
import qualified Logs.UUIDBased
|
|
|
|
import qualified Logs.Trust
|
|
|
|
import qualified Logs.Remote
|
2011-03-27 20:58:28 +00:00
|
|
|
import qualified Remote
|
2011-01-12 05:58:23 +00:00
|
|
|
import qualified Command.DropUnused
|
2011-06-14 01:51:52 +00:00
|
|
|
import qualified Types.Key
|
2011-04-17 05:13:21 +00:00
|
|
|
import qualified Config
|
2011-04-21 20:56:24 +00:00
|
|
|
import qualified Crypto
|
2011-08-22 20:14:12 +00:00
|
|
|
import qualified Utility.Path
|
2011-09-28 19:17:45 +00:00
|
|
|
import qualified Utility.FileMode
|
2011-12-21 03:20:36 +00:00
|
|
|
import qualified Utility.Gpg
|
|
|
|
import qualified Build.SysConfig
|
2011-12-23 00:14:35 +00:00
|
|
|
import qualified Utility.Format
|
2010-11-02 20:49:35 +00:00
|
|
|
|
2011-04-25 19:28:41 +00:00
|
|
|
-- for quickcheck
|
2011-06-14 01:51:52 +00:00
|
|
|
instance Arbitrary Types.Key.Key where
|
2011-04-25 19:28:41 +00:00
|
|
|
arbitrary = do
|
|
|
|
n <- arbitrary
|
|
|
|
b <- elements ['A'..'Z']
|
2011-07-15 07:12:05 +00:00
|
|
|
return Types.Key.Key {
|
2011-06-14 01:51:52 +00:00
|
|
|
Types.Key.keyName = n,
|
|
|
|
Types.Key.keyBackendName = [b],
|
|
|
|
Types.Key.keySize = Nothing,
|
|
|
|
Types.Key.keyMtime = Nothing
|
2011-04-25 19:28:41 +00:00
|
|
|
}
|
|
|
|
|
2011-01-07 06:14:48 +00:00
|
|
|
main :: IO ()
|
2011-01-07 01:39:26 +00:00
|
|
|
main = do
|
2011-01-07 18:06:32 +00:00
|
|
|
prepare
|
2011-01-26 20:20:28 +00:00
|
|
|
r <- runVerboseTests $ TestList [quickcheck, blackbox]
|
2011-01-07 01:39:26 +00:00
|
|
|
cleanup tmpdir
|
2011-01-07 06:14:48 +00:00
|
|
|
propigate r
|
|
|
|
|
|
|
|
propigate :: (Counts, Int) -> IO ()
|
2011-04-27 00:08:36 +00:00
|
|
|
propigate (Counts { errors = e , failures = f }, _)
|
|
|
|
| e+f > 0 = error "failed"
|
2011-01-07 06:14:48 +00:00
|
|
|
| otherwise = return ()
|
2011-01-07 00:09:49 +00:00
|
|
|
|
2011-01-26 20:20:28 +00:00
|
|
|
quickcheck :: Test
|
|
|
|
quickcheck = TestLabel "quickcheck" $ TestList
|
2011-12-23 00:14:35 +00:00
|
|
|
[ qctest "prop_idempotent_deencode_git" Git.Filename.prop_idempotent_deencode
|
|
|
|
, qctest "prop_idempotent_deencode" Utility.Format.prop_idempotent_deencode
|
2011-01-07 00:26:57 +00:00
|
|
|
, qctest "prop_idempotent_fileKey" Locations.prop_idempotent_fileKey
|
2011-06-14 01:51:52 +00:00
|
|
|
, qctest "prop_idempotent_key_read_show" Types.Key.prop_idempotent_key_read_show
|
2011-08-22 20:14:12 +00:00
|
|
|
, qctest "prop_idempotent_shellEscape" Utility.SafeCommand.prop_idempotent_shellEscape
|
|
|
|
, qctest "prop_idempotent_shellEscape_multiword" Utility.SafeCommand.prop_idempotent_shellEscape_multiword
|
2011-10-15 20:21:08 +00:00
|
|
|
, qctest "prop_idempotent_configEscape" Logs.Remote.prop_idempotent_configEscape
|
2011-08-22 20:14:12 +00:00
|
|
|
, qctest "prop_parentDir_basics" Utility.Path.prop_parentDir_basics
|
|
|
|
|
|
|
|
, qctest "prop_relPathDirToFile_basics" Utility.Path.prop_relPathDirToFile_basics
|
2011-04-17 05:13:21 +00:00
|
|
|
, qctest "prop_cost_sane" Config.prop_cost_sane
|
2011-04-21 20:56:24 +00:00
|
|
|
, qctest "prop_hmacWithCipher_sane" Crypto.prop_hmacWithCipher_sane
|
2011-10-15 20:21:08 +00:00
|
|
|
, qctest "prop_TimeStamp_sane" Logs.UUIDBased.prop_TimeStamp_sane
|
|
|
|
, qctest "prop_addLog_sane" Logs.UUIDBased.prop_addLog_sane
|
2010-11-02 21:08:16 +00:00
|
|
|
]
|
|
|
|
|
2011-01-26 20:20:28 +00:00
|
|
|
blackbox :: Test
|
|
|
|
blackbox = TestLabel "blackbox" $ TestList
|
2011-01-07 01:39:26 +00:00
|
|
|
-- test order matters, later tests may rely on state from earlier
|
2011-01-07 00:09:49 +00:00
|
|
|
[ test_init
|
|
|
|
, test_add
|
2011-10-31 19:18:41 +00:00
|
|
|
, test_reinject
|
2011-01-07 01:39:26 +00:00
|
|
|
, test_unannex
|
|
|
|
, test_drop
|
2011-01-07 02:22:09 +00:00
|
|
|
, test_get
|
2011-01-07 05:02:06 +00:00
|
|
|
, test_move
|
2011-01-07 06:14:48 +00:00
|
|
|
, test_copy
|
2011-01-07 18:06:32 +00:00
|
|
|
, test_lock
|
|
|
|
, test_edit
|
|
|
|
, test_fix
|
2011-01-11 22:50:18 +00:00
|
|
|
, test_trust
|
2011-01-11 23:34:28 +00:00
|
|
|
, test_fsck
|
2011-01-12 01:11:32 +00:00
|
|
|
, test_migrate
|
2011-01-12 05:58:23 +00:00
|
|
|
, test_unused
|
2011-12-20 20:26:39 +00:00
|
|
|
, test_addurl
|
|
|
|
, test_describe
|
|
|
|
, test_find
|
|
|
|
, test_merge
|
|
|
|
, test_status
|
2011-12-20 21:31:25 +00:00
|
|
|
, test_version
|
2011-12-20 20:26:39 +00:00
|
|
|
, test_sync
|
2011-12-20 20:31:59 +00:00
|
|
|
, test_map
|
2011-12-20 21:31:25 +00:00
|
|
|
, test_uninit
|
|
|
|
, test_upgrade
|
|
|
|
, test_whereis
|
2011-12-20 19:13:36 +00:00
|
|
|
, test_hook_remote
|
2011-12-20 19:17:56 +00:00
|
|
|
, test_directory_remote
|
|
|
|
, test_rsync_remote
|
2011-12-21 17:50:33 +00:00
|
|
|
, test_bup_remote
|
2011-12-21 03:20:36 +00:00
|
|
|
, test_crypto
|
2011-01-07 00:09:49 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
test_init :: Test
|
2011-01-07 18:06:32 +00:00
|
|
|
test_init = "git-annex init" ~: TestCase $ innewrepo $ do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "init" [reponame] @? "init failed"
|
2011-01-07 00:09:49 +00:00
|
|
|
where
|
|
|
|
reponame = "test repo"
|
|
|
|
|
|
|
|
test_add :: Test
|
2011-07-10 17:52:53 +00:00
|
|
|
test_add = "git-annex add" ~: TestList [basic, sha1dup, subdirs]
|
2011-01-27 18:01:30 +00:00
|
|
|
where
|
|
|
|
-- this test case runs in the main repo, to set up a basic
|
|
|
|
-- annexed file that later tests will use
|
|
|
|
basic = TestCase $ inmainrepo $ do
|
|
|
|
writeFile annexedfile $ content annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "add" [annexedfile] @? "add failed"
|
2011-01-27 18:01:30 +00:00
|
|
|
annexed_present annexedfile
|
2011-10-31 16:47:13 +00:00
|
|
|
writeFile sha1annexedfile $ content sha1annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "add" [sha1annexedfile, "--backend=SHA1"] @? "add with SHA1 failed"
|
2011-10-31 16:47:13 +00:00
|
|
|
annexed_present sha1annexedfile
|
2011-12-21 18:10:36 +00:00
|
|
|
checkbackend sha1annexedfile backendSHA1
|
|
|
|
writeFile wormannexedfile $ content wormannexedfile
|
|
|
|
git_annex "add" [wormannexedfile, "--backend=WORM"] @? "add with WORM failed"
|
|
|
|
annexed_present wormannexedfile
|
|
|
|
checkbackend wormannexedfile backendWORM
|
|
|
|
boolSystem "git" [Params "rm --force -q", File wormannexedfile] @? "git rm failed"
|
2011-01-27 18:01:30 +00:00
|
|
|
writeFile ingitfile $ content ingitfile
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Param "add", File ingitfile] @? "git add failed"
|
|
|
|
boolSystem "git" [Params "commit -q -a -m commit"] @? "git commit failed"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "add" [ingitfile] @? "add ingitfile should be no-op"
|
2011-01-27 18:01:30 +00:00
|
|
|
unannexed ingitfile
|
|
|
|
sha1dup = TestCase $ intmpclonerepo $ do
|
|
|
|
writeFile sha1annexedfiledup $ content sha1annexedfiledup
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "add" [sha1annexedfiledup, "--backend=SHA1"] @? "add of second file with same SHA1 failed"
|
2011-01-27 18:01:30 +00:00
|
|
|
annexed_present sha1annexedfiledup
|
|
|
|
annexed_present sha1annexedfile
|
2011-07-10 17:52:53 +00:00
|
|
|
subdirs = TestCase $ intmpclonerepo $ do
|
|
|
|
createDirectory "dir"
|
|
|
|
writeFile "dir/foo" $ content annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "add" ["dir"] @? "add of subdir failed"
|
2011-07-10 17:52:53 +00:00
|
|
|
createDirectory "dir2"
|
|
|
|
writeFile "dir2/foo" $ content annexedfile
|
|
|
|
changeWorkingDirectory "dir"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "add" ["../dir2"] @? "add of ../subdir failed"
|
2011-01-07 00:09:49 +00:00
|
|
|
|
2011-10-31 19:18:41 +00:00
|
|
|
test_reinject :: Test
|
|
|
|
test_reinject = "git-annex reinject/fromkey" ~: TestCase $ intmpclonerepo $ do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "drop" ["--force", sha1annexedfile] @? "drop failed"
|
2011-01-11 23:59:11 +00:00
|
|
|
writeFile tmp $ content sha1annexedfile
|
2011-06-14 01:51:52 +00:00
|
|
|
r <- annexeval $ Types.Backend.getKey backendSHA1 tmp
|
2011-03-16 02:53:14 +00:00
|
|
|
let key = show $ fromJust r
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "reinject" [tmp, sha1annexedfile] @? "reinject failed"
|
|
|
|
git_annex "fromkey" [key, sha1annexedfiledup] @? "fromkey failed"
|
2011-10-31 16:47:13 +00:00
|
|
|
annexed_present sha1annexedfiledup
|
2011-01-11 23:59:11 +00:00
|
|
|
where
|
|
|
|
tmp = "tmpfile"
|
|
|
|
|
2011-01-07 01:39:26 +00:00
|
|
|
test_unannex :: Test
|
2011-01-08 19:00:04 +00:00
|
|
|
test_unannex = "git-annex unannex" ~: TestList [nocopy, withcopy]
|
|
|
|
where
|
|
|
|
nocopy = "no content" ~: intmpclonerepo $ do
|
2011-01-08 19:14:41 +00:00
|
|
|
annexed_notpresent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "unannex" [annexedfile] @? "unannex failed with no copy"
|
2011-01-08 19:14:41 +00:00
|
|
|
annexed_notpresent annexedfile
|
2011-02-13 18:17:02 +00:00
|
|
|
withcopy = "with content" ~: intmpclonerepo $ do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get failed"
|
2011-01-08 19:14:41 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "unannex" [annexedfile, sha1annexedfile] @? "unannex failed"
|
2011-01-08 19:00:04 +00:00
|
|
|
unannexed annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "unannex" [annexedfile] @? "unannex failed on non-annexed file"
|
2011-01-08 19:00:04 +00:00
|
|
|
unannexed annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "unannex" [ingitfile] @? "unannex ingitfile should be no-op"
|
2011-01-08 19:00:04 +00:00
|
|
|
unannexed ingitfile
|
2011-01-07 01:39:26 +00:00
|
|
|
|
|
|
|
test_drop :: Test
|
2011-01-27 00:03:03 +00:00
|
|
|
test_drop = "git-annex drop" ~: TestList [noremote, withremote, untrustedremote]
|
2011-01-07 18:06:32 +00:00
|
|
|
where
|
2011-02-13 18:17:02 +00:00
|
|
|
noremote = "no remotes" ~: TestCase $ intmpclonerepo $ do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get failed"
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Params "remote rm origin"]
|
2011-02-13 18:17:02 +00:00
|
|
|
@? "git remote rm origin failed"
|
2011-12-20 21:31:25 +00:00
|
|
|
not <$> git_annex "drop" [annexedfile] @? "drop wrongly succeeded with no known copy of file"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "drop" ["--force", annexedfile] @? "drop --force failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_notpresent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "drop" [annexedfile] @? "drop of dropped file failed"
|
|
|
|
git_annex "drop" [ingitfile] @? "drop ingitfile should be no-op"
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed ingitfile
|
2011-01-08 19:00:04 +00:00
|
|
|
withremote = "with remote" ~: TestCase $ intmpclonerepo $ do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get failed"
|
2011-01-27 00:03:03 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "drop" [annexedfile] @? "drop failed though origin has copy"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_notpresent annexedfile
|
|
|
|
inmainrepo $ annexed_present annexedfile
|
2011-01-27 00:03:03 +00:00
|
|
|
untrustedremote = "untrusted remote" ~: TestCase $ intmpclonerepo $ do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "untrust" ["origin"] @? "untrust of origin failed"
|
|
|
|
git_annex "get" [annexedfile] @? "get failed"
|
2011-01-27 00:03:03 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 21:31:25 +00:00
|
|
|
not <$> git_annex "drop" [annexedfile] @? "drop wrongly suceeded with only an untrusted copy of the file"
|
2011-01-27 00:03:03 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
inmainrepo $ annexed_present annexedfile
|
2011-01-07 02:22:09 +00:00
|
|
|
|
|
|
|
test_get :: Test
|
2011-01-07 18:06:32 +00:00
|
|
|
test_get = "git-annex get" ~: TestCase $ intmpclonerepo $ do
|
|
|
|
inmainrepo $ annexed_present annexedfile
|
|
|
|
annexed_notpresent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get of file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
inmainrepo $ annexed_present annexedfile
|
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get of file already here failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
inmainrepo $ annexed_present annexedfile
|
|
|
|
annexed_present annexedfile
|
|
|
|
inmainrepo $ unannexed ingitfile
|
|
|
|
unannexed ingitfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [ingitfile] @? "get ingitfile should be no-op"
|
2011-01-07 18:06:32 +00:00
|
|
|
inmainrepo $ unannexed ingitfile
|
|
|
|
unannexed ingitfile
|
2011-01-07 05:02:06 +00:00
|
|
|
|
|
|
|
test_move :: Test
|
2011-01-07 18:06:32 +00:00
|
|
|
test_move = "git-annex move" ~: TestCase $ intmpclonerepo $ do
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
inmainrepo $ annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "move" ["--from", "origin", annexedfile] @? "move --from of file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
inmainrepo $ annexed_notpresent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "move" ["--from", "origin", annexedfile] @? "move --from of file already here failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
inmainrepo $ annexed_notpresent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "move" ["--to", "origin", annexedfile] @? "move --to of file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
inmainrepo $ annexed_present annexedfile
|
|
|
|
annexed_notpresent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "move" ["--to", "origin", annexedfile] @? "move --to of file already there failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
inmainrepo $ annexed_present annexedfile
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
unannexed ingitfile
|
|
|
|
inmainrepo $ unannexed ingitfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "move" ["--to", "origin", ingitfile] @? "move of ingitfile should be no-op"
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed ingitfile
|
|
|
|
inmainrepo $ unannexed ingitfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "move" ["--from", "origin", ingitfile] @? "move of ingitfile should be no-op"
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed ingitfile
|
|
|
|
inmainrepo $ unannexed ingitfile
|
2011-01-07 06:14:48 +00:00
|
|
|
|
|
|
|
test_copy :: Test
|
2011-01-07 18:06:32 +00:00
|
|
|
test_copy = "git-annex copy" ~: TestCase $ intmpclonerepo $ do
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
inmainrepo $ annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "copy" ["--from", "origin", annexedfile] @? "copy --from of file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
inmainrepo $ annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "copy" ["--from", "origin", annexedfile] @? "copy --from of file already here failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
inmainrepo $ annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "copy" ["--to", "origin", annexedfile] @? "copy --to of file already there failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
inmainrepo $ annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "move" ["--to", "origin", annexedfile] @? "move --to of file already there failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_notpresent annexedfile
|
|
|
|
inmainrepo $ annexed_present annexedfile
|
|
|
|
unannexed ingitfile
|
|
|
|
inmainrepo $ unannexed ingitfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "copy" ["--to", "origin", ingitfile] @? "copy of ingitfile should be no-op"
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed ingitfile
|
|
|
|
inmainrepo $ unannexed ingitfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "copy" ["--from", "origin", ingitfile] @? "copy of ingitfile should be no-op"
|
2011-01-07 06:18:39 +00:00
|
|
|
checkregularfile ingitfile
|
|
|
|
checkcontent ingitfile
|
2011-01-07 05:02:06 +00:00
|
|
|
|
2011-01-07 18:06:32 +00:00
|
|
|
test_lock :: Test
|
|
|
|
test_lock = "git-annex unlock/lock" ~: intmpclonerepo $ do
|
2011-01-14 03:46:02 +00:00
|
|
|
-- regression test: unlock of not present file should skip it
|
|
|
|
annexed_notpresent annexedfile
|
2011-12-20 21:31:25 +00:00
|
|
|
not <$> git_annex "unlock" [annexedfile] @? "unlock failed to fail with not present file"
|
2011-01-14 03:46:02 +00:00
|
|
|
annexed_notpresent annexedfile
|
|
|
|
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get of file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "unlock" [annexedfile] @? "unlock failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed annexedfile
|
|
|
|
-- write different content, to verify that lock
|
|
|
|
-- throws it away
|
|
|
|
changecontent annexedfile
|
2011-07-15 07:12:05 +00:00
|
|
|
writeFile annexedfile $ content annexedfile ++ "foo"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "lock" [annexedfile] @? "lock failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "unlock" [annexedfile] @? "unlock failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed annexedfile
|
|
|
|
changecontent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "add" [annexedfile] @? "add of modified file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
runchecks [checklink, checkunwritable] annexedfile
|
|
|
|
c <- readFile annexedfile
|
2011-07-15 07:12:05 +00:00
|
|
|
assertEqual "content of modified file" c (changedcontent annexedfile)
|
2011-12-20 19:48:25 +00:00
|
|
|
r' <- git_annex "drop" [annexedfile]
|
2011-01-14 03:46:02 +00:00
|
|
|
not r' @? "drop wrongly succeeded with no known copy of modified file"
|
2011-01-07 18:06:32 +00:00
|
|
|
|
|
|
|
test_edit :: Test
|
2011-01-12 00:48:58 +00:00
|
|
|
test_edit = "git-annex edit/commit" ~: TestList [t False, t True]
|
|
|
|
where t precommit = TestCase $ intmpclonerepo $ do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get of file failed"
|
2011-01-12 00:48:58 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "edit" [annexedfile] @? "edit failed"
|
2011-01-12 00:48:58 +00:00
|
|
|
unannexed annexedfile
|
|
|
|
changecontent annexedfile
|
|
|
|
if precommit
|
|
|
|
then do
|
|
|
|
-- pre-commit depends on the file being
|
|
|
|
-- staged, normally git commit does this
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Param "add", File annexedfile]
|
2011-01-12 00:48:58 +00:00
|
|
|
@? "git add of edited file failed"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "pre-commit" []
|
2011-01-12 00:48:58 +00:00
|
|
|
@? "pre-commit failed"
|
|
|
|
else do
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Params "commit -q -a -m contentchanged"]
|
2011-01-12 00:48:58 +00:00
|
|
|
@? "git commit of edited file failed"
|
|
|
|
runchecks [checklink, checkunwritable] annexedfile
|
|
|
|
c <- readFile annexedfile
|
2011-07-15 07:12:05 +00:00
|
|
|
assertEqual "content of modified file" c (changedcontent annexedfile)
|
2011-12-20 21:31:25 +00:00
|
|
|
not <$> git_annex "drop" [annexedfile] @? "drop wrongly succeeded with no known copy of modified file"
|
2011-01-07 18:06:32 +00:00
|
|
|
|
|
|
|
test_fix :: Test
|
|
|
|
test_fix = "git-annex fix" ~: intmpclonerepo $ do
|
2011-01-07 18:08:43 +00:00
|
|
|
annexed_notpresent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "fix" [annexedfile] @? "fix of not present failed"
|
2011-01-07 18:08:43 +00:00
|
|
|
annexed_notpresent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get of file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "fix" [annexedfile] @? "fix of present file failed"
|
2011-01-07 18:08:43 +00:00
|
|
|
annexed_present annexedfile
|
2011-01-07 18:06:32 +00:00
|
|
|
createDirectory subdir
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Param "mv", File annexedfile, File subdir]
|
2011-01-07 18:06:32 +00:00
|
|
|
@? "git mv failed"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "fix" [newfile] @? "fix of moved file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
runchecks [checklink, checkunwritable] newfile
|
|
|
|
c <- readFile newfile
|
2011-07-15 07:12:05 +00:00
|
|
|
assertEqual "content of moved file" c (content annexedfile)
|
2011-01-07 18:06:32 +00:00
|
|
|
where
|
|
|
|
subdir = "s"
|
|
|
|
newfile = subdir ++ "/" ++ annexedfile
|
2011-01-07 01:39:26 +00:00
|
|
|
|
2011-01-11 22:50:18 +00:00
|
|
|
test_trust :: Test
|
2011-12-20 20:26:39 +00:00
|
|
|
test_trust = "git-annex trust/untrust/semitrust/dead" ~: intmpclonerepo $ do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "trust" [repo] @? "trust failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.Trusted "trusted 1"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "trust" [repo] @? "trust of trusted failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.Trusted "trusted 2"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "untrust" [repo] @? "untrust failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.UnTrusted "untrusted 1"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "untrust" [repo] @? "untrust of untrusted failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.UnTrusted "untrusted 2"
|
2011-12-20 20:26:39 +00:00
|
|
|
git_annex "dead" [repo] @? "dead failed"
|
|
|
|
trustcheck Logs.Trust.DeadTrusted "deadtrusted 1"
|
|
|
|
git_annex "dead" [repo] @? "dead of dead failed"
|
|
|
|
trustcheck Logs.Trust.DeadTrusted "deadtrusted 2"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "semitrust" [repo] @? "semitrust failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.SemiTrusted "semitrusted 1"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "semitrust" [repo] @? "semitrust of semitrusted failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.SemiTrusted "semitrusted 2"
|
2011-01-11 22:50:18 +00:00
|
|
|
where
|
2011-03-27 20:55:43 +00:00
|
|
|
repo = "origin"
|
2011-01-26 20:20:28 +00:00
|
|
|
trustcheck expected msg = do
|
2011-01-26 19:37:16 +00:00
|
|
|
present <- annexeval $ do
|
2011-10-15 20:21:08 +00:00
|
|
|
l <- Logs.Trust.trustGet expected
|
2011-03-27 20:58:28 +00:00
|
|
|
u <- Remote.nameToUUID repo
|
2011-01-30 16:01:56 +00:00
|
|
|
return $ u `elem` l
|
2011-01-26 20:20:28 +00:00
|
|
|
assertBool msg present
|
2011-01-11 22:50:18 +00:00
|
|
|
|
2011-01-11 23:34:28 +00:00
|
|
|
test_fsck :: Test
|
2011-12-21 18:20:41 +00:00
|
|
|
test_fsck = "git-annex fsck" ~: TestList [basicfsck, barefsck, withlocaluntrusted, withremoteuntrusted]
|
2011-01-12 00:06:15 +00:00
|
|
|
where
|
2011-01-26 20:20:28 +00:00
|
|
|
basicfsck = TestCase $ intmpclonerepo $ do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "fsck" [] @? "fsck failed"
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Params "config annex.numcopies 2"] @? "git config failed"
|
2011-01-27 00:03:03 +00:00
|
|
|
fsck_should_fail "numcopies unsatisfied"
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Params "config annex.numcopies 1"] @? "git config failed"
|
2011-01-26 20:20:28 +00:00
|
|
|
corrupt annexedfile
|
|
|
|
corrupt sha1annexedfile
|
2011-12-21 18:20:41 +00:00
|
|
|
barefsck = TestCase $ intmpbareclonerepo $ do
|
|
|
|
git_annex "fsck" [] @? "fsck failed"
|
2011-02-13 18:17:02 +00:00
|
|
|
withlocaluntrusted = TestCase $ intmpclonerepo $ do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get failed"
|
|
|
|
git_annex "untrust" ["origin"] @? "untrust of origin repo failed"
|
|
|
|
git_annex "untrust" ["."] @? "untrust of current repo failed"
|
2011-01-27 00:03:03 +00:00
|
|
|
fsck_should_fail "content only available in untrusted (current) repository"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "trust" ["."] @? "trust of current repo failed"
|
|
|
|
git_annex "fsck" [annexedfile] @? "fsck failed on file present in trusted repo"
|
2011-01-27 00:03:03 +00:00
|
|
|
withremoteuntrusted = TestCase $ intmpclonerepo $ do
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Params "config annex.numcopies 2"] @? "git config failed"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get failed"
|
|
|
|
git_annex "get" [sha1annexedfile] @? "get failed"
|
|
|
|
git_annex "fsck" [] @? "fsck failed with numcopies=2 and 2 copies"
|
|
|
|
git_annex "untrust" ["origin"] @? "untrust of origin failed"
|
2011-01-27 00:03:03 +00:00
|
|
|
fsck_should_fail "content not replicated to enough non-untrusted repositories"
|
2011-03-04 01:34:30 +00:00
|
|
|
|
2011-01-12 00:06:15 +00:00
|
|
|
corrupt f = do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [f] @? "get of file failed"
|
2011-09-28 19:17:45 +00:00
|
|
|
Utility.FileMode.allowWrite f
|
2011-01-12 00:06:15 +00:00
|
|
|
writeFile f (changedcontent f)
|
2011-12-20 21:31:25 +00:00
|
|
|
not <$> git_annex "fsck" [] @? "fsck failed to fail with corrupted file content"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "fsck" [] @? "fsck unexpectedly failed again; previous one did not fix problem with " ++ f
|
2011-01-27 00:03:03 +00:00
|
|
|
fsck_should_fail m = do
|
2011-12-20 21:31:25 +00:00
|
|
|
not <$> git_annex "fsck" [] @? "fsck failed to fail with " ++ m
|
2011-01-11 23:34:28 +00:00
|
|
|
|
2011-01-12 01:11:32 +00:00
|
|
|
test_migrate :: Test
|
|
|
|
test_migrate = "git-annex migrate" ~: TestList [t False, t True]
|
|
|
|
where t usegitattributes = TestCase $ intmpclonerepo $ do
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
annexed_notpresent sha1annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "migrate" [annexedfile] @? "migrate of not present failed"
|
|
|
|
git_annex "migrate" [sha1annexedfile] @? "migrate of not present failed"
|
|
|
|
git_annex "get" [annexedfile] @? "get of file failed"
|
|
|
|
git_annex "get" [sha1annexedfile] @? "get of file failed"
|
2011-01-12 01:11:32 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
annexed_present sha1annexedfile
|
|
|
|
if usegitattributes
|
|
|
|
then do
|
2011-01-12 03:02:21 +00:00
|
|
|
writeFile ".gitattributes" $ "* annex.backend=SHA1"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "migrate" [sha1annexedfile]
|
2011-01-12 03:02:21 +00:00
|
|
|
@? "migrate sha1annexedfile failed"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "migrate" [annexedfile]
|
2011-01-12 03:02:21 +00:00
|
|
|
@? "migrate annexedfile failed"
|
2011-01-12 01:11:32 +00:00
|
|
|
else do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "migrate" [sha1annexedfile, "--backend", "SHA1"]
|
2011-01-12 03:02:21 +00:00
|
|
|
@? "migrate sha1annexedfile failed"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "migrate" [annexedfile, "--backend", "SHA1"]
|
2011-01-12 03:02:21 +00:00
|
|
|
@? "migrate annexedfile failed"
|
2011-01-12 01:11:32 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
annexed_present sha1annexedfile
|
2011-03-02 17:47:45 +00:00
|
|
|
checkbackend annexedfile backendSHA1
|
|
|
|
checkbackend sha1annexedfile backendSHA1
|
2011-01-12 03:02:21 +00:00
|
|
|
|
|
|
|
-- check that reversing a migration works
|
2011-12-20 20:06:15 +00:00
|
|
|
writeFile ".gitattributes" $ "* annex.backend=SHA256"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "migrate" [sha1annexedfile]
|
2011-01-12 03:02:21 +00:00
|
|
|
@? "migrate sha1annexedfile failed"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "migrate" [annexedfile]
|
2011-01-12 03:02:21 +00:00
|
|
|
@? "migrate annexedfile failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
annexed_present sha1annexedfile
|
2011-12-20 20:06:15 +00:00
|
|
|
checkbackend annexedfile backendSHA256
|
|
|
|
checkbackend sha1annexedfile backendSHA256
|
2011-01-12 01:11:32 +00:00
|
|
|
|
2011-01-12 05:58:23 +00:00
|
|
|
test_unused :: Test
|
|
|
|
test_unused = "git-annex unused/dropunused" ~: intmpclonerepo $ do
|
|
|
|
-- keys have to be looked up before files are removed
|
|
|
|
annexedfilekey <- annexeval $ findkey annexedfile
|
|
|
|
sha1annexedfilekey <- annexeval $ findkey sha1annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get of file failed"
|
|
|
|
git_annex "get" [sha1annexedfile] @? "get of file failed"
|
2011-01-12 05:58:23 +00:00
|
|
|
checkunused []
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Params "rm -q", File annexedfile] @? "git rm failed"
|
2011-09-28 21:48:11 +00:00
|
|
|
checkunused []
|
2011-09-30 01:11:48 +00:00
|
|
|
boolSystem "git" [Params "commit -q -m foo"] @? "git commit failed"
|
2011-09-28 21:48:11 +00:00
|
|
|
checkunused []
|
|
|
|
-- unused checks origin/master; once it's gone it is really unused
|
|
|
|
boolSystem "git" [Params "remote rm origin"] @? "git remote rm origin failed"
|
2011-01-12 05:58:23 +00:00
|
|
|
checkunused [annexedfilekey]
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Params "rm -q", File sha1annexedfile] @? "git rm failed"
|
2011-09-30 01:11:48 +00:00
|
|
|
boolSystem "git" [Params "commit -q -m foo"] @? "git commit failed"
|
2011-01-12 05:58:23 +00:00
|
|
|
checkunused [annexedfilekey, sha1annexedfilekey]
|
|
|
|
|
|
|
|
-- good opportunity to test dropkey also
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "dropkey" ["--force", show annexedfilekey]
|
2011-01-12 05:58:23 +00:00
|
|
|
@? "dropkey failed"
|
|
|
|
checkunused [sha1annexedfilekey]
|
|
|
|
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "dropunused" ["1", "2"] @? "dropunused failed"
|
2011-01-12 05:58:23 +00:00
|
|
|
checkunused []
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "dropunused" ["10", "501"] @? "dropunused failed on bogus numbers"
|
2011-01-12 05:58:23 +00:00
|
|
|
|
|
|
|
where
|
|
|
|
checkunused expectedkeys = do
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "unused" [] @? "unused failed"
|
2011-05-15 05:33:25 +00:00
|
|
|
unusedmap <- annexeval $ Command.DropUnused.readUnusedLog ""
|
2011-01-12 05:58:23 +00:00
|
|
|
let unusedkeys = M.elems unusedmap
|
|
|
|
assertEqual "unused keys differ"
|
|
|
|
(sort expectedkeys) (sort unusedkeys)
|
|
|
|
findkey f = do
|
|
|
|
r <- Backend.lookupFile f
|
|
|
|
return $ fst $ fromJust r
|
|
|
|
|
2011-12-20 20:26:39 +00:00
|
|
|
test_addurl :: Test
|
|
|
|
test_addurl = "git-annex addurl" ~: intmpclonerepo $ do
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
-- can't check download; test suite should not access network,
|
|
|
|
-- and starting up a web server seems excessive
|
|
|
|
git_annex "addurl" ["--fast", "http://example.com/nosuchfile"] @? "addurl failed"
|
|
|
|
|
|
|
|
test_describe :: Test
|
|
|
|
test_describe = "git-annex describe" ~: intmpclonerepo $ do
|
|
|
|
git_annex "describe" [".", "this repo"] @? "describe 1 failed"
|
|
|
|
git_annex "describe" ["origin", "origin repo"] @? "describe 2 failed"
|
|
|
|
|
|
|
|
test_find :: Test
|
|
|
|
test_find = "git-annex find" ~: intmpclonerepo $ do
|
|
|
|
annexed_notpresent annexedfile
|
2011-12-21 06:32:40 +00:00
|
|
|
git_annex_expectoutput "find" [] []
|
|
|
|
git_annex "get" [annexedfile] @? "get failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
annexed_notpresent sha1annexedfile
|
|
|
|
git_annex_expectoutput "find" [] [annexedfile]
|
|
|
|
git_annex_expectoutput "find" ["--exclude", annexedfile, "--and", "--exclude", sha1annexedfile] []
|
2011-12-22 17:53:06 +00:00
|
|
|
git_annex_expectoutput "find" ["--include", annexedfile] [annexedfile]
|
2011-12-21 06:32:40 +00:00
|
|
|
git_annex_expectoutput "find" ["--not", "--in", "origin"] []
|
|
|
|
git_annex_expectoutput "find" ["--copies", "1", "--and", "--not", "--copies", "2"] [sha1annexedfile]
|
|
|
|
git_annex_expectoutput "find" ["--inbackend", "SHA1"] [sha1annexedfile]
|
|
|
|
git_annex_expectoutput "find" ["--inbackend", "WORM"] []
|
2011-12-20 20:26:39 +00:00
|
|
|
|
|
|
|
test_merge :: Test
|
|
|
|
test_merge = "git-annex merge" ~: intmpclonerepo $ do
|
|
|
|
git_annex "merge" [] @? "merge failed"
|
|
|
|
|
|
|
|
test_status :: Test
|
|
|
|
test_status = "git-annex status" ~: intmpclonerepo $ do
|
2011-12-21 06:32:40 +00:00
|
|
|
json <- git_annex_output "status" ["--json"]
|
|
|
|
case Text.JSON.decodeStrict json :: Text.JSON.Result (JSObject JSValue) of
|
|
|
|
Ok _ -> return ()
|
|
|
|
Error e -> assertFailure e
|
2011-12-20 20:26:39 +00:00
|
|
|
|
2011-12-20 21:31:25 +00:00
|
|
|
test_version :: Test
|
|
|
|
test_version = "git-annex version" ~: intmpclonerepo $ do
|
|
|
|
git_annex "version" [] @? "version failed"
|
|
|
|
|
2011-12-20 20:26:39 +00:00
|
|
|
test_sync :: Test
|
|
|
|
test_sync = "git-annex sync" ~: intmpclonerepo $ do
|
|
|
|
git_annex "sync" [] @? "sync failed"
|
|
|
|
|
2011-12-20 20:31:59 +00:00
|
|
|
test_map :: Test
|
|
|
|
test_map = "git-annex map" ~: intmpclonerepo $ do
|
|
|
|
-- set descriptions, that will be looked for in the map
|
|
|
|
git_annex "describe" [".", "this repo"] @? "describe 1 failed"
|
|
|
|
git_annex "describe" ["origin", "origin repo"] @? "describe 2 failed"
|
|
|
|
-- --fast avoids it running graphviz, not a build dependency
|
|
|
|
git_annex "map" ["--fast"] @? "map failed"
|
|
|
|
doesFileExist "map.dot" @? "map.dot not generated"
|
|
|
|
c <- readFile "map.dot"
|
2011-12-20 21:31:25 +00:00
|
|
|
("this repo" `isInfixOf` c && "origin repo" `isInfixOf` c) @? ("map.dot bad content: " ++ c)
|
|
|
|
|
|
|
|
test_uninit :: Test
|
|
|
|
test_uninit = "git-annex uninit" ~: intmpclonerepo $ do
|
|
|
|
git_annex "get" [] @? "get failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
boolSystem "git" [Params "checkout git-annex"] @? "git checkout git-annex"
|
|
|
|
not <$> git_annex "uninit" [] @? "uninit failed to fail when git-annex branch was checked out"
|
|
|
|
boolSystem "git" [Params "checkout master"] @? "git checkout master"
|
2011-12-21 06:32:40 +00:00
|
|
|
_ <- git_annex "uninit" [] -- exit status not checked; does abnormal exit
|
2011-12-20 21:31:25 +00:00
|
|
|
checkregularfile annexedfile
|
|
|
|
doesDirectoryExist ".git" @? ".git vanished in uninit"
|
2011-12-21 06:32:40 +00:00
|
|
|
not <$> doesDirectoryExist ".git/annex" @? ".git/annex still present after uninit"
|
2011-12-20 21:31:25 +00:00
|
|
|
|
|
|
|
test_upgrade :: Test
|
|
|
|
test_upgrade = "git-annex upgrade" ~: intmpclonerepo $ do
|
|
|
|
git_annex "upgrade" [] @? "upgrade from same version failed"
|
|
|
|
|
|
|
|
test_whereis :: Test
|
|
|
|
test_whereis = "git-annex whereis" ~: intmpclonerepo $ do
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
git_annex "whereis" [annexedfile] @? "whereis on non-present file failed"
|
|
|
|
git_annex "untrust" ["origin"] @? "untrust failed"
|
|
|
|
not <$> git_annex "whereis" [annexedfile] @? "whereis on non-present file only present in untrusted repo failed to fail"
|
|
|
|
git_annex "get" [annexedfile] @? "get failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
git_annex "whereis" [annexedfile] @? "whereis on present file failed"
|
2011-12-20 20:31:59 +00:00
|
|
|
|
2011-12-20 19:13:36 +00:00
|
|
|
test_hook_remote :: Test
|
|
|
|
test_hook_remote = "git-annex hook remote" ~: intmpclonerepo $ do
|
|
|
|
git_annex "initremote" (words "foo type=hook encryption=none hooktype=foo") @? "initremote failed"
|
|
|
|
createDirectory dir
|
|
|
|
git_config "annex.foo-store-hook" $
|
|
|
|
"cp $ANNEX_FILE " ++ loc
|
|
|
|
git_config "annex.foo-retrieve-hook" $
|
|
|
|
"cp " ++ loc ++ " $ANNEX_FILE"
|
|
|
|
git_config "annex.foo-remove-hook" $
|
|
|
|
"rm -f " ++ loc
|
|
|
|
git_config "annex.foo-checkpresent-hook" $
|
|
|
|
"if [ -e " ++ loc ++ " ]; then echo $ANNEX_KEY; fi"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get of file failed"
|
2011-12-20 19:13:36 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "copy" [annexedfile, "--to", "foo"] @? "copy --to hook remote failed"
|
2011-12-20 19:13:36 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed"
|
2011-12-20 19:13:36 +00:00
|
|
|
annexed_notpresent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "move" [annexedfile, "--from", "foo"] @? "move --from hook remote failed"
|
2011-12-20 19:13:36 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 21:31:25 +00:00
|
|
|
not <$> git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed to fail"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:13:36 +00:00
|
|
|
where
|
|
|
|
dir = "dir"
|
|
|
|
loc = dir ++ "/$ANNEX_KEY"
|
|
|
|
git_config k v = boolSystem "git" [Param "config", Param k, Param v]
|
|
|
|
@? "git config failed"
|
|
|
|
|
2011-12-20 19:17:56 +00:00
|
|
|
test_directory_remote :: Test
|
|
|
|
test_directory_remote = "git-annex directory remote" ~: intmpclonerepo $ do
|
|
|
|
createDirectory "dir"
|
|
|
|
git_annex "initremote" (words $ "foo type=directory encryption=none directory=dir") @? "initremote failed"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get of file failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "copy" [annexedfile, "--to", "foo"] @? "copy --to directory remote failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_notpresent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "move" [annexedfile, "--from", "foo"] @? "move --from directory remote failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 21:31:25 +00:00
|
|
|
not <$> git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed to fail"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
|
|
|
|
test_rsync_remote :: Test
|
|
|
|
test_rsync_remote = "git-annex rsync remote" ~: intmpclonerepo $ do
|
|
|
|
createDirectory "dir"
|
|
|
|
git_annex "initremote" (words $ "foo type=rsync encryption=none rsyncurl=dir") @? "initremote failed"
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "get" [annexedfile] @? "get of file failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "copy" [annexedfile, "--to", "foo"] @? "copy --to rsync remote failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_notpresent annexedfile
|
2011-12-20 19:48:25 +00:00
|
|
|
git_annex "move" [annexedfile, "--from", "foo"] @? "move --from rsync remote failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2011-12-20 21:31:25 +00:00
|
|
|
not <$> git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed to fail"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
|
2011-12-21 17:50:33 +00:00
|
|
|
test_bup_remote :: Test
|
2011-12-21 18:10:36 +00:00
|
|
|
test_bup_remote = "git-annex bup remote" ~: intmpclonerepo $ when Build.SysConfig.bup $ do
|
2011-12-21 17:50:33 +00:00
|
|
|
dir <- absPath "dir" -- bup special remote needs an absolute path
|
|
|
|
createDirectory dir
|
|
|
|
git_annex "initremote" (words $ "foo type=bup encryption=none buprepo="++dir) @? "initremote failed"
|
|
|
|
git_annex "get" [annexedfile] @? "get of file failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
git_annex "copy" [annexedfile, "--to", "foo"] @? "copy --to bup remote failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed"
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
git_annex "copy" [annexedfile, "--from", "foo"] @? "copy --from bup remote failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
not <$> git_annex "move" [annexedfile, "--from", "foo"] @? "move --from bup remote failed to fail"
|
|
|
|
annexed_present annexedfile
|
|
|
|
|
2011-12-21 18:10:36 +00:00
|
|
|
-- gpg is not a build dependency, so only test when it's available
|
2011-12-21 03:20:36 +00:00
|
|
|
test_crypto :: Test
|
2011-12-21 18:10:36 +00:00
|
|
|
test_crypto = "git-annex crypto" ~: intmpclonerepo $ when Build.SysConfig.gpg $ do
|
|
|
|
Utility.Gpg.testTestHarness @? "test harness self-test failed"
|
|
|
|
Utility.Gpg.testHarness $ do
|
|
|
|
createDirectory "dir"
|
|
|
|
let initremote = git_annex "initremote"
|
|
|
|
[ "foo"
|
|
|
|
, "type=directory"
|
|
|
|
, "encryption=" ++ Utility.Gpg.testKeyId
|
|
|
|
, "directory=dir"
|
|
|
|
]
|
|
|
|
initremote @? "initremote failed"
|
|
|
|
initremote @? "initremote failed when run twice in a row"
|
|
|
|
git_annex "get" [annexedfile] @? "get of file failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
git_annex "copy" [annexedfile, "--to", "foo"] @? "copy --to encrypted remote failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed"
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
git_annex "move" [annexedfile, "--from", "foo"] @? "move --from encrypted remote failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
not <$> git_annex "drop" [annexedfile, "--numcopies=2"] @? "drop failed to fail"
|
|
|
|
annexed_present annexedfile
|
2011-12-21 03:20:36 +00:00
|
|
|
|
2011-01-11 22:50:18 +00:00
|
|
|
-- This is equivilant to running git-annex, but it's all run in-process
|
|
|
|
-- so test coverage collection works.
|
2011-01-07 00:09:49 +00:00
|
|
|
git_annex :: String -> [String] -> IO Bool
|
2011-01-07 00:26:57 +00:00
|
|
|
git_annex command params = do
|
2011-01-07 01:39:26 +00:00
|
|
|
-- catch all errors, including normally fatal errors
|
|
|
|
r <- E.try (run)::IO (Either E.SomeException ())
|
2011-01-07 00:26:57 +00:00
|
|
|
case r of
|
|
|
|
Right _ -> return True
|
|
|
|
Left _ -> return False
|
2011-01-07 01:39:26 +00:00
|
|
|
where
|
2011-12-20 19:48:25 +00:00
|
|
|
run = GitAnnex.run (command:"-q":params)
|
2011-01-07 00:09:49 +00:00
|
|
|
|
2011-12-21 06:32:40 +00:00
|
|
|
{- Runs git-annex and returns its output. -}
|
|
|
|
git_annex_output :: String -> [String] -> IO String
|
|
|
|
git_annex_output command params = do
|
|
|
|
(frompipe, topipe) <- createPipe
|
|
|
|
pid <- forkProcess $ do
|
|
|
|
_ <- dupTo topipe stdOutput
|
|
|
|
closeFd frompipe
|
|
|
|
_ <- git_annex command params
|
|
|
|
exitSuccess
|
|
|
|
-- XXX since the above is a separate process, code coverage stats are
|
|
|
|
-- not gathered for things run in it.
|
|
|
|
closeFd topipe
|
|
|
|
fromh <- fdToHandle frompipe
|
|
|
|
got <- hGetContentsStrict fromh
|
|
|
|
hClose fromh
|
|
|
|
_ <- getProcessStatus True False pid
|
|
|
|
-- XXX hack Run same command again, to get code coverage.
|
|
|
|
_ <- git_annex command params
|
|
|
|
return got
|
|
|
|
|
|
|
|
git_annex_expectoutput :: String -> [String] -> [String] -> IO ()
|
|
|
|
git_annex_expectoutput command params expected = do
|
|
|
|
got <- lines <$> git_annex_output command params
|
|
|
|
got == expected @? ("unexpected value running " ++ command ++ " " ++ show params ++ " -- got: " ++ show got ++ " expected: " ++ show expected)
|
|
|
|
|
2011-01-11 22:50:18 +00:00
|
|
|
-- Runs an action in the current annex. Note that shutdown actions
|
|
|
|
-- are not run; this should only be used for actions that query state.
|
2011-01-26 01:49:04 +00:00
|
|
|
annexeval :: Types.Annex a -> IO a
|
2011-01-11 22:50:18 +00:00
|
|
|
annexeval a = do
|
2011-12-13 19:05:07 +00:00
|
|
|
g <- Git.Construct.fromCwd
|
|
|
|
g' <- Git.Config.read g
|
2011-07-05 22:31:46 +00:00
|
|
|
s <- Annex.new g'
|
2011-12-20 20:03:14 +00:00
|
|
|
Annex.eval s { Annex.output = Annex.QuietOutput } a
|
2011-01-11 22:50:18 +00:00
|
|
|
|
2011-01-07 18:06:32 +00:00
|
|
|
innewrepo :: Assertion -> Assertion
|
|
|
|
innewrepo a = withgitrepo $ \r -> indir r a
|
2011-01-07 01:39:26 +00:00
|
|
|
|
2011-01-07 18:06:32 +00:00
|
|
|
inmainrepo :: Assertion -> Assertion
|
|
|
|
inmainrepo a = indir mainrepodir a
|
2011-01-07 01:39:26 +00:00
|
|
|
|
2011-01-07 18:06:32 +00:00
|
|
|
intmpclonerepo :: Assertion -> Assertion
|
2011-12-21 18:20:41 +00:00
|
|
|
intmpclonerepo a = withtmpclonerepo False $ \r -> indir r a
|
|
|
|
|
|
|
|
intmpbareclonerepo :: Assertion -> Assertion
|
|
|
|
intmpbareclonerepo a = withtmpclonerepo True $ \r -> indir r a
|
2011-01-07 02:22:09 +00:00
|
|
|
|
2011-12-21 18:20:41 +00:00
|
|
|
withtmpclonerepo :: Bool -> (FilePath -> Assertion) -> Assertion
|
|
|
|
withtmpclonerepo bare = bracket (clonerepo mainrepodir tmprepodir bare) cleanup
|
2011-01-07 02:22:09 +00:00
|
|
|
|
2011-01-07 01:39:26 +00:00
|
|
|
withgitrepo :: (FilePath -> Assertion) -> Assertion
|
2011-01-07 18:06:32 +00:00
|
|
|
withgitrepo = bracket (setuprepo mainrepodir) return
|
2011-01-07 01:39:26 +00:00
|
|
|
|
|
|
|
indir :: FilePath -> Assertion -> Assertion
|
|
|
|
indir dir a = do
|
2011-01-07 00:09:49 +00:00
|
|
|
cwd <- getCurrentDirectory
|
2011-01-08 19:00:04 +00:00
|
|
|
-- Assertion failures throw non-IO errors; catch
|
|
|
|
-- any type of error and change back to cwd before
|
|
|
|
-- rethrowing.
|
2011-11-26 16:08:54 +00:00
|
|
|
r <- bracket_ (changeToTmpDir dir) (changeWorkingDirectory cwd)
|
2011-01-08 19:00:04 +00:00
|
|
|
(E.try (a)::IO (Either E.SomeException ()))
|
|
|
|
case r of
|
|
|
|
Right () -> return ()
|
2011-01-08 19:14:41 +00:00
|
|
|
Left e -> throw e
|
2011-01-07 00:09:49 +00:00
|
|
|
|
2011-01-07 01:39:26 +00:00
|
|
|
setuprepo :: FilePath -> IO FilePath
|
|
|
|
setuprepo dir = do
|
|
|
|
cleanup dir
|
|
|
|
ensuretmpdir
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Params "init -q", File dir] @? "git init failed"
|
2011-02-09 15:17:26 +00:00
|
|
|
indir dir $ do
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Params "config user.name", Param "Test User"] @? "git config failed"
|
|
|
|
boolSystem "git" [Params "config user.email test@example.com"] @? "git config failed"
|
2011-01-07 01:39:26 +00:00
|
|
|
return dir
|
|
|
|
|
2011-01-07 02:22:09 +00:00
|
|
|
-- clones are always done as local clones; we cannot test ssh clones
|
2011-12-21 18:20:41 +00:00
|
|
|
clonerepo :: FilePath -> FilePath -> Bool -> IO FilePath
|
|
|
|
clonerepo old new bare = do
|
2011-01-07 02:22:09 +00:00
|
|
|
cleanup new
|
|
|
|
ensuretmpdir
|
2011-12-21 18:20:41 +00:00
|
|
|
let b = if bare then " --bare" else ""
|
|
|
|
boolSystem "git" [Params ("clone -q" ++ b), File old, File new] @? "git clone failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
indir new $ git_annex "init" ["-q", new] @? "git annex init failed"
|
2011-01-07 02:22:09 +00:00
|
|
|
return new
|
2011-01-07 01:39:26 +00:00
|
|
|
|
|
|
|
ensuretmpdir :: IO ()
|
|
|
|
ensuretmpdir = do
|
|
|
|
e <- doesDirectoryExist tmpdir
|
|
|
|
unless e $
|
|
|
|
createDirectory tmpdir
|
|
|
|
|
|
|
|
cleanup :: FilePath -> IO ()
|
|
|
|
cleanup dir = do
|
|
|
|
e <- doesDirectoryExist dir
|
|
|
|
when e $ do
|
|
|
|
-- git-annex prevents annexed file content from being
|
2011-02-09 05:01:06 +00:00
|
|
|
-- removed via directory permissions; undo
|
|
|
|
recurseDir SystemFS dir >>=
|
|
|
|
filterM doesDirectoryExist >>=
|
2011-09-28 19:17:45 +00:00
|
|
|
mapM_ Utility.FileMode.allowWrite
|
2011-01-07 01:39:26 +00:00
|
|
|
removeDirectoryRecursive dir
|
2011-01-07 02:22:09 +00:00
|
|
|
|
|
|
|
checklink :: FilePath -> Assertion
|
|
|
|
checklink f = do
|
|
|
|
s <- getSymbolicLinkStatus f
|
2011-01-07 05:02:06 +00:00
|
|
|
isSymbolicLink s @? f ++ " is not a symlink"
|
2011-01-07 02:22:09 +00:00
|
|
|
|
2011-01-07 05:02:06 +00:00
|
|
|
checkregularfile :: FilePath -> Assertion
|
|
|
|
checkregularfile f = do
|
|
|
|
s <- getSymbolicLinkStatus f
|
|
|
|
isRegularFile s @? f ++ " is not a normal file"
|
|
|
|
return ()
|
|
|
|
|
|
|
|
checkcontent :: FilePath -> Assertion
|
|
|
|
checkcontent f = do
|
|
|
|
c <- readFile f
|
|
|
|
assertEqual ("checkcontent " ++ f) c (content f)
|
2011-01-07 02:22:09 +00:00
|
|
|
|
|
|
|
checkunwritable :: FilePath -> Assertion
|
|
|
|
checkunwritable f = do
|
2011-04-27 00:21:24 +00:00
|
|
|
-- Look at permissions bits rather than trying to write or using
|
|
|
|
-- fileAccess because if run as root, any file can be modified
|
|
|
|
-- despite permissions.
|
|
|
|
s <- getFileStatus f
|
|
|
|
let mode = fileMode s
|
|
|
|
if (mode == mode `unionFileModes` ownerWriteMode)
|
|
|
|
then assertFailure $ "able to modify annexed file's " ++ f ++ " content"
|
|
|
|
else return ()
|
2011-01-07 02:22:09 +00:00
|
|
|
|
2011-01-07 18:06:32 +00:00
|
|
|
checkwritable :: FilePath -> Assertion
|
|
|
|
checkwritable f = do
|
|
|
|
r <- try $ writeFile f $ content f
|
|
|
|
case r of
|
|
|
|
Left _ -> assertFailure $ "unable to modify " ++ f
|
|
|
|
Right _ -> return ()
|
|
|
|
|
2011-01-07 02:22:09 +00:00
|
|
|
checkdangling :: FilePath -> Assertion
|
|
|
|
checkdangling f = do
|
|
|
|
r <- try $ readFile f
|
|
|
|
case r of
|
|
|
|
Left _ -> return () -- expected; dangling link
|
|
|
|
Right _ -> assertFailure $ f ++ " was not a dangling link as expected"
|
2011-01-07 01:39:26 +00:00
|
|
|
|
2011-01-11 19:43:29 +00:00
|
|
|
checklocationlog :: FilePath -> Bool -> Assertion
|
|
|
|
checklocationlog f expected = do
|
2011-10-15 21:47:03 +00:00
|
|
|
thisuuid <- annexeval Annex.UUID.getUUID
|
2011-01-11 22:50:18 +00:00
|
|
|
r <- annexeval $ Backend.lookupFile f
|
2011-01-11 19:43:29 +00:00
|
|
|
case r of
|
|
|
|
Just (k, _) -> do
|
2011-10-15 20:21:08 +00:00
|
|
|
uuids <- annexeval $ Logs.Location.keyLocations k
|
2011-11-07 18:46:01 +00:00
|
|
|
assertEqual ("bad content in location log for " ++ f ++ " key " ++ (show k) ++ " uuid " ++ show thisuuid)
|
2011-01-30 16:01:56 +00:00
|
|
|
expected (thisuuid `elem` uuids)
|
2011-01-11 19:43:29 +00:00
|
|
|
_ -> assertFailure $ f ++ " failed to look up key"
|
|
|
|
|
2011-12-21 18:10:36 +00:00
|
|
|
checkbackend :: FilePath -> Types.Backend Types.Annex -> Assertion
|
|
|
|
checkbackend file expected = do
|
|
|
|
r <- annexeval $ Backend.lookupFile file
|
|
|
|
let b = snd $ fromJust r
|
|
|
|
assertEqual ("backend for " ++ file) expected b
|
|
|
|
|
2011-01-11 19:43:29 +00:00
|
|
|
inlocationlog :: FilePath -> Assertion
|
|
|
|
inlocationlog f = checklocationlog f True
|
|
|
|
|
|
|
|
notinlocationlog :: FilePath -> Assertion
|
|
|
|
notinlocationlog f = checklocationlog f False
|
|
|
|
|
2011-01-07 18:06:32 +00:00
|
|
|
runchecks :: [FilePath -> Assertion] -> FilePath -> Assertion
|
|
|
|
runchecks [] _ = return ()
|
|
|
|
runchecks (a:as) f = do
|
|
|
|
a f
|
|
|
|
runchecks as f
|
|
|
|
|
|
|
|
annexed_notpresent :: FilePath -> Assertion
|
2011-01-11 19:43:29 +00:00
|
|
|
annexed_notpresent = runchecks
|
2011-04-27 00:21:24 +00:00
|
|
|
[checklink, checkdangling, notinlocationlog]
|
2011-01-07 18:06:32 +00:00
|
|
|
|
|
|
|
annexed_present :: FilePath -> Assertion
|
2011-01-11 19:43:29 +00:00
|
|
|
annexed_present = runchecks
|
|
|
|
[checklink, checkcontent, checkunwritable, inlocationlog]
|
2011-01-07 18:06:32 +00:00
|
|
|
|
|
|
|
unannexed :: FilePath -> Assertion
|
|
|
|
unannexed = runchecks [checkregularfile, checkcontent, checkwritable]
|
|
|
|
|
|
|
|
prepare :: IO ()
|
|
|
|
prepare = do
|
|
|
|
-- While PATH is mostly avoided, the commit hook does run it. Make
|
|
|
|
-- sure that the just-built git annex is used.
|
|
|
|
cwd <- getCurrentDirectory
|
|
|
|
p <- getEnvDefault "PATH" ""
|
|
|
|
setEnv "PATH" (cwd ++ ":" ++ p) True
|
|
|
|
setEnv "TOPDIR" cwd True
|
2011-08-23 17:41:32 +00:00
|
|
|
-- Avoid git complaining if it cannot determine the user's email
|
|
|
|
-- address.
|
|
|
|
setEnv "EMAIL" "git-annex test <test@example.com>" True
|
2011-01-07 18:06:32 +00:00
|
|
|
|
|
|
|
changeToTmpDir :: FilePath -> IO ()
|
|
|
|
changeToTmpDir t = do
|
|
|
|
-- Hack alert. Threading state to here was too much bother.
|
|
|
|
topdir <- getEnvDefault "TOPDIR" ""
|
|
|
|
changeWorkingDirectory $ topdir ++ "/" ++ t
|
|
|
|
|
|
|
|
tmpdir :: String
|
2011-01-07 01:39:26 +00:00
|
|
|
tmpdir = ".t"
|
|
|
|
|
2011-01-07 18:06:32 +00:00
|
|
|
mainrepodir :: String
|
|
|
|
mainrepodir = tmpdir ++ "/repo"
|
2011-01-07 01:39:26 +00:00
|
|
|
|
|
|
|
tmprepodir :: String
|
|
|
|
tmprepodir = tmpdir ++ "/tmprepo"
|
2011-01-07 18:06:32 +00:00
|
|
|
|
2011-01-07 05:02:06 +00:00
|
|
|
annexedfile :: String
|
|
|
|
annexedfile = "foo"
|
|
|
|
|
2011-12-21 18:10:36 +00:00
|
|
|
wormannexedfile :: String
|
|
|
|
wormannexedfile = "apple"
|
|
|
|
|
2011-01-11 23:59:11 +00:00
|
|
|
sha1annexedfile :: String
|
|
|
|
sha1annexedfile = "sha1foo"
|
|
|
|
|
2011-01-27 18:01:30 +00:00
|
|
|
sha1annexedfiledup :: String
|
|
|
|
sha1annexedfiledup = "sha1foodup"
|
|
|
|
|
2011-01-07 05:02:06 +00:00
|
|
|
ingitfile :: String
|
|
|
|
ingitfile = "bar"
|
2011-01-07 02:22:09 +00:00
|
|
|
|
2011-01-07 05:02:06 +00:00
|
|
|
content :: FilePath -> String
|
|
|
|
content f
|
|
|
|
| f == annexedfile = "annexed file content"
|
|
|
|
| f == ingitfile = "normal file content"
|
2011-01-11 23:59:11 +00:00
|
|
|
| f == sha1annexedfile ="sha1 annexed file content"
|
2011-01-27 18:01:30 +00:00
|
|
|
| f == sha1annexedfiledup = content sha1annexedfile
|
2011-12-21 18:10:36 +00:00
|
|
|
| f == wormannexedfile = "worm annexed file content"
|
2011-01-07 05:02:06 +00:00
|
|
|
| otherwise = "unknown file " ++ f
|
2011-01-07 18:06:32 +00:00
|
|
|
|
|
|
|
changecontent :: FilePath -> IO ()
|
|
|
|
changecontent f = writeFile f $ changedcontent f
|
|
|
|
|
|
|
|
changedcontent :: FilePath -> String
|
|
|
|
changedcontent f = (content f) ++ " (modified)"
|
2011-03-02 17:47:45 +00:00
|
|
|
|
|
|
|
backendSHA1 :: Types.Backend Types.Annex
|
|
|
|
backendSHA1 = backend_ "SHA1"
|
|
|
|
|
2011-12-20 20:06:15 +00:00
|
|
|
backendSHA256 :: Types.Backend Types.Annex
|
|
|
|
backendSHA256 = backend_ "SHA256"
|
2011-03-02 17:47:45 +00:00
|
|
|
|
2011-12-21 18:10:36 +00:00
|
|
|
backendWORM :: Types.Backend Types.Annex
|
|
|
|
backendWORM = backend_ "WORM"
|
|
|
|
|
2011-03-02 17:47:45 +00:00
|
|
|
backend_ :: String -> Types.Backend Types.Annex
|
2011-07-05 22:31:46 +00:00
|
|
|
backend_ name = Backend.lookupBackendName name
|