Skip to content
Merged
18 changes: 18 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@
overrideInputs."haskell-parsers" = ./nix/haskell-parsers;
};

test-simple = {
dir = "test/simple";
overrideInputs = {
"haskell-flake" = ./.;
"flake-parts" = "github:hercules-ci/flake-parts/7c7a8bce3dffe71203dcd4276504d1cb49dfe05f";
"nixpkgs" = "github:nixos/nixpkgs/bb31220cca6d044baa6dc2715b07497a2a7c4bc7";
};
};

test-project-module = {
dir = "test/project-module";
overrideInputs = {
"haskell-flake" = ./.;
"flake-parts" = "github:hercules-ci/flake-parts/7c7a8bce3dffe71203dcd4276504d1cb49dfe05f";
"nixpkgs" = "github:nixos/nixpkgs/bb31220cca6d044baa6dc2715b07497a2a7c4bc7";
};
};

# Legacy shell script test
test = {
dir = "test";
Expand Down
3 changes: 1 addition & 2 deletions runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ nix --version
# TODO: Supplant these scripts with Nix. See https://github.com/srid/haskell-flake/issues/241
TESTS=(
./example
./test/simple
# TODO: Move these to flake check, just like ./test/{simple, project-module}
./test/with-subdir
./test/project-module
# We run this separately, because it's a bit slow.
# ./doc
)
Expand Down
2 changes: 1 addition & 1 deletion test/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function logHeader {

nix --version

SYSTEM=$(nix show-config | grep 'system =' | awk '{print $3}')
SYSTEM=$(nix eval --impure --expr builtins.currentSystem)

DIR_OF_COMMON_SH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
HASKELL_FLAKE=${DIR_OF_COMMON_SH}/..
Expand Down
9 changes: 0 additions & 9 deletions test/project-module/test.sh

This file was deleted.

50 changes: 46 additions & 4 deletions test/simple/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
flake-parts = { };
haskell-flake = { };

check-flake.url = "github:srid/check-flake/48a17393ed4fcd523399d6602c283775b5127295";

haskell-multi-nix.url = "github:srid/haskell-multi-nix/7aed736571714ec12105ec110358998d70d59e34";
haskell-multi-nix.flake = false;
};
Expand All @@ -17,7 +15,6 @@
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
inputs.haskell-flake.flakeModule
inputs.check-flake.flakeModule
];
flake.haskellFlakeProjectModules.default = { pkgs, lib, ... }: {
packages = {
Expand All @@ -38,7 +35,6 @@
# Setting to null should remove this tool from defaults.
ghcid = null;
};
hlsCheck.enable = true;
};
};
perSystem = { self', pkgs, lib, ... }: {
Expand Down Expand Up @@ -74,6 +70,52 @@
# An explicit app to test `nix run .#test` (*without* falling back to
# using self.packages.test)
apps.app1 = self'.apps.haskell-flake-test;

# Our test
checks.test =
pkgs.runCommandNoCC "simple-test"
{
nativeBuildInputs = with pkgs; [
which
] ++ self'.devShells.default.nativeBuildInputs;

# Test defaults.settings module behaviour, viz: haddock
NO_HADDOCK =
lib.assertMsg (!lib.hasAttr "doc" self'.packages.default)
"doc output should not be present";
}
''
(
set -x
echo "Testing test/simple ..."

# Run the cabal executable as flake app
${self'.apps.app1.program} | grep fooFunc

# Setting buildTools.ghcid to null should disable that default
# buildTool (ghcid)
which ghcid && \
(echo "ghcid should not be in devshell"; exit 2)

# Adding a buildTool (fzf, here) should put it in devshell.
which fzf || \
(echo "fzf should be in devshell"; exit 2)

# mkShellArgs works
${self'.devShells.default.shellHook}
if [[ "$FOO" == "bar" ]]; then
echo "$FOO"
else
echo "FOO is not bar"
exit 2
fi

# extraLibraries works
runghc ${./script} | grep -F 'TOML-flavored boolean: Bool True'

touch $out
)
'';
};
};
}
29 changes: 0 additions & 29 deletions test/simple/test-in-devshell.sh

This file was deleted.

27 changes: 0 additions & 27 deletions test/simple/test.sh

This file was deleted.