Skip to content

Commit

Permalink
tests: add shell script which runs all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Jan 30, 2019
1 parent ce0f5e0 commit a8adc34
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,4 @@ before_script:
script:
- nix-env -if https://github.com/cachix/cachix/tarball/master --extra-substituters https://cachix.cachix.org --trusted-public-keys 'cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= cachix.cachix.org-1:eWNHQldwUO7G2VkjpnjDbWwy4KQ/HNxht7H4SSoMckM='
- cachix use nix-tools
- nix-build
-I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/${CHANNEL}.tar.gz
test/default.nix
--cores 0
-j2
- NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/${CHANNEL}.tar.gz NIX_BUILD_ARGS="--cores 0 --max-jobs 2" ./test/tests.sh
39 changes: 39 additions & 0 deletions test/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash jq nix

set -euo pipefail

NIX_BUILD_ARGS="${NIX_BUILD_ARGS:-}"

cd $(dirname $0)

printf "*** Running the nix-build tests...\n" >& 2
nix-build $NIX_BUILD_ARGS --no-out-link --keep-going ./default.nix
echo >& 2

printf "*** Running the unit tests... " >& 2
res=$(nix-instantiate --eval --json --strict ./default.nix -A unit)
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
nix-shell $NIX_BUILD_ARGS \
--pure ./default.nix \
-A with-packages.test-shell \
--run 'runghc with-packages/Point.hs'
echo >& 2

printf "*** Checking that a nix-shell works for cabal...\n" >& 2
nix-shell $NIX_BUILD_ARGS \
--pure ./default.nix \
-A with-packages.test-shell \
--run 'echo CABAL_CONFIG=$CABAL_CONFIG && type -p ghc && cd with-packages && rm -rf dist-newstyle .ghc-environment* && cabal new-build'
echo >& 2

printf "\n*** Finished successfully\n" >& 2

0 comments on commit a8adc34

Please sign in to comment.