Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate from Microspec to Hspec #1157

Merged
merged 6 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,23 @@ jobs:

- name: test
run: cabal v2-test ${{ matrix.versions.args }} --enable-tests --enable-benchmarks all
ormolu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Detect and switch to current branch
run: |
BRANCH_NAME=$(git branch --show-current || echo "${{ github.ref_name }}")
git checkout "$BRANCH_NAME"

- uses: haskell-actions/run-ormolu@v17
with:
mode: inplace
pattern: |
src/**/*.hs
tidal-core/src/**/*.hs
tidal-link/src/**/*.hs
tidal-parse/src/**/*.hs
tidal-listener/src/**/*.hs

- name: apply ormolu formatting
uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ always() }}
with:
commit_message: automated ormolu reformatting
branch: ${{ github.head_ref || github.ref_name }}
ormolu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: haskell-actions/run-ormolu@v17
with:
mode: inplace
pattern: |
src/**/*.hs
tidal-core/src/**/*.hs
tidal-link/src/**/*.hs
tidal-parse/src/**/*.hs
tidal-listener/src/**/*.hs
- name: apply ormolu formatting
uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ always() }}
with:
commit_message: automated ormolu reformatting
branch: ${{ github.head_ref || github.ref_name }}
2 changes: 1 addition & 1 deletion src/Sound/Tidal/Stream/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ type PlayMap = Map.Map PatId PlayState
-- tickArc :: Arc,
-- tickNudge :: Double
-- }
-- deriving Show
-- deriving Show
3 changes: 3 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ packages:
extra-deps:
- hosc-0.21
- haskellish-0.3.2.2
- hspec-2.11.9
- hspec-core-2.11.9
- hspec-discover-2.11.9
4 changes: 2 additions & 2 deletions test/Sound/Tidal/StreamTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import qualified Data.Map.Strict as M
import qualified Sound.Osc.Fd as O
import Sound.Tidal.Pattern
import Sound.Tidal.Stream
import Test.Microspec
import Test.Hspec

run :: Microspec ()
run :: Spec
run =
describe "Sound.Tidal.Stream" $ do
describe "toDatum" $ do
Expand Down
4 changes: 2 additions & 2 deletions test/Test.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{-# LANGUAGE OverloadedStrings #-}

import Sound.Tidal.StreamTest
import Test.Microspec
import Test.Hspec

main :: IO ()
main = microspec $ do
main = hspec $ do
Sound.Tidal.StreamTest.run
8 changes: 4 additions & 4 deletions test/TestUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

import Data.List (sort)
import qualified Data.Map.Strict as Map
import Sound.Tidal.Context

Check warning on line 9 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.8.4

The import of ‘Data.Ratio’ is redundant

Check warning on line 9 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Data.Ratio’ is redundant

Check warning on line 9 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.6.5

The import of ‘Data.Ratio’ is redundant

Check warning on line 9 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.10.7

The import of ‘Data.Ratio’ is redundant

Check warning on line 9 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.4.1.0 - ghc 9.0.2

The import of ‘Data.Ratio’ is redundant

Check warning on line 9 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Data.Ratio’ is redundant
import Test.Microspec
import Test.Hspec

Check warning on line 10 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.8.4

The import of ‘Sound.Tidal.Control’ is redundant

Check warning on line 10 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Control’ is redundant

Check warning on line 10 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.6.5

The import of ‘Sound.Tidal.Control’ is redundant

Check warning on line 10 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.10.7

The import of ‘Sound.Tidal.Control’ is redundant

Check warning on line 10 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.4.1.0 - ghc 9.0.2

The import of ‘Sound.Tidal.Control’ is redundant

Check warning on line 10 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Control’ is redundant
import Prelude hiding ((*>), (<*))

Check warning on line 11 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.8.4

The import of ‘Sound.Tidal.Core’ is redundant

Check warning on line 11 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Core’ is redundant

Check warning on line 11 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.6.5

The import of ‘Sound.Tidal.Core’ is redundant

Check warning on line 11 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.10.7

The import of ‘Sound.Tidal.Core’ is redundant

Check warning on line 11 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.4.1.0 - ghc 9.0.2

The import of ‘Sound.Tidal.Core’ is redundant

Check warning on line 11 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Core’ is redundant

Check warning on line 12 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.8.4

The import of ‘Sound.Tidal.Params’ is redundant

Check warning on line 12 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Params’ is redundant

Check warning on line 12 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.6.5

The import of ‘Sound.Tidal.Params’ is redundant

Check warning on line 12 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.10.7

The import of ‘Sound.Tidal.Params’ is redundant

Check warning on line 12 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.4.1.0 - ghc 9.0.2

The import of ‘Sound.Tidal.Params’ is redundant

Check warning on line 12 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Params’ is redundant
class TolerantEq a where
(~==) :: a -> a -> Bool

Check warning on line 15 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.8.4

The import of ‘Sound.Tidal.Scales’ is redundant

Check warning on line 15 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Scales’ is redundant

Check warning on line 15 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.6.5

The import of ‘Sound.Tidal.Scales’ is redundant

Check warning on line 15 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.10.7

The import of ‘Sound.Tidal.Scales’ is redundant

Check warning on line 15 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.4.1.0 - ghc 9.0.2

The import of ‘Sound.Tidal.Scales’ is redundant

Check warning on line 15 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Scales’ is redundant
instance TolerantEq Double where

Check warning on line 16 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.8.4

The import of ‘Sound.Tidal.Show’ is redundant

Check warning on line 16 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Show’ is redundant

Check warning on line 16 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.6.5

The import of ‘Sound.Tidal.Show’ is redundant

Check warning on line 16 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.10.7

The import of ‘Sound.Tidal.Show’ is redundant

Check warning on line 16 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.4.1.0 - ghc 9.0.2

The import of ‘Sound.Tidal.Show’ is redundant

Check warning on line 16 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Show’ is redundant
a ~== b = abs (a - b) < 0.000001

Check warning on line 17 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.8.4

The import of ‘Sound.Tidal.Simple’ is redundant

Check warning on line 17 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Simple’ is redundant

Check warning on line 17 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.6.5

The import of ‘Sound.Tidal.Simple’ is redundant

Check warning on line 17 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.10.7

The import of ‘Sound.Tidal.Simple’ is redundant

Check warning on line 17 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.4.1.0 - ghc 9.0.2

The import of ‘Sound.Tidal.Simple’ is redundant

Check warning on line 17 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Simple’ is redundant

Check warning on line 18 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.8.4

The import of ‘Sound.Tidal.Stepwise’ is redundant

Check warning on line 18 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Stepwise’ is redundant

Check warning on line 18 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.6.5

The import of ‘Sound.Tidal.Stepwise’ is redundant

Check warning on line 18 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.10.7

The import of ‘Sound.Tidal.Stepwise’ is redundant

Check warning on line 18 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.4.1.0 - ghc 9.0.2

The import of ‘Sound.Tidal.Stepwise’ is redundant

Check warning on line 18 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.Stepwise’ is redundant
instance TolerantEq Value where

Check warning on line 19 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.8.4

The import of ‘Sound.Tidal.UI’ is redundant

Check warning on line 19 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.6.5

The import of ‘Sound.Tidal.UI’ is redundant

Check warning on line 19 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.6.2.0-p1 - ghc 8.10.7

The import of ‘Sound.Tidal.UI’ is redundant

Check warning on line 19 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.4.1.0 - ghc 9.0.2

The import of ‘Sound.Tidal.UI’ is redundant

Check warning on line 19 in test/TestUtils.hs

View workflow job for this annotation

GitHub Actions / cabal 3.12.1.0 - ghc 9.4.8

The import of ‘Sound.Tidal.UI’ is redundant
(VS a) ~== (VS b) = a == b
(VI a) ~== (VI b) = a == b
(VR a) ~== (VR b) = a == b
Expand All @@ -33,13 +33,13 @@
(Event _ w p x) ~== (Event _ w' p' x') = w == w' && p == p' && x ~== x'

-- | Compare the events of two patterns using the given arc
compareP :: (Ord a, Show a) => Arc -> Pattern a -> Pattern a -> Property
compareP :: (Ord a, Show a) => Arc -> Pattern a -> Pattern a -> Expectation
compareP a p p' =
sort (queryArc (stripContext p) a)
`shouldBe` sort (queryArc (stripContext p') a)

-- | Like @compareP@, but tries to 'defragment' the events
comparePD :: (Ord a, Show a) => Arc -> Pattern a -> Pattern a -> Property
comparePD :: (Ord a, Show a) => Arc -> Pattern a -> Pattern a -> Expectation
comparePD a p p' =
sort (defragParts $ queryArc (stripContext p) a)
`shouldBe` sort (defragParts $ queryArc (stripContext p') a)
Expand All @@ -56,4 +56,4 @@
stripContext = setContext $ Context []

firstCycleValues :: Pattern a -> [a]
firstCycleValues pat = map value $ queryArc pat (Arc 0 1)
firstCycleValues pat = map value $ queryArc pat (Arc 0 1)
4 changes: 2 additions & 2 deletions tidal-core/src/Sound/Tidal/Scales.hs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ getScale table sp p =
noteInScale (fromMaybe [0] $ lookup scaleName table) n
)
<$> p
<* sp
<* sp
where
octave s x = x `div` length s
noteInScale s x = (s !!! x) + fromIntegral (12 * octave s x)
Expand Down Expand Up @@ -337,7 +337,7 @@ getScaleMod table sp f p =
noteInScale (uniq $ f $ fromMaybe [0] $ lookup scaleName table) n
)
<$> p
<* sp
<* sp
where
octave s x = x `div` length s
noteInScale s x = (s !!! x) + fromIntegral (12 * octave s x)
Expand Down
4 changes: 2 additions & 2 deletions tidal-core/test/Sound/Tidal/ChordsTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
module Sound.Tidal.ChordsTest where

import Sound.Tidal.Pattern
import Test.Microspec
import Test.Hspec
import TestUtils
import Prelude hiding ((*>), (<*))

run :: Microspec ()
run :: Spec
run =
describe "Sound.Tidal.Chords" $ do
describe "chord" $ do
Expand Down
4 changes: 2 additions & 2 deletions tidal-core/test/Sound/Tidal/ControlTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import Sound.Tidal.Control
import Sound.Tidal.Core
import Sound.Tidal.Params
import Sound.Tidal.Pattern
import Test.Microspec
import Test.Hspec
import TestUtils
import Prelude hiding ((*>), (<*))

run :: Microspec ()
run :: Spec
run =
describe "Sound.Tidal.Control" $ do
describe "echo" $ do
Expand Down
Loading
Loading