packages feed

zip-archive 0.3.1 → 0.3.1.1

raw patch · 8 files changed

+44/−23 lines, 8 filesdep ~binarybinary-added

Dependency ranges changed: binary

Files

changelog view
@@ -1,3 +1,12 @@+zip-archive 0.3.1.1++  * readEntry:  Read file as a strict ByteString.  This avoids+    problems on Windows, where the file handle wasn't being closed.+  * Added appveyor.yml to do continuous testing on Windows.+  * Test suite: remove need for external zip program (#35).+    Instead of creating an archive with zip, we now store+    a small externally created zip archive to use for testing.+ zip-archive 0.3.1    * Don't use a custom build (#28).
src/Codec/Archive/Zip.hs view
@@ -262,7 +262,7 @@                     _         -> p)   contents <- if isDir                  then return B.empty-                 else B.readFile path+                 else B.fromStrict <$> S.readFile path #if MIN_VERSION_directory(1,2,0)   modEpochTime <- fmap (floor . utcTimeToPOSIXSeconds)                    $ getModificationTime path
tests/test-zip-archive.hs view
@@ -7,8 +7,8 @@ import System.Directory import Test.HUnit.Base import Test.HUnit.Text-import System.Process-import qualified Data.ByteString.Lazy as B+import qualified Data.ByteString.Char8 as BS+import qualified Data.ByteString.Lazy as BL import Control.Applicative import System.Exit import System.IO.Temp (withTempDirectory)@@ -46,23 +46,27 @@ testReadWriteArchive :: FilePath -> Test testReadWriteArchive tmpDir = TestCase $ do   archive <- addFilesToArchive [OptRecursive] emptyArchive ["LICENSE", "src"]-  B.writeFile (tmpDir ++ "/test1.zip") $ fromArchive archive-  archive' <- toArchive <$> B.readFile (tmpDir ++ "/test1.zip")+  BL.writeFile (tmpDir ++ "/test1.zip") $ fromArchive archive+  archive' <- toArchive <$> BL.readFile (tmpDir ++ "/test1.zip")   assertEqual "for writing and reading test1.zip" archive archive'   assertEqual "for writing and reading test1.zip" archive archive'  testReadExternalZip :: FilePath -> Test-testReadExternalZip tmpDir = TestCase $ do-  _ <- runCommand ("zip -q " ++ tmpDir ++-           "/test4.zip zip-archive.cabal src/Codec/Archive/Zip.hs") >>=-           waitForProcess-  archive <- toArchive <$> B.readFile (tmpDir ++ "/test4.zip")+testReadExternalZip _tmpDir = TestCase $ do+  archive <- toArchive <$> BL.readFile "tests/test4.zip"   let files = filesInArchive archive-  assertEqual "for results of filesInArchive" ["zip-archive.cabal", "src/Codec/Archive/Zip.hs"] files-  cabalContents <- B.readFile "zip-archive.cabal"-  case findEntryByPath "zip-archive.cabal" archive of -       Nothing  -> assertFailure "zip-archive.cabal not found in archive"-       Just f   -> assertEqual "for contents of zip-archive.cabal in archive" cabalContents (fromEntry f)+  assertEqual "for results of filesInArchive"+    ["test4/","test4/a.txt","test4/b.bin","test4/c/",+     "test4/c/with spaces.txt"] files+  bContents <- BL.readFile "tests/test4/b.bin"+  case findEntryByPath "test4/b.bin" archive of+       Nothing  -> assertFailure "test4/b.bin not found in archive"+       Just f   -> assertEqual "for contents of test4/b.bin in archive"+                      bContents (fromEntry f)+  case findEntryByPath "test4/" archive of+       Nothing  -> assertFailure "test4/ not found in archive"+       Just f   -> assertEqual "for contents of test4/ in archive"+                      BL.empty (fromEntry f)  testFromToArchive :: FilePath -> Test testFromToArchive _tmpDir = TestCase $ do@@ -97,15 +101,15 @@ testExtractFiles tmpDir = TestCase $ do   createDirectory (tmpDir ++ "/dir1")   createDirectory (tmpDir ++ "/dir1/dir2")-  let hiMsg = "hello there"-  let helloMsg = "Hello there. This file is very long.  Longer than 31 characters."-  writeFile (tmpDir ++ "/dir1/hi") hiMsg-  writeFile (tmpDir ++ "/dir1/dir2/hello") helloMsg+  let hiMsg = BS.pack "hello there"+  let helloMsg = BS.pack "Hello there. This file is very long.  Longer than 31 characters."+  BS.writeFile (tmpDir ++ "/dir1/hi") hiMsg+  BS.writeFile (tmpDir ++ "/dir1/dir2/hello") helloMsg   archive <- addFilesToArchive [OptRecursive] emptyArchive [(tmpDir ++ "/dir1")]   removeDirectoryRecursive (tmpDir ++ "/dir1")   extractFilesFromArchive [OptVerbose] archive-  hi <- readFile (tmpDir ++ "/dir1/hi")-  hello <- readFile (tmpDir ++ "/dir1/dir2/hello")+  hi <- BS.readFile (tmpDir ++ "/dir1/hi")+  hello <- BS.readFile (tmpDir ++ "/dir1/dir2/hello")   assertEqual ("contents of " ++ tmpDir ++ "/dir1/hi") hiMsg hi   assertEqual ("contents of " ++ tmpDir ++ "/dir1/dir2/hello") helloMsg hello 
+ tests/test4.zip view

binary file changed (absent → 842 bytes)

+ tests/test4/a.txt view
@@ -0,0 +1,1 @@+Hello, this is a test!
+ tests/test4/b.bin view
@@ -0,0 +1,1 @@+ðã¿ölÑ«>Ô0Ø^ÌÔÚªñ˜@¬ “ùÿ
+ tests/test4/c/with spaces.txt view
@@ -0,0 +1,1 @@+Another file.
zip-archive.cabal view
@@ -1,5 +1,5 @@ Name:                zip-archive-Version:             0.3.1+Version:             0.3.1.1 Cabal-Version:       >= 1.10 Build-type:          Simple Synopsis:            Library for creating and modifying zip archives.@@ -12,7 +12,12 @@ Homepage:            http://github.com/jgm/zip-archive Author:              John MacFarlane Maintainer:          jgm@berkeley.edu-Extra-Source-Files:  changelog, README.markdown+Extra-Source-Files:  changelog,+                     README.markdown,+                     tests/test4.zip,+                     tests/test4/a.txt,+                     tests/test4/b.bin,+                     "tests/test4/c/with spaces.txt"  Source-repository    head   type:              git