=== modified file 'idiii.cabal' --- idiii.cabal 2012-08-26 01:39:36 +0000 +++ idiii.cabal 2012-08-26 06:07:09 +0000 @@ -1,5 +1,6 @@ Name: idiii -Version: 0.1.2.3 +Cabal-version: >= 1.2 +Version: 0.1.2.4 Synopsis: ID3v2 (tagging standard for MP3 files) library Description: ID3v2 (tagging standard for MP3 files) library Category: Text, Sound @@ -7,11 +8,20 @@ License-file: LICENSE Author: Alexey Alekhin, Chris Wagner Maintainer: christopher.t.wagner@gmail.com, alekhin.alexey@gmail.com -Build-Depends: base < 5, bytestring, polyparse, text, data-accessor, utf8-string, containers, MissingH Build-Type: Simple -hs-source-dirs: src extra-source-files: LICENSE read-idiii.hs -Exposed-modules: ID3, +data-dir: test/resources +data-files: *.mp3 + +Executable read-idiii + hs-source-dirs: ., src + build-depends: base + main-is: read-idiii.hs + +Library + Build-Depends: base < 5, bytestring, polyparse, text, data-accessor, utf8-string, containers, MissingH + hs-source-dirs: src + Exposed-modules: ID3, ID3.Simple, ID3.Parser, @@ -34,4 +44,11 @@ ID3.ReadTag, ID3.WriteTag -ghc-options: -Wall + ghc-options: -Wall + +Test-Suite test + type: exitcode-stdio-1.0 + hs-source-dirs: test, src + main-is: Tests.hs + build-depends: base, filepath, process, directory, HUnit + other-modules: Paths_idiii === modified file 'read-idiii.hs' --- read-idiii.hs 2010-08-25 18:53:52 +0000 +++ read-idiii.hs 2012-08-26 05:23:14 +0000 @@ -2,7 +2,7 @@ import ID3 import qualified Data.Map as Map -import System (getArgs) +import System.Environment (getArgs) main = do args <- getArgs === modified file 'test/CharacterEncodingTests.hs' --- test/CharacterEncodingTests.hs 2010-11-03 16:53:11 +0000 +++ test/CharacterEncodingTests.hs 2012-08-26 05:51:43 +0000 @@ -1,7 +1,7 @@ -module Main where +module CharacterEncodingTests (tests) where import Test.HUnit -import TestHelp (getTestDir, testFile, getValueForTextFrame, assertTagHasGivenTextValues) +import TestHelp (assertTagHasGivenTextValues) testReadingTagThatHasNonAsciiCharsWithISO88591Encoding = TestCase $ do assertTagHasGivenTextValues "iso88591-with-non-ascii-chars.mp3" @@ -21,8 +21,7 @@ "utf16-with-no-null-termination-char.mp3" [("TIT2", "My Maria"), ("TYER", "1997"), ("TPUB", "Hey-ya")] -tests = TestList - [TestLabel ("test reading a tag that has a frame with text encoded as ISO-8859-1, with at " ++ +tests = [TestLabel ("test reading a tag that has a frame with text encoded as ISO-8859-1, with at " ++ "least a portion of the characters in the non-ASCII range") testReadingTagThatHasNonAsciiCharsWithISO88591Encoding, TestLabel ("test reading a tag that has a frame with text encoded as UTF-16, containing a " ++ @@ -37,7 +36,3 @@ TestLabel ("test reading a tag that uses UTF-16 encoding but does not use a null " ++ "character (\x00\x00) to terminate strings contained within frames") testUTF16FrameWhenNoNullTerminationCharacterIsUsed] - -main = do - _ <- getTestDir -- Make sure test directory was passed as a command-line argument. - runTestTT tests === modified file 'test/FrameSupportTests.hs' --- test/FrameSupportTests.hs 2011-03-21 18:54:52 +0000 +++ test/FrameSupportTests.hs 2012-08-26 05:49:38 +0000 @@ -1,7 +1,7 @@ -module Main where +module FrameSupportTests (tests) where import Test.HUnit -import TestHelp (getTestDir, assertTagHasGivenTextValues, assertTagHasGivenFrames) +import TestHelp (assertTagHasGivenTextValues, assertTagHasGivenFrames) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as Char8 @@ -37,7 +37,7 @@ testReadingTagWithIllegalNewlineCharactersInFrame = TestCase $ assertTagHasGivenTextValues "has-illegal-newline.mp3" [("TCON", "Very Funny\r\nSuper Funny"), ("TPE1", "Funny Pranks")] -tests = TestList +tests = [TestLabel "Support for 'TYER' and 'TDAT' frames" testReadingTagWithTYERAndTDATFrames, TestLabel "Support for 'TSIZ' frame" testReadingTagWithTSIZFrame, TestLabel "Support for 'UFID' frame" testReadingTagWithUFIDFrame, @@ -49,7 +49,3 @@ testReadingTagWithUnsupportedFramesPresent, TestLabel "Support for reading tags with illegal newline character(s) in frame" testReadingTagWithIllegalNewlineCharactersInFrame] - -main = do - _ <- getTestDir -- Make sure test directory was passed as a command-line argument. - runTestTT tests === modified file 'test/HandlingOfUnsupportedFilesTests.hs' --- test/HandlingOfUnsupportedFilesTests.hs 2010-10-31 23:33:48 +0000 +++ test/HandlingOfUnsupportedFilesTests.hs 2012-08-26 05:53:24 +0000 @@ -1,7 +1,7 @@ -module Main where +module HandlingOfUnsupportedFilesTests (tests) where import Test.HUnit -import TestHelp (getTestDir, testFile) +import TestHelp (testFile) import ID3 (readTag) @@ -10,10 +10,6 @@ maybeTag <- readTag fpath assertEqual "We at least want to make sure the library doesn't crash" Nothing maybeTag -tests = TestList +tests = [TestLabel "Make sure library doesn't crash when trying to read a pre-ID3v2.3 tag" testTryingToReadMP3WithOldUnsupportedID3v2Tag] - -main = do - _ <- getTestDir -- Make sure test directory was passed as a command-line argument. - runTestTT tests === modified file 'test/HeaderTests.hs' --- test/HeaderTests.hs 2011-01-29 23:26:47 +0000 +++ test/HeaderTests.hs 2012-08-26 05:51:15 +0000 @@ -1,7 +1,7 @@ -module Main where +module HeaderTests (tests) where import Test.HUnit -import TestHelp (getTestDir, testFile, getValueForTextFrame, assertTagHasGivenTextValues) +import TestHelp (assertTagHasGivenTextValues) -- This test does not actually assert that we properly make use of or read the extended -- header, but only that a tag containing an extended header still leads to proper reading @@ -10,10 +10,6 @@ assertTagHasGivenTextValues "has-extended-header.mp3" [("TCON", "Pranks"), ("TPE1", "Funny Pranks")] -tests = TestList +tests = [TestLabel "test that a tag containing an extended header can be read" testReadingTagThatHasExtendedHeader] - -main = do - _ <- getTestDir -- Make sure test directory was passed as a command-line argument. - runTestTT tests === modified file 'test/TestHelp.hs' --- test/TestHelp.hs 2012-08-26 01:34:55 +0000 +++ test/TestHelp.hs 2012-08-26 05:45:20 +0000 @@ -1,24 +1,15 @@ -module TestHelp (getTestDir, testFile, getValueForTextFrame, assertTagHasGivenFrames, +module TestHelp (testFile, getValueForTextFrame, assertTagHasGivenFrames, assertTagHasGivenTextValues) where +import Paths_idiii (getDataFileName) import Test.HUnit import qualified Data.Map as Map import ID3 (ID3Tag, ID3Frame(..), readTag, tagFrames) import ID3.Type.FrameInfo (FrameInfo(Text, COMM, WXXX)) -import System.Environment (getArgs) -import System.FilePath (joinPath) - -testFile fname = do - testDir <- getTestDir - return $ joinPath [testDir, "resources", fname] - -getTestDir = do - args <- getArgs - if length args == 0 - then error "You must specify the test directory as a parameter to run this test script." - else return $ head args + +testFile = getDataFileName assertTagHasGivenFrames :: String -> [(String, FrameInfo)] -> Assertion assertTagHasGivenFrames fname expectedFrames = do === modified file 'test/UnsynchronisationHandlingTests.hs' --- test/UnsynchronisationHandlingTests.hs 2010-10-31 22:40:56 +0000 +++ test/UnsynchronisationHandlingTests.hs 2012-08-26 05:49:48 +0000 @@ -1,7 +1,7 @@ -module Main where +module UnsynchronisationHandlingTests (tests) where import Test.HUnit -import TestHelp (getTestDir, assertTagHasGivenTextValues) +import TestHelp (assertTagHasGivenTextValues) testReadingID3v2v3TagThatHasUnsynchronisationFlagOffWithLargeFrame = TestCase $ assertTagHasGivenTextValues "large-comm-frame-with-unsync-not-used.mp3" @@ -27,12 +27,8 @@ "maximum value that a single byte can hold, because we need to test that ID3v2.4 " ++ "tags are read properly with regard to \"unsynchronisation\"." -tests = TestList +tests = [TestLabel "Make sure we properly handle ID3v2.3 tags that have \"unsynchronisation\" flag off" testReadingID3v2v3TagThatHasUnsynchronisationFlagOffWithLargeFrame, TestLabel "Make sure we properly handle \"unsynchronisation\" for ID3v2.4 tags" testReadingID3v2v4TagThatWithLargeFrame] - -main = do - _ <- getTestDir -- Make sure test directory was passed as a command-line argument. - runTestTT tests === removed file 'test/test.hs' --- test/test.hs 2011-03-21 18:49:06 +0000 +++ test/test.hs 1970-01-01 00:00:00 +0000 @@ -1,63 +0,0 @@ -#! /usr/bin/env runhaskell -module Main where - -import Control.Monad (when) -import Data.String.Utils (replace, split, strip) - -import System (getArgs) - -import System.Directory (setCurrentDirectory, getDirectoryContents) -import System.IO (hGetContents) -import System.Process (readProcess) ---import System.Process (runInteractiveCommand, waitForProcess) -import System.Environment.FindBin (getProgPath) -import System.Exit (ExitCode(..)) -import System.FilePath (takeDirectory, joinPath) - -main = do - args <- getArgs - when (length args > 1) $ error $ "This script currently only supports running one test at a " ++ - "time or running the entire test suite (by passing no command-line arguments)." - testDir <- getProgPath - let rootDir = takeDirectory testDir - let srcDir = joinPath [rootDir, "src"] - -- Setting "current working directory" is necessary so modules will be found as expected... - setCurrentDirectory srcDir - case length args of - 1 -> do out <- runTest rootDir testDir $ joinPath [rootDir, head args] - putStrLn out - 0 -> do fs <- getTestFiles testDir - runManyTests rootDir testDir $ map (\f -> joinPath [testDir, f]) fs - putStrLn "Looks like we've had success." - where - runTest rootDir testDir testFile = readProcess "runhaskell" - ["-i" ++ joinPath [rootDir, "test"], testFile, testDir] "" - runManyTests rootDir testDir fs = foreach fs (\f -> do - putStrLn $ "Running test " ++ f ++ " ..." - out <- runTest rootDir testDir f - let outputSplit = filter (/="") $ map strip $ split " " $ replace "\r" " " out - if looksLikeSuccess outputSplit - then putStrLn $ "Test " ++ f ++ " seemed to pass." - else error $ "FAILURE!\n\nHere's the output...\n\n" ++ out) - looksLikeSuccess out = (takeLast 4 out == ["Errors:", "0", "Failures:", "0"]) || - (takeLast 6 out == ["errors", "=", "0,", "failures", "=", "0}"]) - takeLast n l = reverse $ take n $ reverse l - getTestFiles dir = do - fs <- getDirectoryContents dir - return $ filter (`notElem` ["test.hs", "TestHelp.hs"]) $ - filter (\f -> takeLast 3 f == ".hs") fs - -foreach items action = mapM_ action items - -{- -getProcessOutput :: String -> IO String -getProcessOutput command = do - -- Create the process - (_pIn, pOut, pErr, handle) <- runInteractiveCommand command - -- Wait for the process to finish and store its exit code - exitCode <- waitForProcess handle - -- Get the standard output. - output <- hGetContents pOut - -- return both the output and the exit code. - return output --}