Add tasty test-suite for pure helpers. - #75
Merged
Conversation
The cabal file is restructured into a library plus executable plus
test-suite, sharing a `common opts` stanza for default extensions and
GHC options. The library exposes every module except `Main` so the
test-suite can import them directly.
Initial tests cover the pure logic that is easiest to nail down:
* `Lexer.doP`/`doF`/`doS`/`doI` for the mpg123 protocol parsers,
* `Tree.doOrphans` and `Tree.merge` (including the value-order
behavior of the latter),
* `FastIO.basenameP`/`dirnameP`/`trim`/`packedFileNameEndClean`,
* `Core.showTimeDiff_` across the four output branches.
`Lexer.doP/doF/doS/doI` and `Core.showTimeDiff_` are added to their
module export lists for testability.
CI runs `cabal build all && cabal test all` and `stack test`; the build
step is kept because `cabal test` does not build the executable.
The previous layout had the library and the executable sharing `hs-source-dirs: ./`, which let GHC's home-module rule treat every library module as a home source of the executable. It then tried to recompile them against the executable's (much smaller) dependency list and failed on clock/array/hscurses. Putting Main.hs under `app/` gives the executable a non-overlapping source directory and lets the library do its job: compiled once, linked into both the executable and the test-suite. Lexer-relevant types in `Syntax` now derive `Eq` and `Show`, which lets `LexerSpec` compare whole `Msg` values directly instead of pattern- matching out individual fields. The tests get noticeably shorter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Credit to Claude Code for this work:
The cabal file is restructured into a library plus executable plus
test-suite, sharing a
common optsstanza for default extensions andGHC options. The library exposes every module except
Mainso thetest-suite can import them directly.
Initial tests cover the pure logic that is easiest to nail down:
Lexer.doP/doF/doS/doIfor the mpg123 protocol parsers,Tree.doOrphansandTree.merge(including the value-orderbehavior of the latter),
FastIO.basenameP/dirnameP/trim/packedFileNameEndClean,Core.showTimeDiff_across the four output branches.Lexer.doP/doF/doS/doIandCore.showTimeDiff_are added to theirmodule export lists for testability.
CI runs
cabal build all && cabal test allandstack test; the buildstep is kept because
cabal testdoes not build the executable.Putting Main.hs under
app/gives the executable a non-overlappingsource directory and lets the library do its job: compiled once, linked
into both the executable and the test-suite.
Lexer-relevant types in
Syntaxnow deriveEqandShow, which letsLexerSpeccompare wholeMsgvalues directly instead of pattern-matching out individual fields. The tests get noticeably shorter.