Hello community, here is the log from the commit of package ghc-htaglib for openSUSE:Factory checked in at 2016-11-10 13:21:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-htaglib (Old) and /work/SRC/openSUSE:Factory/.ghc-htaglib.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-htaglib" Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-htaglib/ghc-htaglib.changes 2016-11-01 09:55:30.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-htaglib.new/ghc-htaglib.changes 2016-11-10 13:21:54.000000000 +0100 @@ -1,0 +2,5 @@ +Thu Sep 15 06:58:10 UTC 2016 - [email protected] + +- Update to version 1.0.4 revision 0 with cabal2obs. + +------------------------------------------------------------------- Old: ---- htaglib-1.0.3.tar.gz New: ---- htaglib-1.0.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-htaglib.spec ++++++ --- /var/tmp/diff_new_pack.t1EqDx/_old 2016-11-10 13:21:54.000000000 +0100 +++ /var/tmp/diff_new_pack.t1EqDx/_new 2016-11-10 13:21:54.000000000 +0100 @@ -19,28 +19,24 @@ %global pkg_name htaglib %bcond_with tests Name: ghc-%{pkg_name} -Version: 1.0.3 +Version: 1.0.4 Release: 0 Summary: Bindings to TagLib, audio meta-data library License: BSD-3-Clause -Group: System/Libraries +Group: Development/Languages/Other Url: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel -# Begin cabal-rpm deps: BuildRequires: ghc-bytestring-devel BuildRequires: ghc-rpm-macros BuildRequires: ghc-text-devel BuildRequires: libtag-devel BuildRoot: %{_tmppath}/%{name}-%{version}-build %if %{with tests} -BuildRequires: ghc-HUnit-devel BuildRequires: ghc-directory-devel BuildRequires: ghc-filepath-devel -BuildRequires: ghc-test-framework-devel -BuildRequires: ghc-test-framework-hunit-devel +BuildRequires: ghc-hspec-devel %endif -# End cabal-rpm deps %description Bindings to TagLib, audio meta-data library. @@ -50,11 +46,9 @@ Group: Development/Libraries/Other Requires: %{name} = %{version}-%{release} Requires: ghc-compiler = %{ghc_version} -# Begin cabal-rpm deps: Requires: libtag-devel Requires(post): ghc-compiler = %{ghc_version} Requires(postun): ghc-compiler = %{ghc_version} -# End cabal-rpm deps %description devel This package provides the Haskell %{pkg_name} library development files. @@ -62,20 +56,14 @@ %prep %setup -q -n %{pkg_name}-%{version} - %build %ghc_lib_build - %install %ghc_lib_install - %check -%if %{with tests} -%{cabal} test -%endif - +%cabal_test %post devel %ghc_pkg_recache @@ -86,6 +74,10 @@ %files -f %{name}.files %defattr(-,root,root,-) %doc LICENSE.md +%dir %{_datadir}/%{pkg_name}-%{version} +%dir %{_datadir}/%{pkg_name}-%{version}/audio-samples +%{_datadir}/%{pkg_name}-%{version}/audio-samples/*.flac +%{_datadir}/%{pkg_name}-%{version}/audio-samples/*.mp3 %files devel -f %{name}-devel.files %defattr(-,root,root,-) ++++++ htaglib-1.0.3.tar.gz -> htaglib-1.0.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/CHANGELOG.md new/htaglib-1.0.4/CHANGELOG.md --- old/htaglib-1.0.3/CHANGELOG.md 2016-04-06 14:42:14.000000000 +0200 +++ new/htaglib-1.0.4/CHANGELOG.md 2016-09-10 12:48:20.000000000 +0200 @@ -1,3 +1,9 @@ +## HTagLib 1.0.4 + +* Re-wrote the test suite with Hspec. + +* Drop support for GHC 7.6. + ## HTagLib 1.0.3 * Export functions instead of record selectors for tag newtype wrappers. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/README.md new/htaglib-1.0.4/README.md --- old/htaglib-1.0.3/README.md 2016-01-22 08:18:07.000000000 +0100 +++ new/htaglib-1.0.4/README.md 2016-04-12 10:43:20.000000000 +0200 @@ -128,13 +128,13 @@ ``` $ ./example "/home/mark/music/David Bowie/1977, Low/01 Speed of Life.flac" AudioTrack - { atTitle = Title {unTitle = "Speed of Life"} - , atArtist = Artist {unArtist = "David Bowie"} - , atAlbum = Album {unAlbum = "Low"} - , atComment = Comment {unComment = ""} - , atGenre = Genre {unGenre = ""} - , atYear = Just (Year {unYear = 1977}) - , atTrack = Just (TrackNumber {unTrackNumber = 1}) + { atTitle = Title "Speed of Life" + , atArtist = Artist "David Bowie" + , atAlbum = Album "Low" + , atComment = Comment "" + , atGenre = Genre "" + , atYear = Just (Year 1977) + , atTrack = Just (TrackNumber 1) } ``` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/Sound/HTagLib/Internal.hs new/htaglib-1.0.4/Sound/HTagLib/Internal.hs --- old/htaglib-1.0.3/Sound/HTagLib/Internal.hs 2016-01-03 12:18:41.000000000 +0100 +++ new/htaglib-1.0.4/Sound/HTagLib/Internal.hs 2016-09-03 12:21:17.000000000 +0200 @@ -164,8 +164,8 @@ -- File API --- | Open audio file and return its ID (abstraction that rest of library can --- pass around). In case of trouble 'IOException' is thrown. +-- | Open audio file and return its ID (an opaque type that the rest of +-- library can pass around). In case of trouble 'IOException' is thrown. newFile :: FilePath -- ^ Path to audio file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/htaglib.cabal new/htaglib-1.0.4/htaglib.cabal --- old/htaglib-1.0.3/htaglib.cabal 2016-04-06 14:42:02.000000000 +0200 +++ new/htaglib-1.0.4/htaglib.cabal 2016-09-10 12:49:04.000000000 +0200 @@ -31,7 +31,7 @@ -- POSSIBILITY OF SUCH DAMAGE. name: htaglib -version: 1.0.3 +version: 1.0.4 cabal-version: >= 1.10 license: BSD3 license-file: LICENSE.md @@ -43,11 +43,11 @@ synopsis: Bindings to TagLib, audio meta-data library build-type: Simple description: Bindings to TagLib, audio meta-data library. -extra-source-files: CHANGELOG.md +extra-doc-files: CHANGELOG.md , README.md , audio-samples/README.md - , audio-samples/sample.flac - , audio-samples/sample.mp3 +data-files: audio-samples/*.flac + , audio-samples/*.mp3 flag dev description: Turn on development settings. @@ -55,9 +55,9 @@ default: False library - build-depends: base >= 4.6 && < 5 - , bytestring >= 0.9 - , text >= 1.0 + build-depends: base >= 4.7 && < 5.0 + , bytestring >= 0.9 && < 0.11 + , text >= 1.0 && < 1.3 extra-libraries: tag_c exposed-modules: Sound.HTagLib , Sound.HTagLib.Type @@ -71,23 +71,21 @@ default-language: Haskell2010 test-suite tests - main-is: Main.hs + main-is: Spec.hs hs-source-dirs: tests type: exitcode-stdio-1.0 if flag(dev) ghc-options: -O0 -Wall -Werror else ghc-options: -O2 -Wall - other-modules: Getter - , Setter - , Util - build-depends: base >= 4.6 && < 5 - , HUnit >= 1.2 && < 1.4 - , directory >= 1.2 - , filepath >= 1.4 && < 2 - , htaglib >= 1.0 - , test-framework >= 0.6 && < 1 - , test-framework-hunit >= 0.2 && < 0.4 + other-modules: Sound.HTagLib.GetterSpec + , Sound.HTagLib.SetterSpec + , Sound.HTagLib.Test.Util + build-depends: base >= 4.7 && < 5.0 + , directory >= 1.2 && < 1.3 + , filepath >= 1.4 && < 2.0 + , hspec >= 2.0 && < 3.0 + , htaglib >= 1.0.4 default-extensions: CPP default-language: Haskell2010 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/tests/Getter.hs new/htaglib-1.0.4/tests/Getter.hs --- old/htaglib-1.0.3/tests/Getter.hs 2016-03-04 13:38:34.000000000 +0100 +++ new/htaglib-1.0.4/tests/Getter.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,60 +0,0 @@ --- --- HTagLib tests, testing of getters. --- --- Copyright © 2015–2016 Mark Karpov --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions are --- met: --- --- * Redistributions of source code must retain the above copyright notice, --- this list of conditions and the following disclaimer. --- --- * Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in the --- documentation and/or other materials provided with the distribution. --- --- * Neither the name Mark Karpov nor the names of contributors may be used --- to endorse or promote products derived from this software without --- specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY --- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED --- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY --- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL --- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS --- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) --- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, --- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN --- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE --- POSSIBILITY OF SUCH DAMAGE. - -module Getter (tests) where - -import Test.Framework -import Test.HUnit hiding (Test, path) - -import Sound.HTagLib -import Util - -#if !MIN_VERSION_base(4,8,0) -import Control.Applicative ((<$>)) -#endif - -tests :: Test -tests = testGroup "Getters" $ - fmap (caseWithFile (const simpleGetter)) fileList ++ - fmap (caseWithFile specializedGetter) fileList - -simpleGetter :: AudioTags -> Assertion -simpleGetter tags = do - let path = atFileName tags - extracted <- getTags path (id <$> sampleGetter path) - extracted `cfbr` tags - -specializedGetter :: FileType -> AudioTags -> Assertion -specializedGetter t tags = do - let path = atFileName tags - extracted <- getTags' path t (id <$> sampleGetter path) - extracted `cfbr` tags diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/tests/Main.hs new/htaglib-1.0.4/tests/Main.hs --- old/htaglib-1.0.3/tests/Main.hs 2016-01-25 07:52:01.000000000 +0100 +++ new/htaglib-1.0.4/tests/Main.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ --- --- HTagLib tests, main module. --- --- Copyright © 2015–2016 Mark Karpov --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions are --- met: --- --- * Redistributions of source code must retain the above copyright notice, --- this list of conditions and the following disclaimer. --- --- * Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in the --- documentation and/or other materials provided with the distribution. --- --- * Neither the name Mark Karpov nor the names of contributors may be used --- to endorse or promote products derived from this software without --- specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY --- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED --- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY --- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL --- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS --- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) --- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, --- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN --- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE --- POSSIBILITY OF SUCH DAMAGE. - -module Main (main) where - -import Test.Framework (defaultMain) - -import qualified Getter -import qualified Setter - -main :: IO () -main = defaultMain - [ Getter.tests - , Setter.tests ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/tests/Setter.hs new/htaglib-1.0.4/tests/Setter.hs --- old/htaglib-1.0.3/tests/Setter.hs 2016-03-04 13:38:56.000000000 +0100 +++ new/htaglib-1.0.4/tests/Setter.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,85 +0,0 @@ --- --- HTagLib tests, testing of Setters. --- --- Copyright © 2015–2016 Mark Karpov --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions are --- met: --- --- * Redistributions of source code must retain the above copyright notice, --- this list of conditions and the following disclaimer. --- --- * Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in the --- documentation and/or other materials provided with the distribution. --- --- * Neither the name Mark Karpov nor the names of contributors may be used --- to endorse or promote products derived from this software without --- specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY --- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED --- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY --- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL --- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS --- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) --- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, --- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN --- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE --- POSSIBILITY OF SUCH DAMAGE. - -{-# LANGUAGE OverloadedStrings #-} - -module Setter (tests) where - -import System.Directory (getTemporaryDirectory, copyFile) -import System.FilePath ((</>), takeFileName) - -import Test.Framework -import Test.HUnit hiding (Test, path) - -import Sound.HTagLib -import Util - -#if !MIN_VERSION_base(4,8,0) -import Control.Applicative ((<$>)) -#endif - -tests :: Test -tests = testGroup "Setters" $ - fmap (caseWithFile (const simpleSetter)) fileList ++ - fmap (caseWithFile specializedGetter) fileList - -dupeFile :: FilePath -> IO FilePath -dupeFile path = do - newPath <- (</> takeFileName path) <$> getTemporaryDirectory - copyFile path newPath - return newPath - -updateSampleTags :: AudioTags -> AudioTags -updateSampleTags tags = tags - { atTitle = mkTitle "title'" - , atArtist = mkArtist "artist'" - , atAlbum = mkAlbum "album'" - , atComment = mkComment "comment'" - , atGenre = mkGenre "genre'" - , atYear = mkYear 2056 - , atTrackNumber = mkTrackNumber 8 } - -simpleSetter :: AudioTags -> Assertion -simpleSetter tags = do - let path = atFileName tags - dupe <- dupeFile path - setTags dupe Nothing sampleSetter - extracted <- getTags dupe (sampleGetter dupe) - extracted `cfbr` updateSampleTags (tags { atFileName = dupe }) - -specializedGetter :: FileType -> AudioTags -> Assertion -specializedGetter t tags = do - let path = atFileName tags - dupe <- dupeFile path - setTags' dupe Nothing t sampleSetter - extracted <- getTags dupe (sampleGetter dupe) - extracted `cfbr` updateSampleTags (tags { atFileName = dupe }) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/tests/Sound/HTagLib/GetterSpec.hs new/htaglib-1.0.4/tests/Sound/HTagLib/GetterSpec.hs --- old/htaglib-1.0.3/tests/Sound/HTagLib/GetterSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/htaglib-1.0.4/tests/Sound/HTagLib/GetterSpec.hs 2016-09-10 11:58:45.000000000 +0200 @@ -0,0 +1,59 @@ +-- +-- HTagLib tests, testing of getters. +-- +-- Copyright © 2015–2016 Mark Karpov +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions are +-- met: +-- +-- * Redistributions of source code must retain the above copyright notice, +-- this list of conditions and the following disclaimer. +-- +-- * Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- +-- * Neither the name Mark Karpov nor the names of contributors may be used +-- to endorse or promote products derived from this software without +-- specific prior written permission. +-- +-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY +-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY +-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +-- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +-- POSSIBILITY OF SUCH DAMAGE. + +module Sound.HTagLib.GetterSpec (spec) where + +import Sound.HTagLib +import Sound.HTagLib.Test.Util +import Test.Hspec + +#if !MIN_VERSION_base(4,8,0) +import Control.Applicative ((<$>)) +#endif + +spec :: Spec +spec = + describe "getters" $ do + mapM_ (withFile $ const simpleGetter) fileList + mapM_ (withFile specializedGetter) fileList + +simpleGetter :: AudioTags -> Expectation +simpleGetter tags = do + let path = atFileName tags + extracted <- getTags path (id <$> sampleGetter path) + extracted `shouldMatchTags` tags + +specializedGetter :: FileType -> AudioTags -> Expectation +specializedGetter t tags = do + let path = atFileName tags + extracted <- getTags' path t (id <$> sampleGetter path) + extracted `shouldMatchTags` tags diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/tests/Sound/HTagLib/SetterSpec.hs new/htaglib-1.0.4/tests/Sound/HTagLib/SetterSpec.hs --- old/htaglib-1.0.3/tests/Sound/HTagLib/SetterSpec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/htaglib-1.0.4/tests/Sound/HTagLib/SetterSpec.hs 2016-09-10 12:01:36.000000000 +0200 @@ -0,0 +1,83 @@ +-- +-- HTagLib tests, testing of Setters. +-- +-- Copyright © 2015–2016 Mark Karpov +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions are +-- met: +-- +-- * Redistributions of source code must retain the above copyright notice, +-- this list of conditions and the following disclaimer. +-- +-- * Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- +-- * Neither the name Mark Karpov nor the names of contributors may be used +-- to endorse or promote products derived from this software without +-- specific prior written permission. +-- +-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY +-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY +-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +-- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +-- POSSIBILITY OF SUCH DAMAGE. + +{-# LANGUAGE OverloadedStrings #-} + +module Sound.HTagLib.SetterSpec (spec) where + +import Sound.HTagLib +import Sound.HTagLib.Test.Util +import System.Directory (getTemporaryDirectory, copyFile) +import System.FilePath ((</>), takeFileName) +import Test.Hspec + +#if !MIN_VERSION_base(4,8,0) +import Control.Applicative ((<$>)) +#endif + +spec :: Spec +spec = + describe "setters" $ do + mapM_ (withFile $ const simpleSetter) fileList + mapM_ (withFile specializedSetter) fileList + +dupeFile :: FilePath -> IO FilePath +dupeFile path = do + newPath <- (</> takeFileName path) <$> getTemporaryDirectory + copyFile path newPath + return newPath + +updateSampleTags :: AudioTags -> AudioTags +updateSampleTags tags = tags + { atTitle = mkTitle "title'" + , atArtist = mkArtist "artist'" + , atAlbum = mkAlbum "album'" + , atComment = mkComment "comment'" + , atGenre = mkGenre "genre'" + , atYear = mkYear 2056 + , atTrackNumber = mkTrackNumber 8 } + +simpleSetter :: AudioTags -> Expectation +simpleSetter tags = do + let path = atFileName tags + dupe <- dupeFile path + setTags dupe Nothing sampleSetter + extracted <- getTags dupe (sampleGetter dupe) + extracted `shouldMatchTags` updateSampleTags (tags { atFileName = dupe }) + +specializedSetter :: FileType -> AudioTags -> Expectation +specializedSetter t tags = do + let path = atFileName tags + dupe <- dupeFile path + setTags' dupe Nothing t sampleSetter + extracted <- getTags dupe (sampleGetter dupe) + extracted `shouldMatchTags` updateSampleTags (tags { atFileName = dupe }) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/tests/Sound/HTagLib/Test/Util.hs new/htaglib-1.0.4/tests/Sound/HTagLib/Test/Util.hs --- old/htaglib-1.0.3/tests/Sound/HTagLib/Test/Util.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/htaglib-1.0.4/tests/Sound/HTagLib/Test/Util.hs 2016-09-10 11:56:15.000000000 +0200 @@ -0,0 +1,140 @@ +-- +-- HTagLib tests, utility definitions. +-- +-- Copyright © 2015–2016 Mark Karpov +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions are +-- met: +-- +-- * Redistributions of source code must retain the above copyright notice, +-- this list of conditions and the following disclaimer. +-- +-- * Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- +-- * Neither the name Mark Karpov nor the names of contributors may be used +-- to endorse or promote products derived from this software without +-- specific prior written permission. +-- +-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY +-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY +-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +-- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +-- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +-- POSSIBILITY OF SUCH DAMAGE. + +{-# LANGUAGE OverloadedStrings #-} + +module Sound.HTagLib.Test.Util + ( AudioTags (..) + , sampleGetter + , sampleSetter + , fileList + , withFile + , shouldMatchTags ) +where + +import Data.Maybe (fromJust) +import Data.Monoid +import Sound.HTagLib +import Test.Hspec + +#if !MIN_VERSION_base(4,8,0) +import Control.Applicative ((<$>), (<*>), pure) +#endif + +data AudioTags = AudioTags + { atFileName :: FilePath + , atTitle :: Title + , atArtist :: Artist + , atAlbum :: Album + , atComment :: Comment + , atGenre :: Genre + , atYear :: Maybe Year + , atTrackNumber :: Maybe TrackNumber + , atDuration :: Duration + , atBitRate :: BitRate + , atSampleRate :: SampleRate + , atChannels :: Channels } + deriving (Show, Eq) + +sampleGetter :: FilePath -> TagGetter AudioTags +sampleGetter path = AudioTags + <$> pure path + <*> titleGetter + <*> artistGetter + <*> albumGetter + <*> commentGetter + <*> genreGetter + <*> yearGetter + <*> trackNumberGetter + <*> durationGetter + <*> bitRateGetter + <*> sampleRateGetter + <*> channelsGetter + +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" + , atComment = "comment" + , atGenre = "genre" + , atYear = mkYear 2055 + , atTrackNumber = mkTrackNumber 7 + , atDuration = fromJust $ mkDuration 0 + , atBitRate = fromJust $ mkBitRate 0 + , atSampleRate = fromJust $ mkSampleRate 44100 + , atChannels = fromJust $ mkChannels 2 } + +fileList :: [(FileType, AudioTags)] +fileList = + [ (FLAC, sampleTags + { atBitRate = fromJust $ mkBitRate 217 + , atFileName = "audio-samples/sample.flac" }) + , (MPEG, sampleTags + { atBitRate = fromJust $ mkBitRate 136 + , atFileName = "audio-samples/sample.mp3" }) ] + +-- | Call given function with provided data. + +withFile + :: (FileType -> AudioTags -> Expectation) + -> (FileType, AudioTags) + -> Spec +withFile f (t, tags) = it name (f t tags) + where name = "using file: " ++ show (atFileName tags) ++ " (" ++ show t ++ ")" + +-- | Create an expectation 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. + +shouldMatchTags + :: AudioTags -- ^ Tags to test + -> AudioTags -- ^ Correct tags to test against + -> Expectation +shouldMatchTags given expected = + let zeroBitRate = fromJust (mkBitRate 0) + in if atBitRate given == zeroBitRate + then given `shouldBe` expected { atBitRate = zeroBitRate } + else given `shouldBe` expected diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/tests/Spec.hs new/htaglib-1.0.4/tests/Spec.hs --- old/htaglib-1.0.3/tests/Spec.hs 1970-01-01 01:00:00.000000000 +0100 +++ new/htaglib-1.0.4/tests/Spec.hs 2016-09-06 23:07:35.000000000 +0200 @@ -0,0 +1 @@ +{-# OPTIONS_GHC -F -pgmF hspec-discover #-} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/htaglib-1.0.3/tests/Util.hs new/htaglib-1.0.4/tests/Util.hs --- old/htaglib-1.0.3/tests/Util.hs 2016-03-04 13:37:27.000000000 +0100 +++ new/htaglib-1.0.4/tests/Util.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,141 +0,0 @@ --- --- HTagLib tests, utility definitions. --- --- Copyright © 2015–2016 Mark Karpov --- --- Redistribution and use in source and binary forms, with or without --- modification, are permitted provided that the following conditions are --- met: --- --- * Redistributions of source code must retain the above copyright notice, --- this list of conditions and the following disclaimer. --- --- * Redistributions in binary form must reproduce the above copyright --- notice, this list of conditions and the following disclaimer in the --- documentation and/or other materials provided with the distribution. --- --- * Neither the name Mark Karpov nor the names of contributors may be used --- to endorse or promote products derived from this software without --- specific prior written permission. --- --- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS “AS IS” AND ANY --- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED --- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE --- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY --- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL --- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS --- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) --- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, --- STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN --- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE --- POSSIBILITY OF SUCH DAMAGE. - -{-# LANGUAGE OverloadedStrings #-} - -module Util - ( AudioTags (..) - , sampleGetter - , sampleSetter - , fileList - , caseWithFile - , cfbr ) -where - -import Data.Maybe (fromJust) -import Data.Monoid -import Sound.HTagLib - -import Test.Framework -import Test.Framework.Providers.HUnit (testCase) -import Test.HUnit hiding (Test, path) - -#if !MIN_VERSION_base(4,8,0) -import Control.Applicative ((<$>), (<*>), pure) -#endif - -data AudioTags = AudioTags - { atFileName :: FilePath - , atTitle :: Title - , atArtist :: Artist - , atAlbum :: Album - , atComment :: Comment - , atGenre :: Genre - , atYear :: Maybe Year - , atTrackNumber :: Maybe TrackNumber - , atDuration :: Duration - , atBitRate :: BitRate - , atSampleRate :: SampleRate - , atChannels :: Channels } - deriving (Show, Eq) - -sampleGetter :: FilePath -> TagGetter AudioTags -sampleGetter path = AudioTags - <$> pure path - <*> titleGetter - <*> artistGetter - <*> albumGetter - <*> commentGetter - <*> genreGetter - <*> yearGetter - <*> trackNumberGetter - <*> durationGetter - <*> bitRateGetter - <*> sampleRateGetter - <*> channelsGetter - -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" - , atComment = "comment" - , atGenre = "genre" - , atYear = mkYear 2055 - , atTrackNumber = mkTrackNumber 7 - , atDuration = fromJust $ mkDuration 0 - , atBitRate = fromJust $ mkBitRate 0 - , atSampleRate = fromJust $ mkSampleRate 44100 - , atChannels = fromJust $ mkChannels 2 } - -fileList :: [(FileType, AudioTags)] -fileList = - [ (FLAC, sampleTags - { atBitRate = fromJust $ mkBitRate 217 - , atFileName = "audio-samples/sample.flac" }) - , (MPEG, sampleTags - { atBitRate = fromJust $ mkBitRate 136 - , atFileName = "audio-samples/sample.mp3" }) ] - -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
