mirror of
https://github.com/srid/haskell-flake.git
synced 2024-09-11 14:05:58 +03:00
test/{simple, project-module}
: convert to flake checks (#243)
This commit is contained in:
parent
4decea13df
commit
7e97ec1dc8
18
flake.nix
18
flake.nix
@ -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";
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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}/..
|
||||
|
@ -1,9 +0,0 @@
|
||||
source ../common.sh
|
||||
set -euxo pipefail
|
||||
|
||||
# First, build the flake
|
||||
logHeader "Testing nix build"
|
||||
nix build ${OVERRIDE_ALL}
|
||||
|
||||
logHeader "Testing nix devshell"
|
||||
nix develop ${OVERRIDE_ALL} -c echo
|
@ -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;
|
||||
};
|
||||
@ -17,7 +15,6 @@
|
||||
systems = nixpkgs.lib.systems.flakeExposed;
|
||||
imports = [
|
||||
inputs.haskell-flake.flakeModule
|
||||
inputs.check-flake.flakeModule
|
||||
];
|
||||
flake.haskellFlakeProjectModules.default = { pkgs, lib, ... }: {
|
||||
packages = {
|
||||
@ -38,7 +35,6 @@
|
||||
# Setting to null should remove this tool from defaults.
|
||||
ghcid = null;
|
||||
};
|
||||
hlsCheck.enable = true;
|
||||
};
|
||||
};
|
||||
perSystem = { self', pkgs, lib, ... }: {
|
||||
@ -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
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
# This script is run in a `nix develop` shell by Github Actions.
|
||||
#
|
||||
# You can also run it locally using:
|
||||
#
|
||||
# nix develop --override-input haskell-flake ../ -c ./test-in-devshell.sh
|
||||
#
|
||||
# Or, just run `runtest.sh` from project root.
|
||||
|
||||
set -xe
|
||||
|
||||
# Test haskell devshell (via HLS check)
|
||||
haskell-language-server
|
||||
|
||||
# Setting buildTools.ghcid to null should disable that default buildTool
|
||||
which ghcid && exit 2 || echo
|
||||
|
||||
# Adding a buildTool (fzf, here) should put it in devshell.
|
||||
which fzf
|
||||
|
||||
# mkShellArgs works
|
||||
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'
|
@ -1,27 +0,0 @@
|
||||
source ../common.sh
|
||||
set -euxo pipefail
|
||||
|
||||
rm -f result result-bin
|
||||
|
||||
# First, build the flake
|
||||
logHeader "Testing nix build"
|
||||
nix build ${OVERRIDE_ALL}
|
||||
|
||||
# Test defaults.settings module behaviour, viz: haddock
|
||||
nix build ${OVERRIDE_ALL} .#default^doc && {
|
||||
echo "ERROR: dontHaddock (from defaults.settings) not in effect"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Run the devshell test script in a nix develop shell.
|
||||
logHeader "Testing nix devshell"
|
||||
nix develop ${OVERRIDE_ALL} -c ./test-in-devshell.sh
|
||||
# Run the cabal executable as flake app
|
||||
logHeader "Testing nix flake app (cabal exe)"
|
||||
nix run ${OVERRIDE_ALL} .#app1
|
||||
# Test non-devshell features:
|
||||
# Checks
|
||||
logHeader "Testing nix flake checks"
|
||||
nix --option sandbox false build \
|
||||
--no-link --print-out-paths \
|
||||
${OVERRIDE_ALL} -L .#check
|
Loading…
Reference in New Issue
Block a user