Skip to content

Commit a8adc34

Browse files
committed
tests: add shell script which runs all tests
1 parent ce0f5e0 commit a8adc34

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,4 @@ before_script:
1919
script:
2020
- 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='
2121
- cachix use nix-tools
22-
- nix-build
23-
-I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/${CHANNEL}.tar.gz
24-
test/default.nix
25-
--cores 0
26-
-j2
22+
- NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/${CHANNEL}.tar.gz NIX_BUILD_ARGS="--cores 0 --max-jobs 2" ./test/tests.sh

test/tests.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)