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

Using doctest #8

Closed
DamienCassou opened this issue Apr 13, 2021 · 4 comments
Closed

Using doctest #8

DamienCassou opened this issue Apr 13, 2021 · 4 comments

Comments

@DamienCassou
Copy link

Hi,

I've applied your template to a small project but can't make doctest to run in GitHub Actions: it works for the stack build, but not for cabal or nix.

Do you have any idea what could be wrong?

@jonascarpay
Copy link
Owner

jonascarpay commented Apr 14, 2021

I personally don't use doctest, but a coworker who does explained that the issue is that doctest doesn't automatically pick up the project package db. You can try passing it as a flag through the haskell.nix module system like this:

diff --git a/pkgs.nix b/pkgs.nix
index d5871aa..b0d42c3 100644
--- a/pkgs.nix
+++ b/pkgs.nix
@@ -20,6 +20,11 @@ let
         name = "PKGNAME";
       };
       compiler-nix-name = "ghc8104";
+      modules = [{
+        packages.PKGNAME.components.tests.DOCTESTS.testFlags = [
+          "-package-db=${self.hsPkgs.PKGNAME.components.library.configFiles}/lib/ghc-8.10.4/package.conf.d/"
+        ];
+      }];
     };
   };
 in

where PKGNAME and DOCTESTS refer to the actual pkg name and name of the doctest suite, respectively.

@DamienCassou
Copy link
Author

Does this mean I have to create a dedicated doctest test-suite in the .cabal file? The name of the test-suite would be what you call DOCTESTS above?

@jonascarpay
Copy link
Owner

Oh, yeah, I was assuming you had a doctest suite. But calling the binary yourself has the same issue, you need to somehow pass it the package db. All I know is that the solution above has worked for my coworker, but there's also this PR (coincidentally by a different coworker) which might provide some useful insight.

@DamienCassou
Copy link
Author

Thank you very much for your answer. From what I understand, the support for doctest is not really there yet and developers are actively working on it. I will give up for now.

I don't think there is much to be done in template-haskell so I'm also closing this issue. Feel free to reopen it if you want to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants