Skip to content

Commit

Permalink
Fold the test packages into existing lib packages (#44)
Browse files Browse the repository at this point in the history
`yaya-test` was separate because the dependency on `yaya-hedgehog`
prevented it from being included in `yaya`. However, a separate
test-suite package isn’t particularly useful. This folds it into
`yaya-hedgehog`, as the closest option.

Similarly, `yaya-unsafe-test` is folded into `yaya-unsafe`, which had no
reason to be separate in the first place.
  • Loading branch information
sellout committed Mar 11, 2024
2 parents 0298eaa + 90102d6 commit cfa7e77
Show file tree
Hide file tree
Showing 18 changed files with 134 additions and 1,706 deletions.
2 changes: 0 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ tests: True
packages:
./containers/yaya-containers.cabal
./core/yaya.cabal
./core-test/yaya-test.cabal
./hedgehog/yaya-hedgehog.cabal
./quickcheck/yaya-quickcheck.cabal
./unsafe/yaya-unsafe.cabal
./unsafe-test/yaya-unsafe-test.cabal
661 changes: 0 additions & 661 deletions core-test/LICENSE

This file was deleted.

175 changes: 0 additions & 175 deletions core-test/yaya-test.cabal

This file was deleted.

2 changes: 2 additions & 0 deletions core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Recursion schemes allow you to separate _any_ recursion from your business logic

How's this possible? You can’t have totality _and_ Turing-completeness, can you? Oh, but [you can](https://pdfs.semanticscholar.org/e291/5b546b9039a8cf8f28e0b814f6502630239f.pdf) – there is a particular type, `Partial a` (encoded with a fixed-point) that handles potential non-termination, akin to the way that `Maybe a` handles exceptional cases. It can be folded into `IO` in your main function, so that the runtime can execute a Turing-complete program that was modeled totally.

**NB**: The tests for this package are unfortunately included in `yaya-hedgehog` instead, to avoid a dependency cycle.

## organization

This organization is intended to make this a lightly-opinionated library. You should only need to import one module (per package) into any module of yours.
Expand Down
36 changes: 8 additions & 28 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,14 @@

supportedSystems = flaky.lib.defaultSystems;

cabalPackages = pkgs: hpkgs: let
packages =
concat.lib.cabalProject2nix
./cabal.project
pkgs
hpkgs
(old: {
configureFlags = old.configureFlags ++ ["--ghc-options=-Werror"];
});
in
packages
// {
"${pname}-test" = self.lib.testOnly packages."${pname}-test";
"${pname}-unsafe-test" =
self.lib.testOnly packages."${pname}-unsafe-test";
};
cabalPackages = pkgs: hpkgs:
concat.lib.cabalProject2nix
./cabal.project
pkgs
hpkgs
(old: {
configureFlags = old.configureFlags ++ ["--ghc-options=-Werror"];
});
in
{
schemas = {
Expand Down Expand Up @@ -167,18 +159,6 @@
supportedSystems);

lib = {
## TODO: Move upstream.
## Don’t install this Haskell package – it only contains test suites.
testOnly = drv:
drv.overrideAttrs (old: {
installPhase = ''
runHook preInstall
mkdir -p "$out"
runHook postInstall
'';
outputs = ["out"];
});

## TODO: Extract this automatically from `pkgs.haskellPackages`.
defaultCompiler = "ghc948";

Expand Down
18 changes: 18 additions & 0 deletions hedgehog/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ This file documents all notable changes to this package.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/).

## 0.2.1.3 – 2024–03–11

### Added

- The tests for `yaya` were previously in their own `yaya-test` package, but that has been folded into this package. Ideally, the tests would live in the `yaya` package, but Cabal doesn’t play well with circular dependencies between packages (even if the component dependencies aren’t circular).

## 0.2.1.2

Unknown changes.

## 0.2.1.1

Unknown changes.

## 0.2.1.0

Unknown changes.

## 0.2.0.2 – 2023–12–21

### Changed
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
43 changes: 42 additions & 1 deletion hedgehog/yaya-hedgehog.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.0

name: yaya-hedgehog
version: 0.2.1.2
version: 0.2.1.3
synopsis: Hedgehog testing support for the Yaya recursion scheme
library.
description: If you use Yaya in your own code and have tests written
Expand Down Expand Up @@ -204,3 +204,44 @@ test-suite doctests
-- “Build_doctests.hs”, we set it here, and that means it has to match
-- doctests.hs, which is `Unsafe`.
Unsafe

-- NB: This suite should be in the `yaya` package, but it can’t because it
-- depends on `yaya-hedgehog`.
test-suite yaya
import: defaults
type: exitcode-stdio-1.0
hs-source-dirs:
tests
main-is: test.hs
other-modules:
Test.Fold
Test.Fold.Common
Test.Fold.Native
Test.Retrofit
build-depends:
deriving-compat,
hedgehog,
yaya >= 0.5.0,
yaya-hedgehog >= 0.2.0,
ghc-options:
-rtsopts
-threaded
-trust adjunctions
-trust array
-trust base-orphans
-trust binary
-trust bytestring
-trust containers
-trust distributive
-trust exceptions
-trust ghc-prim
-trust hashable
-trust profunctors
-trust semigroupoids
-trust stm
-trust text
-trust transformers-compat
-with-rtsopts=-N
if impl(ghc < 9.6)
ghc-options:
-trust foldable1-classes-compat
Loading

0 comments on commit cfa7e77

Please sign in to comment.