[#233] Put testing library code into its own package
Description
Problem
We currently have test-related modules scattered across multiple packages:
-
Michelson.Test
andMichelson.Doc.Test
inmorley
-
Lorentz.Test
inlorentz
morley-nettest
- Hegdehog generators defined in multiple modules in
morley
andlorentz
We should move them to one single package, cleveland
.
Solution
The overall strategy was this:
- Since the
morley-nettest
only contains test-related stuff, we could move everything here, and then - Rename this package to
cleveland
.
However, this would lead to 3 cyclic dependencies at the package-level that had to be resolved first in order to make this strategy feasible. These were discussed in detail here, but here's a summary:
- There would be a cyclic dependency between
morley
andcleveland
:-
morley:test:morley-test
/bench
would depend oncleveland:lib
, andcleveland:lib
onmorley:lib
. - We solved this by moving
morley-test
/bench
to the cleveland package
-
- There would be a cyclic dependency between
lorentz
andcleveland
:-
lorentz:test:lorentz-test
would depend oncleveland:lib
, andcleveland:lib
onlorentz:lib
. - We solved this by moving
lorentz-test
to the cleveland package
-
- There would be a cyclic dependency between
indigo
andcleveland
:
Outstanding issues
~Because I moved genMText
out of Michelson.Text
, I also had to export minBoundMChar
and maxBoundMChar
to make them accessible to Hedgehog.Gen.Michelson
. These were previously internal, and I'm personally not very fond of having these in the public interface.
I see these possible solutions:
- Do not reuse
min
/maxBoundMChar
, and simply duplicate them inHedgehog.Gen.Michelson
- Replace
min
/maxBoundMChar
with a bounded newtype and accompanying functions, and expose these instead. E.g.:newtype MChar = MChar Char instance Bounded MChar where ... instance Enum MChar where ... mkMChar :: Char -> Either String MChar mkMTextFromMChars :: [MChar] -> Either String MText
- Leave
min
/maxBoundMChar
in the public interface, not a big deal.~
Package dependency graph
The package dependency graph now looks like this (excluding morley-prelude
and tasty-hunit-compat
for simplicity):
(Generated using stack dot --test --bench --prune "morley-prelude,tasty-hunit-compat" | dot -T png -o a.png
)
Related issue(s)
Resolves #233 (closed)
✅ Checklist for your Merge Request
Related changes (conditional)
-
Tests (see short guidelines)
-
If I added new functionality, I added tests covering it. -
If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
-
-
Documentation
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.