@@ -0,0 +1,39 @@
1+#! /usr/bin/env nix-shell
2+#! nix-shell -i bash -p bash jq nix
3+
4+set -euo pipefail
5+
6+NIX_BUILD_ARGS="${NIX_BUILD_ARGS:-}"
7+
8+cd $(dirname $0)
9+
10+printf "*** Running the nix-build tests...\n" >& 2
11+nix-build $NIX_BUILD_ARGS --no-out-link --keep-going ./default.nix
12+echo >& 2
13+
14+printf "*** Running the unit tests... " >& 2
15+res=$(nix-instantiate --eval --json --strict ./default.nix -A unit)
16+num_failed=$(jq length <<< "$res")
17+if [ $num_failed -eq 0 ]; then
18+ printf "PASSED\n" >& 2
19+else
20+ printf "$num_failed FAILED\n" >& 2
21+ jq . <<< "$res"
22+ exit 1
23+fi
24+
25+printf "*** Checking that a nix-shell works for runghc...\n" >& 2
26+nix-shell $NIX_BUILD_ARGS \
27+ --pure ./default.nix \
28+ -A with-packages.test-shell \
29+ --run 'runghc with-packages/Point.hs'
30+echo >& 2
31+
32+printf "*** Checking that a nix-shell works for cabal...\n" >& 2
33+nix-shell $NIX_BUILD_ARGS \
34+ --pure ./default.nix \
35+ -A with-packages.test-shell \
36+ --run 'echo CABAL_CONFIG=$CABAL_CONFIG && type -p ghc && cd with-packages && rm -rf dist-newstyle .ghc-environment* && cabal new-build'
37+echo >& 2
38+
39+printf "\n*** Finished successfully\n" >& 2