2019-01-30 08:36:08 +03:00
|
|
|
#! /usr/bin/env nix-shell
|
2019-11-01 13:08:31 +03:00
|
|
|
#! nix-shell -i bash -p bash jq nix gnused
|
2019-01-30 08:36:08 +03:00
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
2022-06-23 03:39:35 +03:00
|
|
|
# check if Nix has the `ca-derivations` experimental features (code 0) is enabled
|
|
|
|
NIX_CA_DERIVATIONS=$(jq -e '."experimental-features".value|any(. == 0)' <<< $(nix show-config --json)) || true
|
2019-01-30 08:36:08 +03:00
|
|
|
NIX_BUILD_ARGS="${NIX_BUILD_ARGS:-}"
|
|
|
|
|
|
|
|
cd $(dirname $0)
|
|
|
|
|
2020-07-08 13:54:01 +03:00
|
|
|
if [ "$#" != "1" ]; then
|
2020-07-21 05:10:23 +03:00
|
|
|
echo "Please pass a compiler-nix-name to use. For example: ./test/test.sh ghc884"
|
2020-07-08 13:54:01 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
GHC=$1
|
|
|
|
|
2019-02-12 02:30:42 +03:00
|
|
|
printf "*** Cleaning package build directories..." >& 2
|
|
|
|
rm -rvf */cabal.project.local */.ghc.environment* */dist */dist-newstyle */.stack-work
|
|
|
|
echo >& 2
|
|
|
|
|
2019-01-30 08:36:08 +03:00
|
|
|
printf "*** Running the nix-build tests...\n" >& 2
|
2019-07-13 17:13:15 +03:00
|
|
|
nix build $NIX_BUILD_ARGS \
|
|
|
|
-I . -I .. \
|
|
|
|
--option restrict-eval true \
|
|
|
|
--option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" \
|
2020-07-08 13:54:01 +03:00
|
|
|
--no-link --keep-going -f default.nix \
|
2022-06-23 03:39:35 +03:00
|
|
|
--argstr compiler-nix-name $GHC \
|
|
|
|
--arg CADerivationsEnabled $NIX_CA_DERIVATIONS
|
2019-01-30 08:36:08 +03:00
|
|
|
echo >& 2
|
|
|
|
|
|
|
|
printf "*** Running the unit tests... " >& 2
|
2020-07-08 13:54:01 +03:00
|
|
|
res=$(nix-instantiate --eval --json --strict ./default.nix --argstr compiler-nix-name $GHC -A unit.tests)
|
2019-01-30 08:36:08 +03:00
|
|
|
num_failed=$(jq length <<< "$res")
|
|
|
|
if [ $num_failed -eq 0 ]; then
|
|
|
|
printf "PASSED\n" >& 2
|
|
|
|
else
|
|
|
|
printf "$num_failed FAILED\n" >& 2
|
|
|
|
jq . <<< "$res"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
printf "*** Checking that a nix-shell works for runghc...\n" >& 2
|
2021-08-17 15:44:03 +03:00
|
|
|
# This has to use ghc865 for now
|
2019-01-30 08:36:08 +03:00
|
|
|
nix-shell $NIX_BUILD_ARGS \
|
|
|
|
--pure ./default.nix \
|
2021-08-17 15:44:03 +03:00
|
|
|
--argstr compiler-nix-name ghc865 \
|
2019-01-30 08:36:08 +03:00
|
|
|
-A with-packages.test-shell \
|
|
|
|
--run 'runghc with-packages/Point.hs'
|
|
|
|
echo >& 2
|
|
|
|
|
|
|
|
printf "*** Checking that a nix-shell works for cabal...\n" >& 2
|
2021-08-17 15:44:03 +03:00
|
|
|
# This has to use ghc865 for now
|
2019-01-30 08:36:08 +03:00
|
|
|
nix-shell $NIX_BUILD_ARGS \
|
|
|
|
--pure ./default.nix \
|
2021-08-17 15:44:03 +03:00
|
|
|
--argstr compiler-nix-name ghc865 \
|
2019-01-30 08:36:08 +03:00
|
|
|
-A with-packages.test-shell \
|
2019-02-12 02:30:42 +03:00
|
|
|
--run 'echo CABAL_CONFIG=$CABAL_CONFIG && type -p ghc && cd with-packages && cabal new-build'
|
2019-01-30 08:36:08 +03:00
|
|
|
echo >& 2
|
|
|
|
|
2019-01-31 05:40:55 +03:00
|
|
|
printf "*** Checking that a nix-shell works for cabal (doExactConfig component)...\n" >& 2
|
2021-08-17 15:44:03 +03:00
|
|
|
# This has to use ghc865 for now
|
2019-01-31 05:40:55 +03:00
|
|
|
nix-shell $NIX_BUILD_ARGS \
|
|
|
|
--pure ./default.nix \
|
2021-08-17 15:44:03 +03:00
|
|
|
--argstr compiler-nix-name ghc865 \
|
2019-01-31 05:40:55 +03:00
|
|
|
-A with-packages.test-shell-dec \
|
2019-02-12 02:30:42 +03:00
|
|
|
--run 'echo CABAL_CONFIG=$CABAL_CONFIG && echo GHC_ENVIRONMENT=$GHC_ENVIRONMENT && cd with-packages && cabal new-build'
|
2019-01-31 05:40:55 +03:00
|
|
|
echo >& 2
|
|
|
|
|
2019-10-01 05:01:49 +03:00
|
|
|
printf "*** Checking that a nix-shell works for a project with test-suite build-tools and benchmarks...\n" >& 2
|
|
|
|
printf "!!! This is expected to fail until https://github.com/input-output-hk/haskell.nix/issues/231 is resolved! \n" >& 2
|
|
|
|
nix-shell $NIX_BUILD_ARGS \
|
|
|
|
--pure ./default.nix \
|
2020-07-08 13:54:01 +03:00
|
|
|
--argstr compiler-nix-name $GHC \
|
2019-10-01 05:01:49 +03:00
|
|
|
-A cabal-22.shell \
|
|
|
|
--run 'cd cabal-22 && cabal new-build all --enable-tests --enable-benchmarks' \
|
|
|
|
|| true
|
|
|
|
echo >& 2
|
|
|
|
|
2019-02-04 06:49:11 +03:00
|
|
|
printf "*** Checking that a nix-shell works for a multi-target project...\n" >& 2
|
|
|
|
nix-shell $NIX_BUILD_ARGS \
|
|
|
|
--pure ./default.nix \
|
2020-07-08 13:54:01 +03:00
|
|
|
--argstr compiler-nix-name $GHC \
|
2019-02-04 06:49:11 +03:00
|
|
|
-A cabal-simple.test-shell \
|
2019-02-12 02:30:42 +03:00
|
|
|
--run 'cd cabal-simple && cabal new-build'
|
2019-02-04 06:49:11 +03:00
|
|
|
echo >& 2
|
|
|
|
|
2019-05-30 23:46:39 +03:00
|
|
|
printf "*** Checking shellFor works for a cabal project, multiple packages...\n" >& 2
|
2019-05-12 14:57:22 +03:00
|
|
|
nix-shell $NIX_BUILD_ARGS \
|
|
|
|
--pure ./default.nix \
|
2020-07-08 13:54:01 +03:00
|
|
|
--argstr compiler-nix-name $GHC \
|
2019-05-12 14:57:22 +03:00
|
|
|
-A shell-for.env \
|
|
|
|
--run 'cd shell-for && cabal new-build all'
|
|
|
|
echo >& 2
|
|
|
|
|
2019-05-30 23:46:39 +03:00
|
|
|
printf "*** Checking shellFor works for a cabal project, single package...\n" >& 2
|
|
|
|
nix-shell $NIX_BUILD_ARGS \
|
|
|
|
--pure ./default.nix \
|
2020-07-08 13:54:01 +03:00
|
|
|
--argstr compiler-nix-name $GHC \
|
2019-05-30 23:46:39 +03:00
|
|
|
-A shell-for.envPkga \
|
|
|
|
--run 'cd shell-for && cabal new-build --project=single.project all'
|
|
|
|
echo >& 2
|
|
|
|
|
2019-05-26 09:55:10 +03:00
|
|
|
printf "*** Checking shellFor has a working hoogle index...\n" >& 2
|
|
|
|
nix-shell $NIX_BUILD_ARGS \
|
|
|
|
--pure ./default.nix \
|
2020-07-08 13:54:01 +03:00
|
|
|
--argstr compiler-nix-name $GHC \
|
2019-05-26 09:55:10 +03:00
|
|
|
-A shell-for.env \
|
|
|
|
--run 'hoogle ConduitT | grep Data.Conduit'
|
|
|
|
echo >& 2
|
|
|
|
|
2019-11-01 13:08:31 +03:00
|
|
|
printf "*** Checking shellFor does not depend on given packages...\n" >& 2
|
2020-07-08 13:54:01 +03:00
|
|
|
drva=$(nix-instantiate ./default.nix --argstr compiler-nix-name $GHC -A shell-for.env)
|
2019-11-01 13:08:31 +03:00
|
|
|
echo "-- hello" >> shell-for/pkga/PkgA.hs
|
2020-07-08 13:54:01 +03:00
|
|
|
drvb=$(nix-instantiate ./default.nix --argstr compiler-nix-name $GHC -A shell-for.env)
|
2019-11-01 13:08:31 +03:00
|
|
|
sed -i -e '/-- hello/d' shell-for/pkga/PkgA.hs
|
|
|
|
if [ "$drva" != "$drvb" ]; then
|
|
|
|
printf "FAIL\nShell derivations\n$drva\n$drvb\n are not identical.\n" >& 2
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
printf "PASS\n" >& 2
|
|
|
|
fi
|
|
|
|
|
2019-06-15 08:16:52 +03:00
|
|
|
printf "*** Checking the maintainer scripts...\n" >& 2
|
2020-07-08 13:54:01 +03:00
|
|
|
nix build $NIX_BUILD_ARGS --no-link --keep-going -f ../build.nix --argstr compiler-nix-name $GHC maintainer-scripts
|
2019-06-15 08:16:52 +03:00
|
|
|
echo >& 2
|
|
|
|
|
2020-05-02 13:16:34 +03:00
|
|
|
printf "*** Checking that plan construction works with extra Hackages...\n" >& 2
|
|
|
|
nix build $NIX_BUILD_ARGS --no-link \
|
2020-07-08 13:54:01 +03:00
|
|
|
-f ./default.nix --argstr compiler-nix-name $GHC \
|
|
|
|
extra-hackage.run.project.plan-nix
|
2020-05-02 13:16:34 +03:00
|
|
|
echo >& 2
|
|
|
|
|
|
|
|
printf "*** Checking that package with extra Hackages can be build...\n" >& 2
|
|
|
|
nix build $NIX_BUILD_ARGS --no-link \
|
2020-07-08 13:54:01 +03:00
|
|
|
-f ./default.nix --argstr compiler-nix-name $GHC \
|
2020-07-21 07:06:54 +03:00
|
|
|
extra-hackage.run.project.hsPkgs.external-package-user.components.exes.external-package-user
|
2020-05-02 13:16:34 +03:00
|
|
|
echo >& 2
|
|
|
|
|
2019-01-30 08:36:08 +03:00
|
|
|
printf "\n*** Finished successfully\n" >& 2
|