Repository navigation
Expand file tree
/
Copy pathRunfile
More file actions
115 lines (98 loc) · 3.94 KB
/
Copy pathRunfile
File metadata and controls
115 lines (98 loc) · 3.94 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
.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-benchmarks
./local/codd-benchmarks/bin/codd-benchmarks
else
cabal run -O2 codd-benchmarks
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
concurrently -g --timings --names pg18,pg17,pg16,pg15,pg14 \
'run test-with-db --nix --pg 18' \
'run test-with-db --nix --pg 17' \
'run test-with-db --nix --pg 16' \
'run test-with-db --nix --pg 15' \
'run test-with-db --nix --pg 14'
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-tests
`cabal list-bin -O0 codd-tests` "${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=(18)
[ "${PG[0]}" = "all" ] && PG=(14 15 16 17 18)
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-tests
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-tests
nix-shell -A "shellPg18" ./default.nix --run "./scripts/run-tests-system-resources.sh"
fi