diff --git a/htagcli.cabal b/htagcli.cabal index ea36d64..f717da2 100644 --- a/htagcli.cabal +++ b/htagcli.cabal @@ -129,10 +129,6 @@ test-suite tests Tests.Model.Pattern Tests.Model.Tag - ghc-options: - -F - -pgmF=tasty-autocollect - build-depends: hedgehog, hspec, @@ -147,7 +143,6 @@ test-suite tests path-io, resourcet, tasty, - tasty-autocollect, tasty-expected-failure, tasty-hedgehog, tasty-hunit-compat, diff --git a/tests/Main.hs b/tests/Main.hs index f28a8e5..e2b375a 100644 --- a/tests/Main.hs +++ b/tests/Main.hs @@ -1 +1,26 @@ -{- AUTOCOLLECT.MAIN -} +module Main (main) where + +import Test.Tasty (defaultMain, testGroup) +import Tests.Check.Album qualified as Check.Album +import Tests.Check.Artist qualified as Check.Artist +import Tests.Check.Track qualified as Check.Track +import Tests.Commands as Commands +import Tests.Config as Config +import Tests.Model.AudioTrack qualified as Model.AudioTrack +import Tests.Model.Pattern qualified as Model.Pattern +import Tests.Model.Tag qualified as Model.Tag + +main :: IO () +main = + defaultMain $ + testGroup + "Tests" + [ Commands.test, + Config.test, + Model.AudioTrack.test, + Model.Pattern.test, + Model.Tag.test, + Check.Album.test, + Check.Artist.test, + Check.Track.test + ] diff --git a/tests/Tests/Check/Album.hs b/tests/Tests/Check/Album.hs index b9babe6..7bcee49 100644 --- a/tests/Tests/Check/Album.hs +++ b/tests/Tests/Check/Album.hs @@ -1,11 +1,6 @@ -{- AUTOCOLLECT.TEST -} {-# LANGUAGE QuasiQuotes #-} -module Tests.Check.Album - ( - {- AUTOCOLLECT.TEST.export -} - ) -where +module Tests.Check.Album (test) where import Check.Album qualified as Album import Data.List.NonEmpty ((<|)) @@ -23,8 +18,18 @@ import Test.Tasty qualified as Tasty import Test.Tasty.HUnit qualified as Tasty import Tests.Common qualified as Common -test :: TestTree +test :: Tasty.TestTree test = + Tasty.testGroup + "Check.Album" + [ testCheckCover, + testCheckDirectory, + testCheckSameTags, + testCheckSequential + ] + +testCheckCover :: Tasty.TestTree +testCheckCover = Tasty.testGroup "check cover" [ Tasty.testCase "check an album without a cover.png" $ @@ -80,8 +85,8 @@ test = } covers = fromList [[relfile|cover.jpg|], [relfile|cover.png|]] -test :: TestTree -test = +testCheckDirectory :: Tasty.TestTree +testCheckDirectory = Tasty.testGroup "check directory" [ Tasty.testCase "an album is in a single directory" $ do @@ -105,8 +110,8 @@ test = { AudioTrack.atFile = newDir Path.filename (AudioTrack.atFile track) } -test :: TestTree -test = +testCheckSameTags :: Tasty.TestTree +testCheckSameTags = Tasty.testGroup "check same tags" [ Tasty.testCase "all tracks have the same tags" $ do @@ -120,8 +125,8 @@ test = where commonTags = fromList [Tag.Genre, Tag.Year, Tag.Artist, Tag.AlbumArtist] -test :: TestTree -test = +testCheckSequential :: Tasty.TestTree +testCheckSequential = Tasty.testGroup "check sequential tracks" [ Tasty.testCase "the tracks are sequential" $ do diff --git a/tests/Tests/Check/Artist.hs b/tests/Tests/Check/Artist.hs index 9e5c26b..82e8317 100644 --- a/tests/Tests/Check/Artist.hs +++ b/tests/Tests/Check/Artist.hs @@ -1,11 +1,6 @@ -{- AUTOCOLLECT.TEST -} {-# LANGUAGE QuasiQuotes #-} -module Tests.Check.Artist - ( - {- AUTOCOLLECT.TEST.export -} - ) -where +module Tests.Check.Artist (test) where import Check.Artist qualified as Artist import Model.Artist qualified as Artist @@ -17,10 +12,10 @@ import Test.Tasty qualified as Tasty import Test.Tasty.HUnit qualified as Tasty import Tests.Common qualified as Common -test :: TestTree +test :: Tasty.TestTree test = Tasty.testGroup - "check artist" + "Check.Artist" [ Tasty.testCase "two albums of the same artist with the same genre" $ do let album1 = tenTracksAlbum (HTagLib.mkAlbum "album-1") rock album2 = tenTracksAlbum (HTagLib.mkAlbum "album-2") rock diff --git a/tests/Tests/Check/Track.hs b/tests/Tests/Check/Track.hs index 512046f..331dc69 100644 --- a/tests/Tests/Check/Track.hs +++ b/tests/Tests/Check/Track.hs @@ -1,11 +1,6 @@ -{- AUTOCOLLECT.TEST -} {-# LANGUAGE QuasiQuotes #-} -module Tests.Check.Track - ( - {- AUTOCOLLECT.TEST.export -} - ) -where +module Tests.Check.Track (test) where import Check.Track qualified as Track import Model.AudioTrack qualified as AudioTrack @@ -18,8 +13,15 @@ import Test.Hspec.Expectations (shouldBe) import Test.Tasty qualified as Tasty import Test.Tasty.HUnit qualified as Tasty -test :: TestTree +test :: Tasty.TestTree test = + Tasty.testGroup + "Check.Track" + [ testFilenameMatches + ] + +testFilenameMatches :: Tasty.TestTree +testFilenameMatches = Tasty.testGroup "FilenameMatches" [ Tasty.testCase diff --git a/tests/Tests/Commands.hs b/tests/Tests/Commands.hs index d735972..56c59b3 100644 --- a/tests/Tests/Commands.hs +++ b/tests/Tests/Commands.hs @@ -1,11 +1,6 @@ -{- AUTOCOLLECT.TEST -} {-# LANGUAGE QuasiQuotes #-} -module Tests.Commands - ( - {- AUTOCOLLECT.TEST.export -} - ) -where +module Tests.Commands (test) where import Check.Track qualified as Track import Commands qualified @@ -23,8 +18,11 @@ import Test.Tasty qualified as Tasty import Test.Tasty.HUnit qualified as Tasty import Tests.Common qualified as Common -test :: TestTree -test = +test :: Tasty.TestTree +test = Tasty.testGroup "Commands" [testFixFilePaths] + +testFixFilePaths :: Tasty.TestTree +testFixFilePaths = Tasty.testGroup "fixFilePaths" [ Tasty.testCase "dry run" $ diff --git a/tests/Tests/Config.hs b/tests/Tests/Config.hs index 7c7e7f8..fd3a817 100644 --- a/tests/Tests/Config.hs +++ b/tests/Tests/Config.hs @@ -1,17 +1,16 @@ -{- AUTOCOLLECT.TEST -} -module Tests.Config - ( - {- AUTOCOLLECT.TEST.export -} - ) -where +module Tests.Config (test) where import Config qualified import Test.Hspec.Expectations (shouldSatisfy) +import Test.Tasty qualified as Tasty import Test.Tasty.HUnit qualified as Tasty import UnliftIO.Exception qualified as Exception -test :: TestTree -test = +test :: Tasty.TestTree +test = Tasty.testGroup "Config" [testParseDefaultConfig] + +testParseDefaultConfig :: Tasty.TestTree +testParseDefaultConfig = Tasty.testCase "Default config should parse" $ do result <- Exception.tryAny $ Config.parseByteString Config.defaultConfigContent diff --git a/tests/Tests/Model/AudioTrack.hs b/tests/Tests/Model/AudioTrack.hs index a1784e6..b3e7d05 100644 --- a/tests/Tests/Model/AudioTrack.hs +++ b/tests/Tests/Model/AudioTrack.hs @@ -1,11 +1,6 @@ -{- AUTOCOLLECT.TEST -} {-# LANGUAGE QuasiQuotes #-} -module Tests.Model.AudioTrack - ( - {- AUTOCOLLECT.TEST.export -} - ) -where +module Tests.Model.AudioTrack (test) where import Control.Monad.Morph qualified as Morph import Control.Monad.Trans.Resource qualified as Resource @@ -25,6 +20,14 @@ import Test.Tasty qualified as Tasty import Test.Tasty.Hedgehog qualified as Tasty import Text.Megaparsec qualified as Megaparsec +test :: Tasty.TestTree +test = + Tasty.testGroup + "Model.AudioTrack" + [ testParse, + testSetGetRoundTrip + ] + audioTrackGen :: Hedgehog.Gen AudioTrack.AudioTrack audioTrackGen = do atFile <- absFileGen @@ -60,8 +63,8 @@ absFileGen = do pathPieceGen = HedgehogGen.string (HedgehogRange.linear 1 20) HedgehogGen.alphaNum -test :: TestTree -test = +testParse :: Tasty.TestTree +testParse = Tasty.testGroup "Parse" [ Tasty.testPropertyNamed "one" "test_parse_one" $ Hedgehog.property $ do @@ -77,8 +80,8 @@ test = === Right audioTracks ] -test :: TestTree -test = +testSetGetRoundTrip :: Tasty.TestTree +testSetGetRoundTrip = Tasty.testPropertyNamed "roundtrip" "test_set_get" $ do Hedgehog.property . Morph.hoist Resource.runResourceT $ do (_, tempDir) <- diff --git a/tests/Tests/Model/Pattern.hs b/tests/Tests/Model/Pattern.hs index 20c31c4..7958eef 100644 --- a/tests/Tests/Model/Pattern.hs +++ b/tests/Tests/Model/Pattern.hs @@ -1,11 +1,6 @@ -{- AUTOCOLLECT.TEST -} {-# LANGUAGE QuasiQuotes #-} -module Tests.Model.Pattern - ( - {- AUTOCOLLECT.TEST.export -} - ) -where +module Tests.Model.Pattern (test) where import Check.Track qualified as Track import Hedgehog ((===)) @@ -26,6 +21,18 @@ import Test.Tasty.HUnit qualified as Tasty import Test.Tasty.Hedgehog qualified as Tasty import Text.Megaparsec qualified as Megaparsec +test :: Tasty.TestTree +test = + Tasty.testGroup + "Model.Pattern" + [ testParseRoundTrip, + testStaticPatterns, + testTagPattern, + testOtherPatterns, + testParser, + testFormatting + ] + patternGen :: Hedgehog.Gen Pattern.Pattern patternGen = HedgehogGen.nonEmpty (HedgehogRange.linear 1 5) componentGen @@ -62,15 +69,15 @@ textGen :: Hedgehog.Gen Text textGen = HedgehogGen.text (HedgehogRange.linear 1 10) HedgehogGen.alphaNum -test :: TestTree -test = +testParseRoundTrip :: Tasty.TestTree +testParseRoundTrip = Tasty.testPropertyNamed "parse" "test_parse_pattern" $ Hedgehog.property $ do pattern <- Hedgehog.forAll patternGen Megaparsec.parse Pattern.parser "" (Pattern.asText pattern) === Right pattern -test :: TestTree -test = +testStaticPatterns :: Tasty.TestTree +testStaticPatterns = Tasty.testGroup "Static patterns" [ testFileMatchesAndToPath @@ -107,8 +114,8 @@ test = (trackWithFile [absfile|/some-path/to-somewhere/audio.mp3|]) ] -test :: TestTree -test = +testTagPattern :: Tasty.TestTree +testTagPattern = Tasty.testGroup "Tag patterns" [ testFileMatchesAndToPath @@ -225,8 +232,8 @@ testFileMatchesAndToPath text pattern track@AudioTrack.AudioTrack {..} = where root = [absdir|/|] -test :: TestTree -test = +testOtherPatterns :: Tasty.TestTree +testOtherPatterns = Tasty.testGroup "Other patterns" [ Tasty.testCase @@ -241,8 +248,8 @@ test = `shouldBe` False ] -test :: TestTree -test = +testParser :: Tasty.TestTree +testParser = Tasty.testGroup "Pattern parser" [ Tasty.testCase "single text" $ @@ -287,8 +294,8 @@ test = ] ] -test :: TestTree -test = +testFormatting :: Tasty.TestTree +testFormatting = Tasty.testGroup "Formatting options" [ Tasty.testCase "no substitutions" $ diff --git a/tests/Tests/Model/Tag.hs b/tests/Tests/Model/Tag.hs index a4d26c0..79ecaed 100644 --- a/tests/Tests/Model/Tag.hs +++ b/tests/Tests/Model/Tag.hs @@ -1,20 +1,18 @@ -{- AUTOCOLLECT.TEST -} - -module Tests.Model.Tag - ( - {- AUTOCOLLECT.TEST.export -} - ) -where +module Tests.Model.Tag (test) where import Hedgehog ((===)) import Hedgehog qualified import Hedgehog.Gen qualified as Hedgehog import Model.Tag qualified as Tag +import Test.Tasty qualified as Tasty import Test.Tasty.Hedgehog qualified as Tasty import Text.Megaparsec qualified as Megaparsec -test :: TestTree -test = +test :: Tasty.TestTree +test = Tasty.testGroup "Model.Tag" [testParseRoundTrip] + +testParseRoundTrip :: Tasty.TestTree +testParseRoundTrip = Tasty.testPropertyNamed "roundtrip" "test_parse_one" $ Hedgehog.property $ do tag <- Hedgehog.forAll Hedgehog.enumBounded Megaparsec.parse Tag.parser "" (Tag.asText tag) === Right tag