summaryrefslogtreecommitdiff
path: root/Test.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-04 14:31:26 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-04 14:31:26 -0400
commitd30e87fa9ded2f7b2c1f8ecbb8d95bc080993b18 (patch)
treebcd14e8af8d91336168d58679854581cef1d2ed9 /Test.hs
parentd1039b1f632c6e9b90ef2279122cc9d684381bcb (diff)
much improved test and real fix for FAT symlink loss on conflicted merge
I think that f5ce1a15d7a35b85ffa938ee950f4749bf445939 didn't quite manage to actually fix the bug, although I have not checked since its "fix" got redone. The test suite now actually checks the file staged in git is a symlink, rather than relying on the bug casing a later sync failure. This seems a more reliable way to detect it, and probably avoids a heisenbug in the test suite.
Diffstat (limited to 'Test.hs')
-rw-r--r--Test.hs48
1 files changed, 31 insertions, 17 deletions
diff --git a/Test.hs b/Test.hs
index 9a2c8bee5..346066893 100644
--- a/Test.hs
+++ b/Test.hs
@@ -33,6 +33,8 @@ import qualified Backend
import qualified Git.CurrentRepo
import qualified Git.Filename
import qualified Git.Types
+import qualified Git.Ref
+import qualified Git.LsTree
import qualified Locations
import qualified Types.KeySource
import qualified Types.Backend
@@ -199,7 +201,7 @@ unitTests note getenv = testGroup ("Unit Tests " ++ note)
, check "union merge regression" test_union_merge_regression
, check "conflict resolution" test_conflict_resolution_movein_bug
, check "conflict resolution (mixed directory and file)" test_mixed_conflict_resolution
- , check "conflict resolution push" test_conflict_resolution_push
+ , check "conflict resolution symlinks" test_conflict_resolution_symlinks
, check "conflict resolution (uncommitted local file)" test_uncommitted_conflict_resolution
, check "map" test_map
, check "uninit" test_uninit
@@ -897,25 +899,37 @@ test_uncommitted_conflict_resolution env = do
localcontent = "local"
annexedcontent = "annexed"
-{- A push failure that sometimes happens after conflict resolution
- - on Windows/FAT. Note that something nondeterministic seems to be
- - involved in the bug.
+{- On Windows/FAT, repeated conflict resolution sometimes
+ - lost track of whether a file was a symlink.
-}
-test_conflict_resolution_push :: TestEnv -> Assertion
-test_conflict_resolution_push env = go >> go
- where
- go = withtmpclonerepo env False $ \r1 ->
+test_conflict_resolution_symlinks :: TestEnv -> Assertion
+test_conflict_resolution_symlinks env = do
+ withtmpclonerepo env False $ \r1 ->
withtmpclonerepo env False $ \r2 -> do
- indir env r1 $ do
- writeFile conflictor "conflictor"
- git_annex env "add" [conflictor] @? "add conflicter failed"
- git_annex env "sync" [] @? "sync failed in r1"
- indir env r2 $ do
- createDirectory conflictor
- writeFile (conflictor </> "subfile") "subfile"
- git_annex env "add" [conflictor] @? "add conflicter failed"
- git_annex env "sync" [] @? "sync failed in r2"
+ withtmpclonerepo env False $ \r3 -> do
+ indir env r1 $ do
+ writeFile conflictor "conflictor"
+ git_annex env "add" [conflictor] @? "add conflicter failed"
+ git_annex env "sync" [] @? "sync failed in r1"
+ check_is_link conflictor "r1"
+ indir env r2 $ do
+ createDirectory conflictor
+ writeFile (conflictor </> "subfile") "subfile"
+ git_annex env "add" [conflictor] @? "add conflicter failed"
+ git_annex env "sync" [] @? "sync failed in r2"
+ check_is_link (conflictor </> "subfile") "r2"
+ indir env r3 $ do
+ writeFile conflictor "conflictor"
+ git_annex env "add" [conflictor] @? "add conflicter failed"
+ git_annex env "sync" [] @? "sync failed in r1"
+ check_is_link (conflictor </> "subfile") "r3"
+ where
conflictor = "conflictor"
+ check_is_link f what = do
+ git_annex_expectoutput env "find" ["--include=*", f] [f]
+ l <- annexeval $ Annex.inRepo $ Git.LsTree.lsTreeFiles Git.Ref.headRef [f]
+ all (\i -> Git.Types.toBlobType (Git.LsTree.mode i) == Just Git.Types.SymlinkBlob) l
+ @? (what ++ " " ++ f ++ " lost symlink bit after merge: " ++ show l)
{- Set up repos as remotes of each other. -}
pair :: TestEnv -> FilePath -> FilePath -> Assertion