Nixify io and memory tests (#1538)

* Include tests for io and memory in the Nix environment.
* include spec tests in nix-shell by default
* install the io and memory tests in CI
This commit is contained in:
Remo Rechkemmer
2020-05-28 12:45:14 -05:00
committed by GitHub
parent 784ebe57d7
commit 69b09e312a
18 changed files with 211 additions and 108 deletions
+49 -6
View File
@@ -2,11 +2,16 @@
{ buildEnv
, cabal-install
, curl
, git
, haskell
, lib
, postgrestBuildEnv
, ncat
, postgresql
, postgresqlVersions
, postgrest
, postgrestStatic
, postgrestProfiled
, runtimeShell
, writeShellScript
, writeShellScriptBin
@@ -33,7 +38,7 @@ let
''
set -euo pipefail
export PATH="$(cat ${postgrestBuildEnv})"/bin:"$PATH"
export PATH="$(cat ${postgrest.env})"/bin:"$PATH"
cat << EOF
@@ -51,9 +56,6 @@ let
EOF
'';
defaultTestSpec =
testSpec "postgrest-test-spec" postgresql;
# Create a `testSpec` for each PostgreSQL version that we want to test
# against.
testSpecVersions =
@@ -73,6 +75,36 @@ let
${lib.concatStringsSep "\n" testRunners}
'';
testIO =
name: postgresql:
writeShellScriptBin
name
''
set -euo pipefail
rootdir="$(${git}/bin/git rev-parse --show-toplevel)"
cd "$rootdir"
export PATH="${postgrestStatic}/bin:${curl}/bin:${ncat}/bin:$PATH"
${withTmpDb postgresql} "$rootdir"/test/io-tests.sh
'';
testMemory =
name: postgresql:
writeShellScriptBin
name
''
set -euo pipefail
rootdir="$(${git}/bin/git rev-parse --show-toplevel)"
cd "$rootdir"
export PATH="${postgrestProfiled}/bin:${curl}/bin:$PATH"
${withTmpDb postgresql} "$rootdir/test/memory-tests.sh"
'';
in
# Create an environment that contains all the utility scripts for running tests
# that we defined above.
@@ -82,7 +114,18 @@ buildEnv {
paths =
[
defaultTestSpec
(testSpec "postgrest-test-spec" postgresql)
testSpecAllVersions
] ++ testSpecVersions;
}
# The IO an memory tests have large dependencies (a static and a profiled
# build of PostgREST respectively) and are run less often than the spec
# tests, so we don't include them in the default test environment. We make
# them available through separate attributes:
// {
ioTests =
(testIO "postgrest-test-io" postgresql);
memoryTests =
(testMemory "postgrest-test-memory" postgresql);
}