about summary refs log tree commit diff
path: root/pkgs/test
diff options
context:
space:
mode:
authorDennis Gosnell <cdep.illabout@gmail.com>2023-07-04 15:38:23 +0900
committerDennis Gosnell <cdep.illabout@gmail.com>2023-07-04 15:38:23 +0900
commit55b8958f7d7e76a3328e7287c8c7d7572d980f9d (patch)
treedd7d924966c5650a115b7216e32cdde5073320d1 /pkgs/test
parent9393b5fc08755021a5b245e24cd058d7ac7848ca (diff)
tests.haskell.shellFor: change package used in extraDependencies test
This commit does the following two things:

1.  Changes the Haskell package used in the extraDependencies test from
    releaser to conduit.  The reason for this is that conduit is more
    of a "core" package in Haskell, and it is more likely to always be
    working.  (If conduit is not compiling, then large chunks of Hackage
    won't be working.)

2.  Tighten up the GHCi test to actually use the package from
    extraDependencies.  It appears that GHCi can fail to import the
    package from extraDependencies, and that doesn't cause GHCi to
    return an error code, which means the test isn't actually testing
    anything.

    This new change makes it so that if the package from
    extraDependencies is actually not included for some reason, then
    this shellFor test should fail.
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/haskell/shellFor/default.nix22
1 files changed, 16 insertions, 6 deletions
diff --git a/pkgs/test/haskell/shellFor/default.nix b/pkgs/test/haskell/shellFor/default.nix
index aa06ff6e52f8e..83daf079cc0f2 100644
--- a/pkgs/test/haskell/shellFor/default.nix
+++ b/pkgs/test/haskell/shellFor/default.nix
@@ -2,7 +2,11 @@
 
 (haskellPackages.shellFor {
   packages = p: [ p.constraints p.linear ];
-  extraDependencies = p: { libraryHaskellDepends = [ p.releaser ]; };
+  # WARNING: When updating this, make sure that the libraries passed to
+  # `extraDependencies` are not actually transitive dependencies of libraries in
+  # `packages` above.  We explicitly want to test that it is possible to specify
+  # `extraDependencies` that are not in the closure of `packages`.
+  extraDependencies = p: { libraryHaskellDepends = [ p.conduit ]; };
   nativeBuildInputs = [ cabal-install ];
   phases = [ "unpackPhase" "buildPhase" "installPhase" ];
   unpackPhase = ''
@@ -18,13 +22,19 @@
     mkdir -p $HOME/.cabal
     touch $HOME/.cabal/config
 
-    # Check extraDependencies.libraryHaskellDepends arg
+    # Check that the extraDependencies.libraryHaskellDepends arg is correctly
+    # picked up. This uses ghci to interpret a small Haskell program that uses
+    # a package from extraDependencies.
     ghci <<EOF
-    :m + Releaser.Primitives
-    :m + System.IO
-    writeFile "done" "done"
+    :set -XOverloadedStrings
+    :m + Conduit
+    runResourceT $ connect (yield "done") (sinkFile "outfile")
     EOF
-    [[ done == $(cat done) ]]
+
+    if [[ "done" != "$(cat outfile)" ]]; then
+      echo "ERROR: extraDependencies appear not to be available in the environment"
+      exit 1
+    fi
 
     # Check packages arg
     cabal v2-build --offline --verbose constraints linear --ghc-options="-O0 -j$NIX_BUILD_CORES"