htaglib 1.0.1 → 1.0.2
raw patch · 7 files changed
+85/−57 lines, 7 files
Files
- CHANGELOG.md +4/−0
- README.md +1/−0
- htaglib.cabal +2/−3
- tests/Getter.hs +12/−11
- tests/Main.hs +0/−1
- tests/Setter.hs +20/−31
- tests/Util.hs +46/−11
CHANGELOG.md view
@@ -1,3 +1,7 @@+## HTagLib 1.0.2++* Modify test suite so it passes with newer versions of TagLib as well.+ ## HTagLib 1.0.1 * Rewritten setters (without changing the API), so at most one writing
README.md view
@@ -3,6 +3,7 @@ [](http://opensource.org/licenses/BSD-3-Clause) [](https://hackage.haskell.org/package/htaglib) [](http://stackage.org/nightly/package/htaglib)+[](http://stackage.org/lts/package/htaglib) [](https://travis-ci.org/mrkkrp/htaglib) [](https://coveralls.io/github/mrkkrp/htaglib?branch=master)
htaglib.cabal view
@@ -1,4 +1,3 @@--- -*- Mode: Haskell-Cabal; -*- -- -- Cabal config for HTagLib. --@@ -32,7 +31,7 @@ -- POSSIBILITY OF SUCH DAMAGE. name: htaglib-version: 1.0.1+version: 1.0.2 cabal-version: >= 1.10 license: BSD3 license-file: LICENSE.md@@ -40,7 +39,7 @@ maintainer: Mark Karpov <markkarpov@opmbx.org> homepage: https://github.com/mrkkrp/htaglib bug-reports: https://github.com/mrkkrp/htaglib/issues-category: Sound+category: Sound, Foreign synopsis: Bindings to TagLib, audio meta-data library build-type: Simple description: Bindings to TagLib, audio meta-data library.
tests/Getter.hs view
@@ -1,4 +1,3 @@--- -*- Mode: Haskell; -*- -- -- HTagLib tests, testing of getters. --@@ -45,15 +44,17 @@ tests :: Test tests = testGroup "Getters" $- fmap (caseWithFile simpleGetter . fst) fileList ++- fmap (caseWithFile specializedGetter) fileList+ fmap (caseWithFile (const simpleGetter)) fileList +++ fmap (caseWithFile specializedGetter) fileList -simpleGetter :: FilePath -> Assertion-simpleGetter path = do- tags <- getTags path (id <$> sampleGetter path)- tags @?= sampleTags path+simpleGetter :: AudioTags -> Assertion+simpleGetter tags = do+ let path = atFileName tags+ extracted <- getTags path (id <$> sampleGetter path)+ extracted `cfbr` tags -specializedGetter :: (FilePath, FileType) -> Assertion-specializedGetter (path, t) = do- tags <- getTags' path t (id <$> sampleGetter path)- tags @?= sampleTags path+specializedGetter :: FileType -> AudioTags -> Assertion+specializedGetter t tags = do+ let path = atFileName tags+ extracted <- getTags' path t (id <$> sampleGetter path)+ extracted `cfbr` tags
tests/Main.hs view
@@ -1,4 +1,3 @@--- -*- Mode: Haskell; -*- -- -- HTagLib tests, main module. --
tests/Setter.hs view
@@ -1,4 +1,3 @@--- -*- Mode: Haskell; -*- -- -- HTagLib tests, testing of Setters. --@@ -35,7 +34,6 @@ module Setter (tests) where -import Data.Monoid import System.Directory (getTemporaryDirectory, copyFile) import System.FilePath ((</>), takeFileName) @@ -51,8 +49,8 @@ tests :: Test tests = testGroup "Setters" $- fmap (caseWithFile simpleSetter . fst) fileList ++- fmap (caseWithFile specializedGetter) fileList+ fmap (caseWithFile (const simpleSetter)) fileList +++ fmap (caseWithFile specializedGetter) fileList dupeFile :: FilePath -> IO FilePath dupeFile path = do@@ -60,37 +58,28 @@ copyFile path newPath return newPath -sampleSetter :: TagSetter-sampleSetter =- mempty <>- titleSetter (mkTitle "title'") <>- artistSetter (mkArtist "artist'") <>- albumSetter (mkAlbum "album'") <>- commentSetter (mkComment "comment'") <>- genreSetter (mkGenre "genre'") <>- yearSetter (mkYear 2056) <>- trackNumberSetter (mkTrackNumber 8)- updateSampleTags :: AudioTags -> AudioTags updateSampleTags tags = tags- { atTitle = mkTitle "title'"- , atArtist = mkArtist "artist'"- , atAlbum = mkAlbum "album'"- , atComment = mkComment "comment'"- , atGenre = mkGenre "genre'"- , atYear = mkYear 2056+ { atTitle = mkTitle "title'"+ , atArtist = mkArtist "artist'"+ , atAlbum = mkAlbum "album'"+ , atComment = mkComment "comment'"+ , atGenre = mkGenre "genre'"+ , atYear = mkYear 2056 , atTrackNumber = mkTrackNumber 8 } -simpleSetter :: FilePath -> Assertion-simpleSetter path = do+simpleSetter :: AudioTags -> Assertion+simpleSetter tags = do+ let path = atFileName tags dupe <- dupeFile path- setTags dupe Nothing $ sampleSetter- tags <- getTags dupe (sampleGetter dupe)- tags @?= updateSampleTags (sampleTags dupe)+ setTags dupe Nothing sampleSetter+ extracted <- getTags dupe (sampleGetter dupe)+ extracted `cfbr` updateSampleTags (tags { atFileName = dupe }) -specializedGetter :: (FilePath, FileType) -> Assertion-specializedGetter (path, t) = do+specializedGetter :: FileType -> AudioTags -> Assertion+specializedGetter t tags = do+ let path = atFileName tags dupe <- dupeFile path- setTags' dupe Nothing t $ sampleSetter- tags <- getTags dupe (sampleGetter dupe)- tags @?= updateSampleTags (sampleTags dupe)+ setTags' dupe Nothing t sampleSetter+ extracted <- getTags dupe (sampleGetter dupe)+ extracted `cfbr` updateSampleTags (tags { atFileName = dupe })
tests/Util.hs view
@@ -1,4 +1,3 @@--- -*- Mode: Haskell; -*- -- -- HTagLib tests, utility definitions. --@@ -36,12 +35,14 @@ module Util ( AudioTags (..) , sampleGetter- , sampleTags+ , sampleSetter , fileList- , caseWithFile )+ , caseWithFile+ , cfbr ) where import Data.Maybe (fromJust)+import Data.Monoid import Sound.HTagLib import Test.Framework@@ -82,9 +83,20 @@ <*> sampleRateGetter <*> channelsGetter -sampleTags :: FilePath -> AudioTags-sampleTags path = AudioTags- { atFileName = path+sampleSetter :: TagSetter+sampleSetter =+ mempty <>+ titleSetter (mkTitle "title'") <>+ artistSetter (mkArtist "artist'") <>+ albumSetter (mkAlbum "album'") <>+ commentSetter (mkComment "comment'") <>+ genreSetter (mkGenre "genre'") <>+ yearSetter (mkYear 2056) <>+ trackNumberSetter (mkTrackNumber 8)++sampleTags :: AudioTags+sampleTags = AudioTags+ { atFileName = undefined , atTitle = "title" , atArtist = "artist" , atAlbum = "album"@@ -97,10 +109,33 @@ , atSampleRate = fromJust $ mkSampleRate 44100 , atChannels = fromJust $ mkChannels 2 } -fileList :: [(String, FileType)]+fileList :: [(FileType, AudioTags)] fileList =- [ ("audio-samples/sample.flac", FLAC)- , ("audio-samples/sample.mp3", MPEG) ]+ [ (FLAC, sampleTags+ { atBitRate = fromJust $ mkBitRate 217+ , atFileName = "audio-samples/sample.flac" })+ , (MPEG, sampleTags+ { atBitRate = fromJust $ mkBitRate 136+ , atFileName = "audio-samples/sample.mp3" }) ] -caseWithFile :: Show a => (a -> Assertion) -> a -> Test-caseWithFile f param = testCase ("checking file: " ++ show param) (f param)+caseWithFile+ :: (FileType -> AudioTags -> Assertion)+ -> (FileType, AudioTags)+ -> Test+caseWithFile f (t, tags) = testCase name (f t tags)+ where name = "using file: " ++ show (atFileName tags) ++ " (" ++ show t ++ ")"++-- | Create 'Assertion' that two collections of tags match. However, if bit+-- rate of the first is zero (which is the case with older versions of+-- TagLib when it's used with such short files as our samples), allow bit+-- rate values differ.++cfbr+ :: AudioTags -- ^ Tags to test+ -> AudioTags -- ^ Correct tags to test against+ -> Assertion+cfbr n tags =+ let zeroBitRate = fromJust (mkBitRate 0)+ in if atBitRate n == zeroBitRate+ then n @?= tags { atBitRate = zeroBitRate }+ else n @?= tags