2011-01-07 00:09:49 +00:00
|
|
|
{- git-annex test suite
|
|
|
|
-
|
2013-02-27 19:35:07 +00:00
|
|
|
- Copyright 2010-2013 Joey Hess <joey@kitenet.net>
|
2011-01-07 00:09:49 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
2013-05-17 20:45:44 +00:00
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
|
2013-02-27 19:35:07 +00:00
|
|
|
module Test where
|
|
|
|
|
2010-11-02 21:08:16 +00:00
|
|
|
import Test.HUnit
|
2013-02-28 03:21:43 +00:00
|
|
|
import Test.QuickCheck
|
|
|
|
import Test.QuickCheck.Test
|
2011-04-25 19:28:41 +00:00
|
|
|
|
2013-05-17 20:47:25 +00:00
|
|
|
import System.PosixCompat.Files
|
2012-02-03 20:57:07 +00:00
|
|
|
import Control.Exception.Extensible
|
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(..))
|
2013-02-28 03:21:43 +00:00
|
|
|
import qualified Text.JSON
|
2013-05-12 23:13:38 +00:00
|
|
|
import System.Path
|
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
|
2012-05-18 22:20:53 +00:00
|
|
|
import qualified Git.CurrentRepo
|
2011-12-13 19:22:43 +00:00
|
|
|
import qualified Git.Filename
|
2011-01-07 00:26:57 +00:00
|
|
|
import qualified Locations
|
2012-06-21 17:04:24 +00:00
|
|
|
import qualified Types.KeySource
|
2011-06-14 01:51:52 +00:00
|
|
|
import qualified Types.Backend
|
2012-12-20 03:43:15 +00:00
|
|
|
import qualified Types.TrustLevel
|
2011-01-26 01:49:04 +00:00
|
|
|
import qualified Types
|
2011-10-15 20:21:08 +00:00
|
|
|
import qualified Logs.UUIDBased
|
|
|
|
import qualified Logs.Trust
|
|
|
|
import qualified Logs.Remote
|
2012-05-06 00:11:08 +00:00
|
|
|
import qualified Logs.Unused
|
2012-12-19 20:15:39 +00:00
|
|
|
import qualified Logs.Transfer
|
2012-12-20 02:14:12 +00:00
|
|
|
import qualified Logs.Presence
|
2011-03-27 20:58:28 +00:00
|
|
|
import qualified Remote
|
2011-06-14 01:51:52 +00:00
|
|
|
import qualified Types.Key
|
2012-04-30 17:59:05 +00:00
|
|
|
import qualified Types.Messages
|
2013-05-15 21:44:30 +00:00
|
|
|
import qualified Config
|
2013-03-13 20:16:01 +00:00
|
|
|
import qualified Config.Cost
|
2011-04-21 20:56:24 +00:00
|
|
|
import qualified Crypto
|
2013-05-17 18:52:12 +00:00
|
|
|
import qualified Init
|
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 Build.SysConfig
|
2011-12-23 00:14:35 +00:00
|
|
|
import qualified Utility.Format
|
2012-09-08 03:23:52 +00:00
|
|
|
import qualified Utility.Verifiable
|
2012-10-11 17:45:09 +00:00
|
|
|
import qualified Utility.Process
|
2012-10-16 02:22:40 +00:00
|
|
|
import qualified Utility.Misc
|
2013-02-14 20:17:40 +00:00
|
|
|
import qualified Utility.InodeCache
|
2013-05-11 22:23:41 +00:00
|
|
|
import qualified Utility.Env
|
2013-05-20 01:07:47 +00:00
|
|
|
import qualified Utility.Gpg
|
2013-05-25 01:33:54 +00:00
|
|
|
import qualified Utility.Matcher
|
2013-05-25 17:51:36 +00:00
|
|
|
import qualified Utility.Exception
|
2013-08-04 17:07:55 +00:00
|
|
|
#ifndef mingw32_HOST_OS
|
2013-05-17 20:51:46 +00:00
|
|
|
import qualified GitAnnex
|
|
|
|
#endif
|
2010-11-02 20:49:35 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
type TestEnv = M.Map String String
|
|
|
|
|
2011-01-07 06:14:48 +00:00
|
|
|
main :: IO ()
|
2011-01-07 01:39:26 +00:00
|
|
|
main = do
|
2013-02-28 03:35:37 +00:00
|
|
|
divider
|
|
|
|
putStrLn "First, some automated quick checks of properties ..."
|
|
|
|
divider
|
|
|
|
qcok <- all isSuccess <$> sequence quickcheck
|
|
|
|
divider
|
|
|
|
putStrLn "Now, some broader checks ..."
|
|
|
|
putStrLn " (Do not be alarmed by odd output here; it's normal."
|
|
|
|
putStrLn " wait for the last line to see how it went.)"
|
2013-05-20 18:09:50 +00:00
|
|
|
rs <- runhunit =<< prepare False
|
2013-08-04 17:07:55 +00:00
|
|
|
#ifndef mingw32_HOST_OS
|
2013-05-20 18:09:50 +00:00
|
|
|
directrs <- runhunit =<< prepare True
|
2013-06-18 20:35:44 +00:00
|
|
|
#else
|
|
|
|
-- Windows is only going to use direct mode, so don't test twice.
|
|
|
|
let directrs = []
|
|
|
|
#endif
|
2013-02-28 03:35:37 +00:00
|
|
|
divider
|
2013-05-20 18:09:50 +00:00
|
|
|
propigate (rs++directrs) qcok
|
2013-02-28 03:35:37 +00:00
|
|
|
where
|
2013-04-03 07:52:41 +00:00
|
|
|
divider = putStrLn $ replicate 70 '-'
|
2013-05-20 18:09:50 +00:00
|
|
|
runhunit env = do
|
|
|
|
r <- forM hunit $ \t -> do
|
|
|
|
divider
|
|
|
|
t env
|
|
|
|
cleanup tmpdir
|
|
|
|
return r
|
2011-01-07 06:14:48 +00:00
|
|
|
|
2013-02-28 05:21:22 +00:00
|
|
|
propigate :: [Counts] -> Bool -> IO ()
|
|
|
|
propigate cs qcok
|
|
|
|
| countsok && qcok = putStrLn "All tests ok."
|
2013-02-28 03:35:37 +00:00
|
|
|
| otherwise = do
|
|
|
|
unless qcok $
|
|
|
|
putStrLn "Quick check tests failed! This is a bug in git-annex."
|
2013-02-28 05:21:22 +00:00
|
|
|
unless countsok $ do
|
2013-02-28 03:35:37 +00:00
|
|
|
putStrLn "Some tests failed!"
|
|
|
|
putStrLn " (This could be due to a bug in git-annex, or an incompatability"
|
|
|
|
putStrLn " with utilities, such as git, installed on this system.)"
|
|
|
|
exitFailure
|
|
|
|
where
|
2013-02-28 05:21:22 +00:00
|
|
|
noerrors (Counts { errors = e , failures = f }) = e + f == 0
|
|
|
|
countsok = all noerrors cs
|
2011-01-07 00:09:49 +00:00
|
|
|
|
2013-02-28 03:21:43 +00:00
|
|
|
quickcheck :: [IO Result]
|
|
|
|
quickcheck =
|
2013-02-28 03:26:14 +00:00
|
|
|
[ check "prop_idempotent_deencode_git" Git.Filename.prop_idempotent_deencode
|
|
|
|
, check "prop_idempotent_deencode" Utility.Format.prop_idempotent_deencode
|
|
|
|
, check "prop_idempotent_fileKey" Locations.prop_idempotent_fileKey
|
|
|
|
, check "prop_idempotent_key_encode" Types.Key.prop_idempotent_key_encode
|
|
|
|
, check "prop_idempotent_shellEscape" Utility.SafeCommand.prop_idempotent_shellEscape
|
|
|
|
, check "prop_idempotent_shellEscape_multiword" Utility.SafeCommand.prop_idempotent_shellEscape_multiword
|
|
|
|
, check "prop_idempotent_configEscape" Logs.Remote.prop_idempotent_configEscape
|
|
|
|
, check "prop_parse_show_Config" Logs.Remote.prop_parse_show_Config
|
|
|
|
, check "prop_parentDir_basics" Utility.Path.prop_parentDir_basics
|
|
|
|
, check "prop_relPathDirToFile_basics" Utility.Path.prop_relPathDirToFile_basics
|
|
|
|
, check "prop_relPathDirToFile_regressionTest" Utility.Path.prop_relPathDirToFile_regressionTest
|
2013-03-13 20:16:01 +00:00
|
|
|
, check "prop_cost_sane" Config.Cost.prop_cost_sane
|
2013-05-25 01:33:54 +00:00
|
|
|
, check "prop_matcher_sane" Utility.Matcher.prop_matcher_sane
|
2013-03-29 16:06:02 +00:00
|
|
|
, check "prop_HmacSha1WithCipher_sane" Crypto.prop_HmacSha1WithCipher_sane
|
2013-02-28 03:26:14 +00:00
|
|
|
, check "prop_TimeStamp_sane" Logs.UUIDBased.prop_TimeStamp_sane
|
|
|
|
, check "prop_addLog_sane" Logs.UUIDBased.prop_addLog_sane
|
|
|
|
, check "prop_verifiable_sane" Utility.Verifiable.prop_verifiable_sane
|
|
|
|
, check "prop_segment_regressionTest" Utility.Misc.prop_segment_regressionTest
|
|
|
|
, check "prop_read_write_transferinfo" Logs.Transfer.prop_read_write_transferinfo
|
|
|
|
, check "prop_read_show_inodecache" Utility.InodeCache.prop_read_show_inodecache
|
|
|
|
, check "prop_parse_show_log" Logs.Presence.prop_parse_show_log
|
|
|
|
, check "prop_read_show_TrustLevel" Types.TrustLevel.prop_read_show_TrustLevel
|
|
|
|
, check "prop_parse_show_TrustLog" Logs.Trust.prop_parse_show_TrustLog
|
2010-11-02 21:08:16 +00:00
|
|
|
]
|
2013-02-28 03:21:43 +00:00
|
|
|
where
|
2013-02-28 03:26:14 +00:00
|
|
|
check desc prop = do
|
2013-02-28 03:21:43 +00:00
|
|
|
putStrLn desc
|
|
|
|
quickCheckResult prop
|
2010-11-02 21:08:16 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
hunit :: [TestEnv -> IO Counts]
|
2013-02-28 05:21:22 +00:00
|
|
|
hunit =
|
2011-01-07 01:39:26 +00:00
|
|
|
-- test order matters, later tests may rely on state from earlier
|
2013-02-28 05:21:22 +00:00
|
|
|
[ check "init" test_init
|
|
|
|
, check "add" test_add
|
|
|
|
, check "reinject" test_reinject
|
|
|
|
, check "unannex" test_unannex
|
|
|
|
, check "drop" test_drop
|
|
|
|
, check "get" test_get
|
|
|
|
, check "move" test_move
|
|
|
|
, check "copy" test_copy
|
|
|
|
, check "lock" test_lock
|
|
|
|
, check "edit" test_edit
|
|
|
|
, check "fix" test_fix
|
|
|
|
, check "trust" test_trust
|
|
|
|
, check "fsck" test_fsck
|
|
|
|
, check "migrate" test_migrate
|
|
|
|
, check" unused" test_unused
|
|
|
|
, check "describe" test_describe
|
|
|
|
, check "find" test_find
|
|
|
|
, check "merge" test_merge
|
|
|
|
, check "status" test_status
|
|
|
|
, check "version" test_version
|
|
|
|
, check "sync" test_sync
|
2013-05-20 19:51:40 +00:00
|
|
|
, check "union merge regression" test_union_merge_regression
|
|
|
|
, check "conflict resolution" test_conflict_resolution
|
2013-02-28 05:21:22 +00:00
|
|
|
, check "map" test_map
|
|
|
|
, check "uninit" test_uninit
|
|
|
|
, check "upgrade" test_upgrade
|
|
|
|
, check "whereis" test_whereis
|
|
|
|
, check "hook remote" test_hook_remote
|
|
|
|
, check "directory remote" test_directory_remote
|
|
|
|
, check "rsync remote" test_rsync_remote
|
|
|
|
, check "bup remote" test_bup_remote
|
|
|
|
, check "crypto" test_crypto
|
2013-05-25 17:51:36 +00:00
|
|
|
, check "preferred content" test_preferred_content
|
2011-01-07 00:09:49 +00:00
|
|
|
]
|
2013-02-28 05:21:22 +00:00
|
|
|
where
|
2013-05-15 21:22:45 +00:00
|
|
|
check desc t env = do
|
2013-02-28 05:21:22 +00:00
|
|
|
putStrLn desc
|
2013-05-15 21:22:45 +00:00
|
|
|
runTestTT (t env)
|
2011-01-07 00:09:49 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_init :: TestEnv -> Test
|
|
|
|
test_init env = "git-annex init" ~: TestCase $ innewrepo env $ do
|
|
|
|
git_annex env "init" [reponame] @? "init failed"
|
2013-05-20 18:09:50 +00:00
|
|
|
handleforcedirect env
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
|
|
|
reponame = "test repo"
|
2011-01-07 00:09:49 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_add :: TestEnv -> Test
|
|
|
|
test_add env = "git-annex add" ~: TestList [basic, sha1dup, subdirs]
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
|
|
|
-- this test case runs in the main repo, to set up a basic
|
|
|
|
-- annexed file that later tests will use
|
2013-05-15 21:22:45 +00:00
|
|
|
basic = TestCase $ inmainrepo env $ do
|
2012-11-11 04:51:07 +00:00
|
|
|
writeFile annexedfile $ content annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "add" [annexedfile] @? "add failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
writeFile sha1annexedfile $ content sha1annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "add" [sha1annexedfile, "--backend=SHA1"] @? "add with SHA1 failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_present sha1annexedfile
|
|
|
|
checkbackend sha1annexedfile backendSHA1
|
|
|
|
writeFile wormannexedfile $ content wormannexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "add" [wormannexedfile, "--backend=WORM"] @? "add with WORM failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_present wormannexedfile
|
|
|
|
checkbackend wormannexedfile backendWORM
|
|
|
|
boolSystem "git" [Params "rm --force -q", File wormannexedfile] @? "git rm failed"
|
|
|
|
writeFile ingitfile $ content ingitfile
|
|
|
|
boolSystem "git" [Param "add", File ingitfile] @? "git add failed"
|
2013-05-15 23:33:27 +00:00
|
|
|
boolSystem "git" [Params "commit -q -m commit"] @? "git commit failed"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "add" [ingitfile] @? "add ingitfile should be no-op"
|
2012-11-11 04:51:07 +00:00
|
|
|
unannexed ingitfile
|
2013-05-15 21:22:45 +00:00
|
|
|
sha1dup = TestCase $ intmpclonerepo env $ do
|
2012-11-11 04:51:07 +00:00
|
|
|
writeFile sha1annexedfiledup $ content sha1annexedfiledup
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "add" [sha1annexedfiledup, "--backend=SHA1"] @? "add of second file with same SHA1 failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_present sha1annexedfiledup
|
|
|
|
annexed_present sha1annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
subdirs = TestCase $ intmpclonerepo env $ do
|
2012-11-11 04:51:07 +00:00
|
|
|
createDirectory "dir"
|
2013-06-18 19:15:00 +00:00
|
|
|
writeFile ("dir" </> "foo") $ content annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "add" ["dir"] @? "add of subdir failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
createDirectory "dir2"
|
2013-06-18 19:15:00 +00:00
|
|
|
writeFile ("dir2" </> "foo") $ content annexedfile
|
2013-08-04 17:07:55 +00:00
|
|
|
#ifndef mingw32_HOST_OS
|
2013-06-18 19:21:13 +00:00
|
|
|
{- This does not work on Windows, for whatever reason. -}
|
2013-05-11 23:14:30 +00:00
|
|
|
setCurrentDirectory "dir"
|
2013-06-18 19:15:00 +00:00
|
|
|
git_annex env "add" [".." </> "dir2"] @? "add of ../subdir failed"
|
2013-06-18 19:21:13 +00:00
|
|
|
#endif
|
2011-01-07 00:09:49 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_reinject :: TestEnv -> Test
|
2013-05-17 18:52:12 +00:00
|
|
|
test_reinject env = "git-annex reinject/fromkey" ~: TestCase $ intmpclonerepoInDirect env $ do
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "drop" ["--force", sha1annexedfile] @? "drop failed"
|
2011-01-11 23:59:11 +00:00
|
|
|
writeFile tmp $ content sha1annexedfile
|
2012-06-05 23:54:44 +00:00
|
|
|
r <- annexeval $ Types.Backend.getKey backendSHA1 $
|
2013-02-15 20:06:22 +00:00
|
|
|
Types.KeySource.KeySource { Types.KeySource.keyFilename = tmp, Types.KeySource.contentLocation = tmp, Types.KeySource.inodeCache = Nothing }
|
2012-08-08 20:06:01 +00:00
|
|
|
let key = Types.Key.key2file $ fromJust r
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "reinject" [tmp, sha1annexedfile] @? "reinject failed"
|
2013-05-15 23:58:40 +00:00
|
|
|
git_annex env "fromkey" [key, sha1annexedfiledup] @? "fromkey failed for dup"
|
2011-10-31 16:47:13 +00:00
|
|
|
annexed_present sha1annexedfiledup
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
|
|
|
tmp = "tmpfile"
|
2011-01-11 23:59:11 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_unannex :: TestEnv -> Test
|
|
|
|
test_unannex env = "git-annex unannex" ~: TestList [nocopy, withcopy]
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
2013-07-22 21:06:00 +00:00
|
|
|
nocopy = "no content" ~: intmpclonerepo env $ do
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "unannex" [annexedfile] @? "unannex failed with no copy"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-07-22 21:06:00 +00:00
|
|
|
withcopy = "with content" ~: intmpclonerepo env $ do
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [annexedfile] @? "get failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "unannex" [annexedfile, sha1annexedfile] @? "unannex failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
unannexed annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "unannex" [annexedfile] @? "unannex failed on non-annexed file"
|
2012-11-11 04:51:07 +00:00
|
|
|
unannexed annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "unannex" [ingitfile] @? "unannex ingitfile should be no-op"
|
2012-11-11 04:51:07 +00:00
|
|
|
unannexed ingitfile
|
2011-01-07 01:39:26 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_drop :: TestEnv -> Test
|
|
|
|
test_drop env = "git-annex drop" ~: TestList [noremote, withremote, untrustedremote]
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
2013-05-15 21:22:45 +00:00
|
|
|
noremote = "no remotes" ~: TestCase $ intmpclonerepo env $ do
|
|
|
|
git_annex env "get" [annexedfile] @? "get failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
boolSystem "git" [Params "remote rm origin"]
|
|
|
|
@? "git remote rm origin failed"
|
2013-05-15 21:22:45 +00:00
|
|
|
not <$> git_annex env "drop" [annexedfile] @? "drop wrongly succeeded with no known copy of file"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "drop" ["--force", annexedfile] @? "drop --force failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "drop" [annexedfile] @? "drop of dropped file failed"
|
|
|
|
git_annex env "drop" [ingitfile] @? "drop ingitfile should be no-op"
|
2012-11-11 04:51:07 +00:00
|
|
|
unannexed ingitfile
|
2013-05-15 21:22:45 +00:00
|
|
|
withremote = "with remote" ~: TestCase $ intmpclonerepo env $ do
|
|
|
|
git_annex env "get" [annexedfile] @? "get failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "drop" [annexedfile] @? "drop failed though origin has copy"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ annexed_present annexedfile
|
|
|
|
untrustedremote = "untrusted remote" ~: TestCase $ intmpclonerepo env $ do
|
|
|
|
git_annex env "untrust" ["origin"] @? "untrust of origin failed"
|
|
|
|
git_annex env "get" [annexedfile] @? "get failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
not <$> git_annex env "drop" [annexedfile] @? "drop wrongly suceeded with only an untrusted copy of the file"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ annexed_present annexedfile
|
2011-01-07 02:22:09 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_get :: TestEnv -> Test
|
|
|
|
test_get env = "git-annex get" ~: TestCase $ intmpclonerepo env $ do
|
|
|
|
inmainrepo env $ annexed_present annexedfile
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
|
|
|
inmainrepo env $ annexed_present annexedfile
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [annexedfile] @? "get of file already here failed"
|
|
|
|
inmainrepo env $ annexed_present annexedfile
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ unannexed ingitfile
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed ingitfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [ingitfile] @? "get ingitfile should be no-op"
|
|
|
|
inmainrepo env $ unannexed ingitfile
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed ingitfile
|
2011-01-07 05:02:06 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_move :: TestEnv -> Test
|
|
|
|
test_move env = "git-annex move" ~: TestCase $ intmpclonerepo env $ do
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ annexed_present annexedfile
|
|
|
|
git_annex env "move" ["--from", "origin", annexedfile] @? "move --from of file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ annexed_notpresent annexedfile
|
|
|
|
git_annex env "move" ["--from", "origin", annexedfile] @? "move --from of file already here failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ annexed_notpresent annexedfile
|
|
|
|
git_annex env "move" ["--to", "origin", annexedfile] @? "move --to of file failed"
|
|
|
|
inmainrepo env $ annexed_present annexedfile
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "move" ["--to", "origin", annexedfile] @? "move --to of file already there failed"
|
|
|
|
inmainrepo env $ annexed_present annexedfile
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_notpresent annexedfile
|
|
|
|
unannexed ingitfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ unannexed ingitfile
|
|
|
|
git_annex env "move" ["--to", "origin", ingitfile] @? "move of ingitfile should be no-op"
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed ingitfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ unannexed ingitfile
|
|
|
|
git_annex env "move" ["--from", "origin", ingitfile] @? "move of ingitfile should be no-op"
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed ingitfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ unannexed ingitfile
|
2011-01-07 06:14:48 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_copy :: TestEnv -> Test
|
|
|
|
test_copy env = "git-annex copy" ~: TestCase $ intmpclonerepo env $ do
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ annexed_present annexedfile
|
|
|
|
git_annex env "copy" ["--from", "origin", annexedfile] @? "copy --from of file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ annexed_present annexedfile
|
|
|
|
git_annex env "copy" ["--from", "origin", annexedfile] @? "copy --from of file already here failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ annexed_present annexedfile
|
|
|
|
git_annex env "copy" ["--to", "origin", annexedfile] @? "copy --to of file already there failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ annexed_present annexedfile
|
|
|
|
git_annex env "move" ["--to", "origin", annexedfile] @? "move --to of file already there failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ annexed_present annexedfile
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed ingitfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ unannexed ingitfile
|
|
|
|
git_annex env "copy" ["--to", "origin", ingitfile] @? "copy of ingitfile should be no-op"
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed ingitfile
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo env $ unannexed ingitfile
|
|
|
|
git_annex env "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
|
|
|
|
2013-05-25 17:51:36 +00:00
|
|
|
test_preferred_content :: TestEnv -> Test
|
|
|
|
test_preferred_content env = "git-annex preferred-content" ~: TestCase $ intmpclonerepo env $ do
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
-- get --auto only looks at numcopies when preferred content is not
|
|
|
|
-- set, and with 1 copy existing, does not get the file.
|
|
|
|
git_annex env "get" ["--auto", annexedfile] @? "get --auto of file failed with default preferred content"
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
|
|
|
|
git_annex env "content" [".", "standard"] @? "set expression to standard failed"
|
|
|
|
git_annex env "group" [".", "client"] @? "set group to standard failed"
|
|
|
|
git_annex env "get" ["--auto", annexedfile] @? "get --auto of file failed for client"
|
|
|
|
annexed_present annexedfile
|
|
|
|
git_annex env "ungroup" [".", "client"] @? "ungroup failed"
|
|
|
|
|
|
|
|
git_annex env "content" [".", "standard"] @? "set expression to standard failed"
|
|
|
|
git_annex env "group" [".", "manual"] @? "set group to manual failed"
|
|
|
|
-- drop --auto with manual leaves the file where it is
|
|
|
|
git_annex env "drop" ["--auto", annexedfile] @? "drop --auto of file failed with manual preferred content"
|
|
|
|
annexed_present annexedfile
|
|
|
|
git_annex env "drop" [annexedfile] @? "drop of file failed"
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
-- get --auto with manual does not get the file
|
|
|
|
git_annex env "get" ["--auto", annexedfile] @? "get --auto of file failed with manual preferred content"
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
git_annex env "ungroup" [".", "client"] @? "ungroup failed"
|
|
|
|
|
|
|
|
git_annex env "content" [".", "exclude=*"] @? "set expression to exclude=* failed"
|
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
git_annex env "drop" ["--auto", annexedfile] @? "drop --auto of file failed with exclude=*"
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
git_annex env "get" ["--auto", annexedfile] @? "get --auto of file failed with exclude=*"
|
|
|
|
annexed_notpresent annexedfile
|
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_lock :: TestEnv -> Test
|
2013-05-17 18:52:12 +00:00
|
|
|
test_lock env = "git-annex unlock/lock" ~: intmpclonerepoInDirect env $ do
|
2011-01-14 03:46:02 +00:00
|
|
|
-- regression test: unlock of not present file should skip it
|
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
not <$> git_annex env "unlock" [annexedfile] @? "unlock failed to fail with not present file"
|
2011-01-14 03:46:02 +00:00
|
|
|
annexed_notpresent annexedfile
|
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "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"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "lock" [annexedfile] @? "lock failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "unlock" [annexedfile] @? "unlock failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
unannexed annexedfile
|
|
|
|
changecontent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "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)
|
2013-05-15 21:22:45 +00:00
|
|
|
r' <- git_annex env "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
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_edit :: TestEnv -> Test
|
|
|
|
test_edit env = "git-annex edit/commit" ~: TestList [t False, t True]
|
2013-05-17 18:52:12 +00:00
|
|
|
where t precommit = TestCase $ intmpclonerepoInDirect env $ do
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "edit" [annexedfile] @? "edit failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
unannexed annexedfile
|
|
|
|
changecontent annexedfile
|
2013-05-16 02:10:49 +00:00
|
|
|
boolSystem "git" [Param "add", File annexedfile]
|
|
|
|
@? "git add of edited file failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
if precommit
|
2013-05-16 02:10:49 +00:00
|
|
|
then git_annex env "pre-commit" []
|
|
|
|
@? "pre-commit failed"
|
|
|
|
else boolSystem "git" [Params "commit -q -m contentchanged"]
|
|
|
|
@? "git commit of edited file failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
runchecks [checklink, checkunwritable] annexedfile
|
|
|
|
c <- readFile annexedfile
|
|
|
|
assertEqual "content of modified file" c (changedcontent annexedfile)
|
2013-05-15 21:22:45 +00:00
|
|
|
not <$> git_annex env "drop" [annexedfile] @? "drop wrongly succeeded with no known copy of modified file"
|
2011-01-07 18:06:32 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_fix :: TestEnv -> Test
|
2013-05-17 18:52:12 +00:00
|
|
|
test_fix env = "git-annex fix" ~: intmpclonerepoInDirect env $ do
|
2011-01-07 18:08:43 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "fix" [annexedfile] @? "fix of not present failed"
|
2011-01-07 18:08:43 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
2011-01-07 18:06:32 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "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"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "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)
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
|
|
|
subdir = "s"
|
|
|
|
newfile = subdir ++ "/" ++ annexedfile
|
2011-01-07 01:39:26 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_trust :: TestEnv -> Test
|
|
|
|
test_trust env = "git-annex trust/untrust/semitrust/dead" ~: intmpclonerepo env $ do
|
|
|
|
git_annex env "trust" [repo] @? "trust failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.Trusted "trusted 1"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "trust" [repo] @? "trust of trusted failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.Trusted "trusted 2"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "untrust" [repo] @? "untrust failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.UnTrusted "untrusted 1"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "untrust" [repo] @? "untrust of untrusted failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.UnTrusted "untrusted 2"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "dead" [repo] @? "dead failed"
|
2011-12-20 20:26:39 +00:00
|
|
|
trustcheck Logs.Trust.DeadTrusted "deadtrusted 1"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "dead" [repo] @? "dead of dead failed"
|
2011-12-20 20:26:39 +00:00
|
|
|
trustcheck Logs.Trust.DeadTrusted "deadtrusted 2"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "semitrust" [repo] @? "semitrust failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.SemiTrusted "semitrusted 1"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "semitrust" [repo] @? "semitrust of semitrusted failed"
|
2011-10-15 20:21:08 +00:00
|
|
|
trustcheck Logs.Trust.SemiTrusted "semitrusted 2"
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
|
|
|
repo = "origin"
|
|
|
|
trustcheck expected msg = do
|
|
|
|
present <- annexeval $ do
|
|
|
|
l <- Logs.Trust.trustGet expected
|
|
|
|
u <- Remote.nameToUUID repo
|
|
|
|
return $ u `elem` l
|
|
|
|
assertBool msg present
|
2011-01-11 22:50:18 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_fsck :: TestEnv -> Test
|
|
|
|
test_fsck env = "git-annex fsck" ~: TestList [basicfsck, barefsck, withlocaluntrusted, withremoteuntrusted]
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
2013-05-15 21:22:45 +00:00
|
|
|
basicfsck = TestCase $ intmpclonerepo env $ do
|
|
|
|
git_annex env "fsck" [] @? "fsck failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
boolSystem "git" [Params "config annex.numcopies 2"] @? "git config failed"
|
|
|
|
fsck_should_fail "numcopies unsatisfied"
|
|
|
|
boolSystem "git" [Params "config annex.numcopies 1"] @? "git config failed"
|
|
|
|
corrupt annexedfile
|
|
|
|
corrupt sha1annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
barefsck = TestCase $ intmpbareclonerepo env $ do
|
|
|
|
git_annex env "fsck" [] @? "fsck failed"
|
|
|
|
withlocaluntrusted = TestCase $ intmpclonerepo env $ do
|
|
|
|
git_annex env "get" [annexedfile] @? "get failed"
|
|
|
|
git_annex env "untrust" ["origin"] @? "untrust of origin repo failed"
|
|
|
|
git_annex env "untrust" ["."] @? "untrust of current repo failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
fsck_should_fail "content only available in untrusted (current) repository"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "trust" ["."] @? "trust of current repo failed"
|
|
|
|
git_annex env "fsck" [annexedfile] @? "fsck failed on file present in trusted repo"
|
|
|
|
withremoteuntrusted = TestCase $ intmpclonerepo env $ do
|
2012-11-11 04:51:07 +00:00
|
|
|
boolSystem "git" [Params "config annex.numcopies 2"] @? "git config failed"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [annexedfile] @? "get failed"
|
|
|
|
git_annex env "get" [sha1annexedfile] @? "get failed"
|
|
|
|
git_annex env "fsck" [] @? "fsck failed with numcopies=2 and 2 copies"
|
|
|
|
git_annex env "untrust" ["origin"] @? "untrust of origin failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
fsck_should_fail "content not replicated to enough non-untrusted repositories"
|
|
|
|
|
|
|
|
corrupt f = do
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [f] @? "get of file failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
Utility.FileMode.allowWrite f
|
|
|
|
writeFile f (changedcontent f)
|
2013-05-17 19:20:21 +00:00
|
|
|
ifM (annexeval Config.isDirect)
|
|
|
|
( git_annex env "fsck" [] @? "fsck failed in direct mode with changed file content"
|
|
|
|
, not <$> git_annex env "fsck" [] @? "fsck failed to fail with corrupted file content"
|
|
|
|
)
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "fsck" [] @? "fsck unexpectedly failed again; previous one did not fix problem with " ++ f
|
2012-11-11 04:51:07 +00:00
|
|
|
fsck_should_fail m = do
|
2013-05-15 21:22:45 +00:00
|
|
|
not <$> git_annex env "fsck" [] @? "fsck failed to fail with " ++ m
|
2011-01-11 23:34:28 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_migrate :: TestEnv -> Test
|
|
|
|
test_migrate env = "git-annex migrate" ~: TestList [t False, t True]
|
2013-05-17 18:52:12 +00:00
|
|
|
where t usegitattributes = TestCase $ intmpclonerepoInDirect env $ do
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_notpresent annexedfile
|
|
|
|
annexed_notpresent sha1annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "migrate" [annexedfile] @? "migrate of not present failed"
|
|
|
|
git_annex env "migrate" [sha1annexedfile] @? "migrate of not present failed"
|
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
|
|
|
git_annex env "get" [sha1annexedfile] @? "get of file failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
annexed_present sha1annexedfile
|
|
|
|
if usegitattributes
|
|
|
|
then do
|
|
|
|
writeFile ".gitattributes" $ "* annex.backend=SHA1"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "migrate" [sha1annexedfile]
|
2012-11-11 04:51:07 +00:00
|
|
|
@? "migrate sha1annexedfile failed"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "migrate" [annexedfile]
|
2012-11-11 04:51:07 +00:00
|
|
|
@? "migrate annexedfile failed"
|
|
|
|
else do
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "migrate" [sha1annexedfile, "--backend", "SHA1"]
|
2012-11-11 04:51:07 +00:00
|
|
|
@? "migrate sha1annexedfile failed"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "migrate" [annexedfile, "--backend", "SHA1"]
|
2012-11-11 04:51:07 +00:00
|
|
|
@? "migrate annexedfile failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
annexed_present sha1annexedfile
|
|
|
|
checkbackend annexedfile backendSHA1
|
|
|
|
checkbackend sha1annexedfile backendSHA1
|
|
|
|
|
|
|
|
-- check that reversing a migration works
|
|
|
|
writeFile ".gitattributes" $ "* annex.backend=SHA256"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "migrate" [sha1annexedfile]
|
2012-11-11 04:51:07 +00:00
|
|
|
@? "migrate sha1annexedfile failed"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "migrate" [annexedfile]
|
2012-11-11 04:51:07 +00:00
|
|
|
@? "migrate annexedfile failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
annexed_present sha1annexedfile
|
|
|
|
checkbackend annexedfile backendSHA256
|
|
|
|
checkbackend sha1annexedfile backendSHA256
|
2011-01-12 01:11:32 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_unused :: TestEnv -> Test
|
2013-05-17 19:16:28 +00:00
|
|
|
-- This test is broken in direct mode
|
|
|
|
test_unused env = "git-annex unused/dropunused" ~: intmpclonerepoInDirect env $ do
|
2011-01-12 05:58:23 +00:00
|
|
|
-- keys have to be looked up before files are removed
|
|
|
|
annexedfilekey <- annexeval $ findkey annexedfile
|
|
|
|
sha1annexedfilekey <- annexeval $ findkey sha1annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
|
|
|
git_annex env "get" [sha1annexedfile] @? "get of file failed"
|
2012-09-21 04:49:48 +00:00
|
|
|
checkunused [] "after get"
|
2013-05-17 18:52:12 +00:00
|
|
|
boolSystem "git" [Params "rm -fq", File annexedfile] @? "git rm failed"
|
2012-09-21 04:49:48 +00:00
|
|
|
checkunused [] "after rm"
|
2011-09-30 01:11:48 +00:00
|
|
|
boolSystem "git" [Params "commit -q -m foo"] @? "git commit failed"
|
2012-09-21 04:49:48 +00:00
|
|
|
checkunused [] "after commit"
|
2011-09-28 21:48:11 +00:00
|
|
|
-- unused checks origin/master; once it's gone it is really unused
|
|
|
|
boolSystem "git" [Params "remote rm origin"] @? "git remote rm origin failed"
|
2012-09-21 04:49:48 +00:00
|
|
|
checkunused [annexedfilekey] "after origin branches are gone"
|
2013-05-17 18:52:12 +00:00
|
|
|
boolSystem "git" [Params "rm -fq", File sha1annexedfile] @? "git rm failed"
|
2011-09-30 01:11:48 +00:00
|
|
|
boolSystem "git" [Params "commit -q -m foo"] @? "git commit failed"
|
2012-09-21 04:49:48 +00:00
|
|
|
checkunused [annexedfilekey, sha1annexedfilekey] "after rm sha1annexedfile"
|
2011-01-12 05:58:23 +00:00
|
|
|
|
|
|
|
-- good opportunity to test dropkey also
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "dropkey" ["--force", Types.Key.key2file annexedfilekey]
|
2011-01-12 05:58:23 +00:00
|
|
|
@? "dropkey failed"
|
2012-09-21 04:49:48 +00:00
|
|
|
checkunused [sha1annexedfilekey] ("after dropkey --force " ++ Types.Key.key2file annexedfilekey)
|
2011-01-12 05:58:23 +00:00
|
|
|
|
2013-07-30 18:17:09 +00:00
|
|
|
not <$> git_annex env "dropunused" ["1"] @? "dropunused failed to fail without --force"
|
|
|
|
git_annex env "dropunused" ["--force", "1"] @? "dropunused failed"
|
2012-09-21 04:49:48 +00:00
|
|
|
checkunused [] "after dropunused"
|
2013-07-30 18:17:09 +00:00
|
|
|
not <$> git_annex env "dropunused" ["--force", "10", "501"] @? "dropunused failed to fail on bogus numbers"
|
2011-01-12 05:58:23 +00:00
|
|
|
|
2013-08-22 14:29:50 +00:00
|
|
|
-- unused used to miss symlinks that were not staged and pointed
|
|
|
|
-- at annexed content, and think that content was unused
|
|
|
|
writeFile "unusedfile" "unusedcontent"
|
|
|
|
git_annex env "add" ["unusedfile"] @? "add of unusedfile failed"
|
|
|
|
unusedfilekey <- annexeval $ findkey "unusedfile"
|
|
|
|
renameFile "unusedfile" "unusedunstagedfile"
|
|
|
|
boolSystem "git" [Params "rm -qf", File "unusedfile"] @? "git rm failed"
|
|
|
|
checkunused [] "with unstaged link"
|
|
|
|
removeFile "unusedunstagedfile"
|
|
|
|
checkunused [unusedfilekey] "with unstaged link deleted"
|
|
|
|
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
|
|
|
checkunused expectedkeys desc = do
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "unused" [] @? "unused failed"
|
2012-11-11 04:51:07 +00:00
|
|
|
unusedmap <- annexeval $ Logs.Unused.readUnusedLog ""
|
|
|
|
let unusedkeys = M.elems unusedmap
|
|
|
|
assertEqual ("unused keys differ " ++ desc)
|
|
|
|
(sort expectedkeys) (sort unusedkeys)
|
|
|
|
findkey f = do
|
|
|
|
r <- Backend.lookupFile f
|
|
|
|
return $ fst $ fromJust r
|
2011-01-12 05:58:23 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_describe :: TestEnv -> Test
|
|
|
|
test_describe env = "git-annex describe" ~: intmpclonerepo env $ do
|
|
|
|
git_annex env "describe" [".", "this repo"] @? "describe 1 failed"
|
|
|
|
git_annex env "describe" ["origin", "origin repo"] @? "describe 2 failed"
|
2011-12-20 20:26:39 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_find :: TestEnv -> Test
|
|
|
|
test_find env = "git-annex find" ~: intmpclonerepo env $ do
|
2011-12-20 20:26:39 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex_expectoutput env "find" [] []
|
|
|
|
git_annex env "get" [annexedfile] @? "get failed"
|
2011-12-21 06:32:40 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
annexed_notpresent sha1annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex_expectoutput env "find" [] [annexedfile]
|
|
|
|
git_annex_expectoutput env "find" ["--exclude", annexedfile, "--and", "--exclude", sha1annexedfile] []
|
|
|
|
git_annex_expectoutput env "find" ["--include", annexedfile] [annexedfile]
|
|
|
|
git_annex_expectoutput env "find" ["--not", "--in", "origin"] []
|
|
|
|
git_annex_expectoutput env "find" ["--copies", "1", "--and", "--not", "--copies", "2"] [sha1annexedfile]
|
|
|
|
git_annex_expectoutput env "find" ["--inbackend", "SHA1"] [sha1annexedfile]
|
|
|
|
git_annex_expectoutput env "find" ["--inbackend", "WORM"] []
|
2011-12-20 20:26:39 +00:00
|
|
|
|
2013-02-26 17:49:22 +00:00
|
|
|
{- --include=* should match files in subdirectories too,
|
|
|
|
- and --exclude=* should exclude them. -}
|
|
|
|
createDirectory "dir"
|
|
|
|
writeFile "dir/subfile" "subfile"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "add" ["dir"] @? "add of subdir failed"
|
|
|
|
git_annex_expectoutput env "find" ["--include", "*", "--exclude", annexedfile, "--exclude", sha1annexedfile] ["dir/subfile"]
|
|
|
|
git_annex_expectoutput env "find" ["--exclude", "*"] []
|
2013-02-26 17:49:22 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_merge :: TestEnv -> Test
|
|
|
|
test_merge env = "git-annex merge" ~: intmpclonerepo env $ do
|
|
|
|
git_annex env "merge" [] @? "merge failed"
|
2011-12-20 20:26:39 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_status :: TestEnv -> Test
|
|
|
|
test_status env = "git-annex status" ~: intmpclonerepo env $ do
|
|
|
|
json <- git_annex_output env "status" ["--json"]
|
2013-02-28 03:21:43 +00:00
|
|
|
case Text.JSON.decodeStrict json :: Text.JSON.Result (Text.JSON.JSObject Text.JSON.JSValue) of
|
|
|
|
Text.JSON.Ok _ -> return ()
|
|
|
|
Text.JSON.Error e -> assertFailure e
|
2011-12-20 20:26:39 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_version :: TestEnv -> Test
|
|
|
|
test_version env = "git-annex version" ~: intmpclonerepo env $ do
|
|
|
|
git_annex env "version" [] @? "version failed"
|
2011-12-20 21:31:25 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_sync :: TestEnv -> Test
|
2013-07-30 21:03:50 +00:00
|
|
|
test_sync env = "git-annex sync" ~: intmpclonerepo env $ do
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "sync" [] @? "sync failed"
|
2013-07-30 21:03:50 +00:00
|
|
|
{- Regression test for bug fixed in
|
|
|
|
- 7b0970b340d7faeb745c666146c7f701ec71808f, where in direct mode
|
|
|
|
- sync committed the symlink standin file to the annex. -}
|
|
|
|
git_annex_expectoutput env "find" ["--in", "."] []
|
2011-12-20 20:26:39 +00:00
|
|
|
|
2013-05-20 19:51:40 +00:00
|
|
|
{- Regression test for union merge bug fixed in
|
2013-01-17 20:02:58 +00:00
|
|
|
- 0214e0fb175a608a49b812d81b4632c081f63027 -}
|
2013-05-20 19:51:40 +00:00
|
|
|
test_union_merge_regression :: TestEnv -> Test
|
|
|
|
test_union_merge_regression env = "union merge regression" ~:
|
2013-01-17 20:02:58 +00:00
|
|
|
{- We need 3 repos to see this bug. -}
|
2013-05-15 21:22:45 +00:00
|
|
|
withtmpclonerepo env False $ \r1 -> do
|
|
|
|
withtmpclonerepo env False $ \r2 -> do
|
|
|
|
withtmpclonerepo env False $ \r3 -> do
|
|
|
|
forM_ [r1, r2, r3] $ \r -> indir env r $ do
|
2013-01-17 20:02:58 +00:00
|
|
|
when (r /= r1) $
|
|
|
|
boolSystem "git" [Params "remote add r1", File ("../../" ++ r1)] @? "remote add"
|
|
|
|
when (r /= r2) $
|
|
|
|
boolSystem "git" [Params "remote add r2", File ("../../" ++ r2)] @? "remote add"
|
|
|
|
when (r /= r3) $
|
|
|
|
boolSystem "git" [Params "remote add r3", File ("../../" ++ r3)] @? "remote add"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [annexedfile] @? "get failed"
|
2013-01-17 20:02:58 +00:00
|
|
|
boolSystem "git" [Params "remote rm origin"] @? "remote rm"
|
2013-05-15 21:22:45 +00:00
|
|
|
forM_ [r3, r2, r1] $ \r -> indir env r $
|
|
|
|
git_annex env "sync" [] @? "sync failed"
|
|
|
|
forM_ [r3, r2] $ \r -> indir env r $
|
|
|
|
git_annex env "drop" ["--force", annexedfile] @? "drop failed"
|
|
|
|
indir env r1 $ do
|
|
|
|
git_annex env "sync" [] @? "sync failed in r1"
|
|
|
|
git_annex_expectoutput env "find" ["--in", "r3"] []
|
2013-01-17 20:02:58 +00:00
|
|
|
{- This was the bug. The sync
|
|
|
|
- mangled location log data and it
|
|
|
|
- thought the file was still in r2 -}
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex_expectoutput env "find" ["--in", "r2"] []
|
2013-01-17 20:02:58 +00:00
|
|
|
|
2013-05-20 19:51:40 +00:00
|
|
|
{- Regression test for the automatic conflict resolution bug fixed
|
|
|
|
- in f4ba19f2b8a76a1676da7bb5850baa40d9c388e2. -}
|
|
|
|
test_conflict_resolution :: TestEnv -> Test
|
|
|
|
test_conflict_resolution env = "automatic conflict resolution" ~:
|
|
|
|
withtmpclonerepo env False $ \r1 -> do
|
|
|
|
withtmpclonerepo env False $ \r2 -> do
|
|
|
|
let rname r = if r == r1 then "r1" else "r2"
|
|
|
|
forM_ [r1, r2] $ \r -> indir env r $ do
|
|
|
|
{- Get all files, see check below. -}
|
|
|
|
git_annex env "get" [] @? "get failed"
|
|
|
|
{- Set up repos as remotes of each other;
|
|
|
|
- remove origin since we're going to sync
|
|
|
|
- some changes to a file. -}
|
|
|
|
when (r /= r1) $
|
|
|
|
boolSystem "git" [Params "remote add r1", File ("../../" ++ r1)] @? "remote add"
|
|
|
|
when (r /= r2) $
|
|
|
|
boolSystem "git" [Params "remote add r2", File ("../../" ++ r2)] @? "remote add"
|
|
|
|
boolSystem "git" [Params "remote rm origin"] @? "remote rm"
|
|
|
|
|
|
|
|
{- Set up a conflict. -}
|
|
|
|
let newcontent = content annexedfile ++ rname r
|
|
|
|
ifM (annexeval Config.isDirect)
|
|
|
|
( writeFile annexedfile newcontent
|
|
|
|
, do
|
|
|
|
git_annex env "unlock" [annexedfile] @? "unlock failed"
|
|
|
|
writeFile annexedfile newcontent
|
|
|
|
)
|
|
|
|
{- Sync twice in r1 so it gets the conflict resolution
|
|
|
|
- update from r2 -}
|
|
|
|
forM_ [r1, r2, r1] $ \r -> indir env r $ do
|
|
|
|
git_annex env "sync" [] @? "sync failed in " ++ rname r
|
|
|
|
{- After the sync, it should be possible to get all
|
|
|
|
- files. This includes both sides of the conflict,
|
|
|
|
- although the filenames are not easily predictable.
|
|
|
|
-
|
|
|
|
- The bug caused, in direct mode, one repo to
|
|
|
|
- be missing the content of the file that had
|
|
|
|
- been put in it. -}
|
|
|
|
forM_ [r1, r2] $ \r -> indir env r $ do
|
|
|
|
git_annex env "get" [] @? "unable to get all files after merge conflict resolution in " ++ rname r
|
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_map :: TestEnv -> Test
|
|
|
|
test_map env = "git-annex map" ~: intmpclonerepo env $ do
|
2011-12-20 20:31:59 +00:00
|
|
|
-- set descriptions, that will be looked for in the map
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "describe" [".", "this repo"] @? "describe 1 failed"
|
|
|
|
git_annex env "describe" ["origin", "origin repo"] @? "describe 2 failed"
|
2011-12-20 20:31:59 +00:00
|
|
|
-- --fast avoids it running graphviz, not a build dependency
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "map" ["--fast"] @? "map failed"
|
2011-12-20 21:31:25 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_uninit :: TestEnv -> Test
|
2013-07-22 21:06:00 +00:00
|
|
|
test_uninit env = "git-annex uninit" ~: TestList [inbranch, normal]
|
|
|
|
where
|
|
|
|
inbranch = "in branch" ~: intmpclonerepoInDirect env $ do
|
|
|
|
boolSystem "git" [Params "checkout git-annex"] @? "git checkout git-annex"
|
|
|
|
not <$> git_annex env "uninit" [] @? "uninit failed to fail when git-annex branch was checked out"
|
|
|
|
normal = "normal" ~: intmpclonerepo env $ do
|
|
|
|
git_annex env "get" [] @? "get failed"
|
|
|
|
annexed_present annexedfile
|
|
|
|
_ <- git_annex env "uninit" [] -- exit status not checked; does abnormal exit
|
|
|
|
checkregularfile annexedfile
|
|
|
|
doesDirectoryExist ".git" @? ".git vanished in uninit"
|
|
|
|
not <$> doesDirectoryExist ".git/annex" @? ".git/annex still present after uninit"
|
2011-12-20 21:31:25 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_upgrade :: TestEnv -> Test
|
|
|
|
test_upgrade env = "git-annex upgrade" ~: intmpclonerepo env $ do
|
|
|
|
git_annex env "upgrade" [] @? "upgrade from same version failed"
|
2011-12-20 21:31:25 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_whereis :: TestEnv -> Test
|
|
|
|
test_whereis env = "git-annex whereis" ~: intmpclonerepo env $ do
|
2011-12-20 21:31:25 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "whereis" [annexedfile] @? "whereis on non-present file failed"
|
|
|
|
git_annex env "untrust" ["origin"] @? "untrust failed"
|
|
|
|
not <$> git_annex env "whereis" [annexedfile] @? "whereis on non-present file only present in untrusted repo failed to fail"
|
|
|
|
git_annex env "get" [annexedfile] @? "get failed"
|
2011-12-20 21:31:25 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "whereis" [annexedfile] @? "whereis on present file failed"
|
2011-12-20 20:31:59 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_hook_remote :: TestEnv -> Test
|
|
|
|
test_hook_remote env = "git-annex hook remote" ~: intmpclonerepo env $ do
|
2013-08-04 17:07:55 +00:00
|
|
|
#ifndef mingw32_HOST_OS
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "initremote" (words "foo type=hook encryption=none hooktype=foo") @? "initremote failed"
|
2011-12-20 19:13:36 +00:00
|
|
|
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"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
2011-12-20 19:13:36 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "copy" [annexedfile, "--to", "foo"] @? "copy --to hook remote failed"
|
2011-12-20 19:13:36 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "drop" [annexedfile, "--numcopies=2"] @? "drop failed"
|
2011-12-20 19:13:36 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "move" [annexedfile, "--from", "foo"] @? "move --from hook remote failed"
|
2011-12-20 19:13:36 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
not <$> git_annex env "drop" [annexedfile, "--numcopies=2"] @? "drop failed to fail"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
|
|
|
dir = "dir"
|
|
|
|
loc = dir ++ "/$ANNEX_KEY"
|
|
|
|
git_config k v = boolSystem "git" [Param "config", Param k, Param v]
|
|
|
|
@? "git config failed"
|
2013-06-18 20:12:43 +00:00
|
|
|
#else
|
|
|
|
-- this test doesn't work in Windows TODO
|
|
|
|
noop
|
|
|
|
#endif
|
2011-12-20 19:13:36 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_directory_remote :: TestEnv -> Test
|
|
|
|
test_directory_remote env = "git-annex directory remote" ~: intmpclonerepo env $ do
|
2011-12-20 19:17:56 +00:00
|
|
|
createDirectory "dir"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "initremote" (words $ "foo type=directory encryption=none directory=dir") @? "initremote failed"
|
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "copy" [annexedfile, "--to", "foo"] @? "copy --to directory remote failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "drop" [annexedfile, "--numcopies=2"] @? "drop failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "move" [annexedfile, "--from", "foo"] @? "move --from directory remote failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
not <$> git_annex env "drop" [annexedfile, "--numcopies=2"] @? "drop failed to fail"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_rsync_remote :: TestEnv -> Test
|
|
|
|
test_rsync_remote env = "git-annex rsync remote" ~: intmpclonerepo env $ do
|
2013-08-04 17:07:55 +00:00
|
|
|
#ifndef mingw32_HOST_OS
|
2011-12-20 19:17:56 +00:00
|
|
|
createDirectory "dir"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "initremote" (words $ "foo type=rsync encryption=none rsyncurl=dir") @? "initremote failed"
|
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "copy" [annexedfile, "--to", "foo"] @? "copy --to rsync remote failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "drop" [annexedfile, "--numcopies=2"] @? "drop failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "move" [annexedfile, "--from", "foo"] @? "move --from rsync remote failed"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
not <$> git_annex env "drop" [annexedfile, "--numcopies=2"] @? "drop failed to fail"
|
2011-12-20 19:17:56 +00:00
|
|
|
annexed_present annexedfile
|
2013-06-18 20:12:43 +00:00
|
|
|
#else
|
|
|
|
-- this test doesn't work in Windows TODO
|
|
|
|
noop
|
|
|
|
#endif
|
2011-12-20 19:17:56 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
test_bup_remote :: TestEnv -> Test
|
|
|
|
test_bup_remote env = "git-annex bup remote" ~: intmpclonerepo env $ 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
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "initremote" (words $ "foo type=bup encryption=none buprepo="++dir) @? "initremote failed"
|
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
2011-12-21 17:50:33 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "copy" [annexedfile, "--to", "foo"] @? "copy --to bup remote failed"
|
2011-12-21 17:50:33 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "drop" [annexedfile, "--numcopies=2"] @? "drop failed"
|
2011-12-21 17:50:33 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "copy" [annexedfile, "--from", "foo"] @? "copy --from bup remote failed"
|
2011-12-21 17:50:33 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
not <$> git_annex env "move" [annexedfile, "--from", "foo"] @? "move --from bup remote failed to fail"
|
2011-12-21 17:50:33 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
|
2011-12-21 18:10:36 +00:00
|
|
|
-- gpg is not a build dependency, so only test when it's available
|
2013-05-15 21:22:45 +00:00
|
|
|
test_crypto :: TestEnv -> Test
|
2013-05-19 21:59:58 +00:00
|
|
|
test_crypto env = "git-annex crypto" ~: intmpclonerepo env $ whenM (Utility.Path.inPath Utility.Gpg.gpgcmd) $ do
|
2013-08-04 17:07:55 +00:00
|
|
|
#ifndef mingw32_HOST_OS
|
2011-12-21 18:10:36 +00:00
|
|
|
Utility.Gpg.testTestHarness @? "test harness self-test failed"
|
|
|
|
Utility.Gpg.testHarness $ do
|
|
|
|
createDirectory "dir"
|
2013-05-15 21:22:45 +00:00
|
|
|
let a cmd = git_annex env cmd
|
2011-12-21 18:10:36 +00:00
|
|
|
[ "foo"
|
|
|
|
, "type=directory"
|
|
|
|
, "encryption=" ++ Utility.Gpg.testKeyId
|
|
|
|
, "directory=dir"
|
2013-04-05 19:06:16 +00:00
|
|
|
, "highRandomQuality=false"
|
2011-12-21 18:10:36 +00:00
|
|
|
]
|
2013-05-01 06:23:52 +00:00
|
|
|
a "initremote" @? "initremote failed"
|
|
|
|
not <$> a "initremote" @? "initremote failed to fail when run twice in a row"
|
|
|
|
a "enableremote" @? "enableremote failed"
|
|
|
|
a "enableremote" @? "enableremote failed when run twice in a row"
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "get" [annexedfile] @? "get of file failed"
|
2011-12-21 18:10:36 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "copy" [annexedfile, "--to", "foo"] @? "copy --to encrypted remote failed"
|
2011-12-21 18:10:36 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "drop" [annexedfile, "--numcopies=2"] @? "drop failed"
|
2011-12-21 18:10:36 +00:00
|
|
|
annexed_notpresent annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex env "move" [annexedfile, "--from", "foo"] @? "move --from encrypted remote failed"
|
2011-12-21 18:10:36 +00:00
|
|
|
annexed_present annexedfile
|
2013-05-15 21:22:45 +00:00
|
|
|
not <$> git_annex env "drop" [annexedfile, "--numcopies=2"] @? "drop failed to fail"
|
2013-05-17 20:49:34 +00:00
|
|
|
annexed_present annexedfile
|
|
|
|
#else
|
2013-05-17 20:52:50 +00:00
|
|
|
putStrLn "gpg testing not implemented on Windows"
|
2013-05-17 20:49:34 +00:00
|
|
|
#endif
|
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
|
2013-05-17 20:45:44 +00:00
|
|
|
-- (when the OS allows) so test coverage collection works.
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex :: TestEnv -> String -> [String] -> IO Bool
|
|
|
|
git_annex env command params = do
|
2013-08-04 17:07:55 +00:00
|
|
|
#ifndef mingw32_HOST_OS
|
2013-05-15 21:22:45 +00:00
|
|
|
forM_ (M.toList env) $ \(var, val) ->
|
|
|
|
Utility.Env.setEnv var val True
|
|
|
|
|
2011-01-07 01:39:26 +00:00
|
|
|
-- catch all errors, including normally fatal errors
|
2012-02-03 20:57:07 +00:00
|
|
|
r <- try (run)::IO (Either SomeException ())
|
2011-01-07 00:26:57 +00:00
|
|
|
case r of
|
|
|
|
Right _ -> return True
|
|
|
|
Left _ -> return False
|
2012-11-11 04:51:07 +00:00
|
|
|
where
|
|
|
|
run = GitAnnex.run (command:"-q":params)
|
2013-05-17 20:45:44 +00:00
|
|
|
#else
|
|
|
|
Utility.SafeCommand.boolSystemEnv "git-annex"
|
|
|
|
(map Param $ command : params)
|
|
|
|
(Just $ M.toList env)
|
|
|
|
#endif
|
2011-01-07 00:09:49 +00:00
|
|
|
|
2011-12-21 06:32:40 +00:00
|
|
|
{- Runs git-annex and returns its output. -}
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex_output :: TestEnv -> String -> [String] -> IO String
|
|
|
|
git_annex_output env command params = do
|
2013-05-17 20:45:44 +00:00
|
|
|
got <- Utility.Process.readProcessEnv "git-annex" (command:params)
|
|
|
|
(Just $ M.toList env)
|
2011-12-21 06:32:40 +00:00
|
|
|
-- XXX since the above is a separate process, code coverage stats are
|
|
|
|
-- not gathered for things run in it.
|
2012-10-11 17:45:09 +00:00
|
|
|
-- Run same command again, to get code coverage.
|
2013-05-15 21:22:45 +00:00
|
|
|
_ <- git_annex env command params
|
2011-12-21 06:32:40 +00:00
|
|
|
return got
|
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
git_annex_expectoutput :: TestEnv -> String -> [String] -> [String] -> IO ()
|
|
|
|
git_annex_expectoutput env command params expected = do
|
|
|
|
got <- lines <$> git_annex_output env command params
|
2011-12-21 06:32:40 +00:00
|
|
|
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
|
2012-05-18 22:20:53 +00:00
|
|
|
s <- Annex.new =<< Git.CurrentRepo.get
|
2012-04-30 17:59:05 +00:00
|
|
|
Annex.eval s $ do
|
|
|
|
Annex.setOutput Types.Messages.QuietOutput
|
|
|
|
a
|
2011-01-11 22:50:18 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
innewrepo :: TestEnv -> Assertion -> Assertion
|
|
|
|
innewrepo env a = withgitrepo env $ \r -> indir env r a
|
2011-01-07 01:39:26 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
inmainrepo :: TestEnv -> Assertion -> Assertion
|
|
|
|
inmainrepo env a = indir env mainrepodir a
|
2011-01-07 01:39:26 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
intmpclonerepo :: TestEnv -> Assertion -> Assertion
|
|
|
|
intmpclonerepo env a = withtmpclonerepo env False $ \r -> indir env r a
|
2011-12-21 18:20:41 +00:00
|
|
|
|
2013-05-17 18:52:12 +00:00
|
|
|
intmpclonerepoInDirect :: TestEnv -> Assertion -> Assertion
|
|
|
|
intmpclonerepoInDirect env a = intmpclonerepo env $
|
|
|
|
ifM isdirect
|
|
|
|
( putStrLn "not supported in direct mode; skipping"
|
|
|
|
, a
|
|
|
|
)
|
|
|
|
where
|
|
|
|
isdirect = annexeval $ do
|
|
|
|
Init.initialize Nothing
|
|
|
|
Config.isDirect
|
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
intmpbareclonerepo :: TestEnv -> Assertion -> Assertion
|
|
|
|
intmpbareclonerepo env a = withtmpclonerepo env True $ \r -> indir env r a
|
2011-01-07 02:22:09 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
withtmpclonerepo :: TestEnv -> Bool -> (FilePath -> Assertion) -> Assertion
|
|
|
|
withtmpclonerepo env bare a = do
|
2013-01-17 20:02:58 +00:00
|
|
|
dir <- tmprepodir
|
2013-05-15 21:22:45 +00:00
|
|
|
bracket (clonerepo env mainrepodir dir bare) cleanup a
|
2011-01-07 02:22:09 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
withgitrepo :: TestEnv -> (FilePath -> Assertion) -> Assertion
|
|
|
|
withgitrepo env = bracket (setuprepo env mainrepodir) return
|
2011-01-07 01:39:26 +00:00
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
indir :: TestEnv -> FilePath -> Assertion -> Assertion
|
|
|
|
indir env 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.
|
2013-05-15 21:22:45 +00:00
|
|
|
r <- bracket_ (changeToTmpDir env dir) (setCurrentDirectory cwd)
|
2012-02-03 20:57:07 +00:00
|
|
|
(try (a)::IO (Either SomeException ()))
|
2011-01-08 19:00:04 +00:00
|
|
|
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
|
|
|
|
2013-05-15 21:22:45 +00:00
|
|
|
setuprepo :: TestEnv -> FilePath -> IO FilePath
|
|
|
|
setuprepo env dir = do
|
2011-01-07 01:39:26 +00:00
|
|
|
cleanup dir
|
|
|
|
ensuretmpdir
|
2011-08-22 20:14:12 +00:00
|
|
|
boolSystem "git" [Params "init -q", File dir] @? "git init failed"
|
2013-05-15 21:22:45 +00:00
|
|
|
indir env 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
|
2013-05-15 21:22:45 +00:00
|
|
|
clonerepo :: TestEnv -> FilePath -> FilePath -> Bool -> IO FilePath
|
|
|
|
clonerepo env 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"
|
2013-05-15 21:22:45 +00:00
|
|
|
indir env new $
|
|
|
|
git_annex env "init" ["-q", new] @? "git annex init failed"
|
2013-05-20 18:09:50 +00:00
|
|
|
when (not bare) $
|
|
|
|
indir env new $
|
|
|
|
handleforcedirect env
|
2011-01-07 02:22:09 +00:00
|
|
|
return new
|
2013-05-20 18:09:50 +00:00
|
|
|
|
|
|
|
handleforcedirect :: TestEnv -> IO ()
|
|
|
|
handleforcedirect env = when (M.lookup "FORCEDIRECT" env == Just "1") $
|
|
|
|
git_annex env "direct" ["-q"] @? "git annex direct failed"
|
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 >>=
|
2013-03-31 20:38:05 +00:00
|
|
|
mapM_ Utility.FileMode.allowWrite
|
2013-06-18 20:35:44 +00:00
|
|
|
-- For unknown reasons, this sometimes fails on Windows.
|
2013-06-18 17:41:33 +00:00
|
|
|
void $ tryIO $ removeDirectoryRecursive dir
|
2011-01-07 02:22:09 +00:00
|
|
|
|
|
|
|
checklink :: FilePath -> Assertion
|
|
|
|
checklink f = do
|
|
|
|
s <- getSymbolicLinkStatus f
|
2013-05-15 23:58:40 +00:00
|
|
|
-- in direct mode, it may be a symlink, or not, depending
|
|
|
|
-- on whether the content is present.
|
|
|
|
unlessM (annexeval Config.isDirect) $
|
|
|
|
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
|
2013-05-25 17:51:36 +00:00
|
|
|
c <- Utility.Exception.catchDefaultIO "could not read file" $ readFile f
|
2013-05-15 23:58:40 +00:00
|
|
|
assertEqual ("checkcontent " ++ f) (content f) c
|
2011-01-07 02:22:09 +00:00
|
|
|
|
|
|
|
checkunwritable :: FilePath -> Assertion
|
2013-05-15 23:58:40 +00:00
|
|
|
checkunwritable f = unlessM (annexeval Config.isDirect) $ do
|
|
|
|
-- 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
|
2012-02-03 20:57:07 +00:00
|
|
|
r <- tryIO $ writeFile f $ content f
|
2011-01-07 18:06:32 +00:00
|
|
|
case r of
|
|
|
|
Left _ -> assertFailure $ "unable to modify " ++ f
|
|
|
|
Right _ -> return ()
|
|
|
|
|
2011-01-07 02:22:09 +00:00
|
|
|
checkdangling :: FilePath -> Assertion
|
2013-05-15 23:33:27 +00:00
|
|
|
checkdangling f = ifM (annexeval Config.crippledFileSystem)
|
|
|
|
( return () -- probably no real symlinks to test
|
|
|
|
, do
|
|
|
|
r <- tryIO $ 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
|
2012-01-10 17:11:16 +00:00
|
|
|
uuids <- annexeval $ Remote.keyLocations k
|
2012-08-08 20:06:01 +00:00
|
|
|
assertEqual ("bad content in location log for " ++ f ++ " key " ++ (Types.Key.key2file 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-31 08:11:39 +00:00
|
|
|
checkbackend :: FilePath -> Types.Backend -> Assertion
|
2011-12-21 18:10:36 +00:00
|
|
|
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]
|
|
|
|
|
2013-05-20 18:09:50 +00:00
|
|
|
prepare :: Bool -> IO TestEnv
|
|
|
|
prepare forcedirect = do
|
2013-02-27 19:48:26 +00:00
|
|
|
whenM (doesDirectoryExist tmpdir) $
|
|
|
|
error $ "The temporary directory " ++ tmpdir ++ " already exists; cannot run test suite."
|
2013-02-27 19:35:07 +00:00
|
|
|
|
2011-01-07 18:06:32 +00:00
|
|
|
cwd <- getCurrentDirectory
|
2013-05-15 21:22:45 +00:00
|
|
|
p <- Utility.Env.getEnvDefault "PATH" ""
|
|
|
|
|
|
|
|
let env =
|
|
|
|
-- Ensure that the just-built git annex is used.
|
2013-07-30 20:57:17 +00:00
|
|
|
[ ("PATH", cwd ++ [searchPathSeparator] ++ p)
|
2013-05-15 21:22:45 +00:00
|
|
|
, ("TOPDIR", cwd)
|
|
|
|
-- Avoid git complaining if it cannot determine the user's
|
|
|
|
-- email address, or exploding if it doesn't know the user's
|
|
|
|
-- name.
|
|
|
|
, ("GIT_AUTHOR_EMAIL", "test@example.com")
|
|
|
|
, ("GIT_AUTHOR_NAME", "git-annex test")
|
|
|
|
, ("GIT_COMMITTER_EMAIL", "test@example.com")
|
|
|
|
, ("GIT_COMMITTER_NAME", "git-annex test")
|
|
|
|
-- force gpg into batch mode for the tests
|
|
|
|
, ("GPG_BATCH", "1")
|
2013-05-20 18:09:50 +00:00
|
|
|
, ("FORCEDIRECT", if forcedirect then "1" else "")
|
2013-05-15 21:22:45 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
return $ M.fromList env
|
|
|
|
|
|
|
|
changeToTmpDir :: TestEnv -> FilePath -> IO ()
|
|
|
|
changeToTmpDir env t = do
|
|
|
|
let topdir = fromMaybe "" $ M.lookup "TOPDIR" env
|
2013-05-11 23:14:30 +00:00
|
|
|
setCurrentDirectory $ topdir ++ "/" ++ t
|
2011-01-07 18:06:32 +00:00
|
|
|
|
|
|
|
tmpdir :: String
|
2011-01-07 01:39:26 +00:00
|
|
|
tmpdir = ".t"
|
|
|
|
|
2013-01-17 20:02:58 +00:00
|
|
|
mainrepodir :: FilePath
|
2013-06-18 18:08:35 +00:00
|
|
|
mainrepodir = tmpdir </> "repo"
|
2011-01-07 01:39:26 +00:00
|
|
|
|
2013-01-17 20:02:58 +00:00
|
|
|
tmprepodir :: IO FilePath
|
|
|
|
tmprepodir = go (0 :: Int)
|
|
|
|
where
|
|
|
|
go n = do
|
2013-06-18 18:08:35 +00:00
|
|
|
let d = tmpdir </> "tmprepo" ++ show n
|
2013-01-17 20:02:58 +00:00
|
|
|
ifM (doesDirectoryExist d)
|
|
|
|
( go $ n + 1
|
|
|
|
, return d
|
|
|
|
)
|
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
|
|
|
|
2011-12-31 08:11:39 +00:00
|
|
|
backendSHA1 :: Types.Backend
|
2011-03-02 17:47:45 +00:00
|
|
|
backendSHA1 = backend_ "SHA1"
|
|
|
|
|
2011-12-31 08:11:39 +00:00
|
|
|
backendSHA256 :: Types.Backend
|
2011-12-20 20:06:15 +00:00
|
|
|
backendSHA256 = backend_ "SHA256"
|
2011-03-02 17:47:45 +00:00
|
|
|
|
2011-12-31 08:11:39 +00:00
|
|
|
backendWORM :: Types.Backend
|
2011-12-21 18:10:36 +00:00
|
|
|
backendWORM = backend_ "WORM"
|
|
|
|
|
2011-12-31 08:11:39 +00:00
|
|
|
backend_ :: String -> Types.Backend
|
2011-07-05 22:31:46 +00:00
|
|
|
backend_ name = Backend.lookupBackendName name
|