packages feed

tar 0.4.2.0 → 0.4.2.1

raw patch · 5 files changed

+43/−23 lines, 5 files

Files

Codec/Archive/Tar/Index.hs view
@@ -104,6 +104,8 @@ import qualified Prelude import Test.QuickCheck import Control.Applicative ((<$>), (<*>))+import Data.List (nub, sort, stripPrefix, isPrefixOf)+import Data.Maybe #endif  @@ -535,22 +537,25 @@  #ifdef TESTS --- properties of a finite mapping...+-- Not quite the properties of a finite mapping because we also have lookups+-- that result in completions. -prop_lookup :: [(NonEmptyFilePath, TarEntryOffset)] -> NonEmptyFilePath -> Bool-prop_lookup paths (NonEmptyFilePath p) =-  case (lookup index p, Prelude.lookup p paths') of+prop_lookup :: ValidPaths -> NonEmptyFilePath -> Bool+prop_lookup (ValidPaths paths) (NonEmptyFilePath p) =+  case (lookup index p, Prelude.lookup p paths) of     (Nothing,                    Nothing)      -> True     (Just (TarFileEntry offset), Just offset') -> offset == offset'+    (Just (TarDir entries),      Nothing)      -> sort (nub (map fst entries))+                                               == sort (nub completions)     _                                          -> False   where-    paths' = [ (p, off) | (NonEmptyFilePath p, off) <- paths ]--    index@(TarIndex pathTable _ _) =-      finaliseIndex (IndexBuilder paths' 0)+    index       = finaliseIndex (IndexBuilder paths 0)+    completions = [ head (FilePath.splitDirectories completion)+                  | (path,_) <- paths+                  , completion <- maybeToList $ stripPrefix (p ++ "/") path ] -prop_valid :: [(NonEmptyFilePath, TarEntryOffset)] -> Bool-prop_valid paths+prop_valid :: ValidPaths -> Bool+prop_valid (ValidPaths paths)   | not $ StringTable.prop_valid   pathbits = error "TarIndex: bad string table"   | not $ IntTrie.prop_lookup      intpaths = error "TarIndex: bad int trie"   | not $ IntTrie.prop_completions intpaths = error "TarIndex: bad int trie"@@ -558,16 +563,13 @@   | otherwise                               = True    where-    paths' = [ (p, off) | (NonEmptyFilePath p, off) <- paths ]--    index@(TarIndex pathTable _ _) =-      finaliseIndex (IndexBuilder paths' 0)+    index@(TarIndex pathTable _ _) = finaliseIndex (IndexBuilder paths 0) -    pathbits = concatMap (FilePath.splitDirectories . fst) paths'+    pathbits = concatMap (FilePath.splitDirectories . fst) paths     intpaths = [ (cids, offset)-               | (path, offset) <- paths'+               | (path, offset) <- paths                , let Just cids = toComponentIds pathTable path ]-    prop' = flip all paths' $ \(file, offset) ->+    prop' = flip all paths $ \(file, offset) ->       case lookup index file of         Just (TarFileEntry offset') -> offset' == offset         _                           -> False@@ -577,6 +579,22 @@ instance Arbitrary NonEmptyFilePath where   arbitrary = NonEmptyFilePath . FilePath.joinPath                 <$> listOf1 (elements ["a", "b", "c", "d"])++newtype ValidPaths = ValidPaths [(FilePath, TarEntryOffset)] deriving Show++instance Arbitrary ValidPaths where+  arbitrary =+      ValidPaths . makeNoPrefix <$> listOf ((,) <$> arbitraryPath <*> arbitrary)+    where+      arbitraryPath   = FilePath.joinPath+                         <$> listOf1 (elements ["a", "b", "c", "d"])+      makeNoPrefix [] = []+      makeNoPrefix ((k,v):kvs)+        | all (\(k', _) -> not (isPrefixOfOther k k')) kvs+                     = (k,v) : makeNoPrefix kvs+        | otherwise  =         makeNoPrefix kvs++      isPrefixOfOther a b = a `isPrefixOf` b || b `isPrefixOf` a  example0 :: Entries () example0 =
Codec/Archive/Tar/Index/IntTrie.hs view
@@ -420,9 +420,9 @@   shrink (ValidPaths kvs) =       map ValidPaths . filter noPrefix . filter nonEmpty . shrink $ kvs     where-      noPrefix []          = True-      noPrefix ((k,_):kvs) = all (\(k', _) -> not (isPrefixOfOther k k')) kvs-                          && noPrefix kvs+      noPrefix []           = True+      noPrefix ((k,_):kvs') = all (\(k', _) -> not (isPrefixOfOther k k')) kvs'+                           && noPrefix kvs'       nonEmpty = all (not . null . fst)  isPrefixOfOther a b = a `isPrefixOf` b || b `isPrefixOf` a
changelog.md view
@@ -1,3 +1,7 @@+0.4.2.1 Duncan Coutts <duncan@community.haskell.org> July 2015++  * Fix tests for the Index modules (the code was right)+ 0.4.2.0 Duncan Coutts <duncan@community.haskell.org> July 2015    * New Index module for random access to tar file contents
tar.cabal view
@@ -1,5 +1,5 @@ name:            tar-version:         0.4.2.0+version:         0.4.2.1 license:         BSD3 license-file:    LICENSE author:          Bjorn Bringert <bjorn@bringert.net>
test/Properties.hs view
@@ -4,8 +4,6 @@ import qualified Codec.Archive.Tar.Index.IntTrie as IntTrie import qualified Codec.Archive.Tar.Index.StringTable as StringTable -import qualified Data.ByteString.Lazy.Char8 as BS-import Test.QuickCheck import Test.Tasty import Test.Tasty.QuickCheck