Skip to content

Commit 5f1f2be

Browse files
authored
Merge pull request #126 from srid/more-tests
Add test for `hpack` support
2 parents b47c956 + c26dc57 commit 5f1f2be

File tree

13 files changed

+80
-25
lines changed

13 files changed

+80
-25
lines changed

example/test.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ set -euo pipefail
33

44
function templateTest () {
55
# Build haskell executable
6-
nix build \
7-
${OVERRIDE_HASKELL_FLAKE} \
8-
${OVERRIDE_NIXPKGS}
6+
nix build ${OVERRIDE_ALL}
97
# Test haskell devshell (via HLS check)
108
nix develop \
11-
${OVERRIDE_HASKELL_FLAKE} \
12-
${OVERRIDE_NIXPKGS} \
9+
${OVERRIDE_ALL} \
1310
-c haskell-language-server
1411
}
1512

nix/find-haskell-paths/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
source ../../test/common.sh
22

3-
nix eval -I nixpkgs=flake:github:nixos/nixpkgs/bb31220cca6d044baa6dc2715b07497a2a7c4bc7 \
3+
nix eval -I nixpkgs=flake:${NIXPKGS_URL} \
44
--impure --expr 'import ./parser_tests.nix {}'

runtest.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ TESTS=(
1111
./nix/find-haskell-paths
1212
./example
1313
./test/simple
14+
./test/hpack
1415
./test/with-subdir
1516
./doc
1617
)

test/common.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ fi
1414
DIR_OF_COMMON_SH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1515
HASKELL_FLAKE=${DIR_OF_COMMON_SH}/..
1616
OVERRIDE_HASKELL_FLAKE="--override-input haskell-flake path:${HASKELL_FLAKE}"
17-
OVERRIDE_NIXPKGS="--override-input nixpkgs github:nixos/nixpkgs/bb31220cca6d044baa6dc2715b07497a2a7c4bc7"
17+
18+
# Let's pin both nixpkgs and flake-parts across all tests, to save up on CI time.
19+
NIXPKGS_URL="github:nixos/nixpkgs/bb31220cca6d044baa6dc2715b07497a2a7c4bc7"
20+
OVERRIDE_NIXPKGS="--override-input nixpkgs ${NIXPKGS_URL}"
21+
OVERRIDE_FLAKE_PARTS="--override-input flake-parts github:hercules-ci/flake-parts/7c7a8bce3dffe71203dcd4276504d1cb49dfe05f"
22+
23+
OVERRIDE_ALL="${OVERRIDE_HASKELL_FLAKE} ${OVERRIDE_FLAKE_PARTS} ${OVERRIDE_NIXPKGS}"
1824

1925
currentver="$(nix eval --raw --expr builtins.nixVersion)"
2026
requiredver="2.14.1"

test/hpack/flake.nix

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
# Since there is no flake.lock file (to avoid incongruent haskell-flake
3+
# pinning), we must specify revisions for *all* inputs to ensure
4+
# reproducibility.
5+
inputs = {
6+
nixpkgs = { };
7+
flake-parts = { };
8+
haskell-flake = { };
9+
};
10+
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
11+
flake-parts.lib.mkFlake { inherit inputs; } {
12+
systems = nixpkgs.lib.systems.flakeExposed;
13+
imports = [
14+
inputs.haskell-flake.flakeModule
15+
];
16+
perSystem = { self', pkgs, ... }: {
17+
haskellProjects.default = { };
18+
# haskell-flake doesn't set the default package, but you can do it here.
19+
packages.default = self'.packages.haskell-flake-test;
20+
};
21+
};
22+
}

test/hpack/package.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: haskell-flake-test
2+
version: 0.1.0.0
3+
license: NONE
4+
author: Joe
5+
maintainer: [email protected]
6+
7+
ghc-options:
8+
- -Wall
9+
10+
default-language: Haskell2010
11+
12+
executables:
13+
haskell-flake-test:
14+
main: Main.hs
15+
dependencies:
16+
- base
17+
source-dirs: src

test/hpack/script

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Toml.Type.Value (Value(Bool))
2+
3+
main :: IO ()
4+
main = do
5+
putStrLn ("I depend on the `tomland` package. Here's a TOML-flavored boolean: " <> show (Bool True))

test/hpack/src/Main.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Main where
2+
3+
main :: IO ()
4+
main = do
5+
putStrLn "Hello world, from hpack test"

test/hpack/test.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source ../common.sh
2+
set -euxo pipefail
3+
4+
# First, build the flake
5+
logHeader "Testing nix build"
6+
nix build ${OVERRIDE_ALL}
7+
# Run the devshell test script in a nix develop shell.
8+
logHeader "Testing nix devshell"
9+
nix develop ${OVERRIDE_ALL} -c echo

test/simple/flake.nix

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@
33
# pinning), we must specify revisions for *all* inputs to ensure
44
# reproducibility.
55
inputs = {
6-
nixpkgs.url = "github:nixos/nixpkgs/bb31220cca6d044baa6dc2715b07497a2a7c4bc7";
7-
flake-parts.url = "github:hercules-ci/flake-parts/7c7a8bce3dffe71203dcd4276504d1cb49dfe05f";
6+
nixpkgs = { };
7+
flake-parts = { };
8+
haskell-flake = { };
9+
810
check-flake.url = "github:srid/check-flake/48a17393ed4fcd523399d6602c283775b5127295";
911

1012
haskell-multi-nix.url = "github:srid/haskell-multi-nix/7aed736571714ec12105ec110358998d70d59e34";
1113
haskell-multi-nix.flake = false;
12-
13-
# We do not specify a value for this input, because it is explicitly
14-
# specified using --override-input to point to ../. For example,
15-
# `nix build --override-input haskell-flake ..`
16-
haskell-flake = { };
1714
};
1815
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
1916
flake-parts.lib.mkFlake { inherit inputs; } {

0 commit comments

Comments
 (0)