summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2013-11-21 14:04:08 -0400
committerJoey Hess <joey@kitenet.net>2013-11-21 14:04:08 -0400
commitefda9be7c8782936fab05b6059c43d1c30effe1f (patch)
tree128be6be052040f60620df77b00f88be2e1207cb
parent0be4febab2f4fe102d2bd1bb9bf564ea0b5e1ee6 (diff)
downloadgit-repair-efda9be7c8782936fab05b6059c43d1c30effe1f.tar.gz
better FileSelector distribution
-rw-r--r--Git/Destroyer.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/Git/Destroyer.hs b/Git/Destroyer.hs
index a208576..f175515 100644
--- a/Git/Destroyer.hs
+++ b/Git/Destroyer.hs
@@ -61,7 +61,14 @@ data FileSelector = FileSelector Int
deriving (Read, Show)
instance Arbitrary FileSelector where
- arbitrary = FileSelector <$> nonNegative arbitraryBoundedIntegral
+ arbitrary = FileSelector <$> oneof
+ -- An early file in the git tree, tends to be the most
+ -- interesting when there are lots of files.
+ [ nonNegative arbitrarySizedIntegral
+ -- Totally random choice from any of the files in
+ -- the git tree, to ensure good coverage.
+ , nonNegative arbitraryBoundedIntegral
+ ]
selectFile :: [FilePath] -> FileSelector -> FilePath
selectFile sortedfs (FileSelector n) = sortedfs !! (n `mod` length sortedfs)