-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRunfile
More file actions
117 lines (100 loc) · 4.15 KB
/
Runfile
File metadata and controls
117 lines (100 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
.SHELL = bash
##
# Runs benchmarks.
# OPTION NIX --nix Use a Nix-built test executable instead of compiling with cabal in the user's shell.
benchmarks:
set -eo pipefail
if [ -n "$NIX" ]; then
nix-build -A coddbenchmarks -o local/codd-bench
./local/codd-bench/bin/codd-bench
else
cabal run -O2 codd-bench
fi
##
# Runs all tests that CI runs, exactly like CI runs them.
ci-tests:
set -eo pipefail
echo "Testing install script posix compatibility"
shellcheck --shell=sh nix/install-codd.sh
echo "Running tests that don't depend on a database"
run test-no-db --nix
# Postgres-version dependent tests for each possible version next
# We test the last version with the vanilla nixpkgs-built derivation,
# not the IOHK one. We assume differences in the codebase regarding different
# postgres versions aren't enough to make it worth testing every version here too.
concurrently -g --timings --names pg16Nixpkgs,pg15,pg14,pg13 \
'nix-build ./nix/install-codd-nixpkgs.nix --no-out-link -A coddWithCheck' \
'run test-with-db --nix --pg 15' \
'run test-with-db --nix --pg 14' \
'run test-with-db --nix --pg 13'
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Running system-resources test"
run test-system-resources --nix
else
echo "Skipping system-resources test as strace is only available on Linux"
fi
##
# Formats all Haskell files with fourmolu.
format-hs:
set -eo pipefail
readarray -d '' FILES < <(git ls-files -z '*.hs')
for f in "${FILES[@]}"; do
if [ "$f" = "src/Codd/Internal.hs" ]; then
echo "Skipping \"$f\" because of some fourmolu bug"
else
echo "Formatting $f..."
fourmolu --mode inplace "$f"
fi
done
##
# Runs a test without starting a postgresql DB for it. If no extra arguments are passed, special cases to running
# all tests that don't require a database.
# OPTION NIX --nix Run tests in a Nix derivation's sandbox
test-no-db:
set -eo pipefail
ARGSARRAY=("$@")
[ -z "$1" ] && ARGSARRAY=(--skip /DbDependentSpecs/ --skip /SystemResourcesSpecs/)
TARGS=$(printf "'%s' " "$@") && [ -z "$1" ] && TARGS="--skip /DbDependentSpecs/ --skip /SystemResourcesSpecs/"
if [ -n "$NIX" ]; then
nix-build --no-out-link -A testsNoDb --argstr hspecArgs "$TARGS"
else
cabal build -O0 codd-test
`cabal list-bin -O0 codd-test` "${ARGSARRAY[@]}"
fi
##
# Runs a test in an environment where there is a postgresql DB listening. If no extra arguments are passed, special cases to running
# all tests that _do_ require a database.
# OPTION PG --pg <pg> The version of the postgresql instance to start or 'all'. Defaults to 16 if unspecified.
# OPTION NIX --nix Run tests in a Nix derivation's sandbox
test-with-db:
set -eo pipefail
[ -z "$PG" ] && PG=(16)
[ "${PG[0]}" = "all" ] && PG=(13 14 15 16)
TARGS="--match '/DbDependentSpecs/'" && [ -n "$1" ] && TARGS=$(printf "'%s' " "${@}")
for pg in "${PG[@]}"; do
echo "Running tests on Postgres $pg"
if [ -n "$NIX" ]; then
nix-build --no-out-link -A "testsPg${pg}" --argstr hspecArgs "$TARGS"
else
cabal build -O0 codd-test
nix-shell -A "shellPg${pg}" ./default.nix --run "./scripts/run-tests-db-internal.sh $TARGS"
fi
done
##
# Test that codd does not open more than one migration file or on-disk representation file simultaneously, so that it won't fail in shells or OS's with tight open file limits.
# OPTION NIX --nix Run tests in a Nix derivation's sandbox
test-system-resources:
set -eo pipefail
if [ -n "$NIX" ]; then
nix-build --no-out-link -A testsSystemResources
else
if ! command -v strace &> /dev/null
then
echo strace could not be found. You need strace installed for this test.
exit 1
fi
rm -f /tmp/strace-codd-system-resources-test.log
trap "rm -f /tmp/strace-codd-system-resources-test.log" ERR EXIT
cabal build -O0 codd-test
nix-shell -A "shellPg16" ./default.nix --run "./scripts/run-tests-system-resources.sh"
fi