summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/hooks/postgresql-test-hook.section.md6
-rw-r--r--pkgs/build-support/setup-hooks/postgresql-test-hook/postgresql-test-hook.sh2
-rw-r--r--pkgs/build-support/setup-hooks/postgresql-test-hook/test.nix5
3 files changed, 12 insertions, 1 deletions
diff --git a/doc/hooks/postgresql-test-hook.section.md b/doc/hooks/postgresql-test-hook.section.md
index c53d841883e5..8b37ca1e4b3e 100644
--- a/doc/hooks/postgresql-test-hook.section.md
+++ b/doc/hooks/postgresql-test-hook.section.md
@@ -46,6 +46,12 @@ Bash-only variables:
- `postgresqlEnableTCP`: set to `1` to enable TCP listening. Flaky; not recommended.
- `postgresqlStartCommands`: defaults to `pg_ctl start`.
+## Hooks {#sec-postgresqlTestHook-hooks}
+
+A number of additional hooks are ran in postgresqlTestHook
+
+ - `postgresqlTestSetupPost`: ran after postgresql has been set up.
+
## TCP and the Nix sandbox {#sec-postgresqlTestHook-tcp}
`postgresqlEnableTCP` relies on network sandboxing, which is not available on macOS and some custom Nix installations, resulting in flaky tests.
diff --git a/pkgs/build-support/setup-hooks/postgresql-test-hook/postgresql-test-hook.sh b/pkgs/build-support/setup-hooks/postgresql-test-hook/postgresql-test-hook.sh
index cfc9bd2f83d6..8131304cccf9 100644
--- a/pkgs/build-support/setup-hooks/postgresql-test-hook/postgresql-test-hook.sh
+++ b/pkgs/build-support/setup-hooks/postgresql-test-hook/postgresql-test-hook.sh
@@ -71,6 +71,8 @@ EOF
header 'setting up postgresql'
eval "$postgresqlTestSetupCommands"
+ runHook postgresqlTestSetupPost
+
}
postgresqlStop() {
diff --git a/pkgs/build-support/setup-hooks/postgresql-test-hook/test.nix b/pkgs/build-support/setup-hooks/postgresql-test-hook/test.nix
index adb65fca7ca6..9881ed1016cc 100644
--- a/pkgs/build-support/setup-hooks/postgresql-test-hook/test.nix
+++ b/pkgs/build-support/setup-hooks/postgresql-test-hook/test.nix
@@ -14,6 +14,9 @@ stdenv.mkDerivation {
INSERT INTO hello VALUES ('it '||'worked');
SELECT * FROM hello;
'';
+ postgresqlTestSetupPost = ''
+ TEST_POST_HOOK_RAN=1
+ '';
checkPhase = ''
runHook preCheck
psql <$sqlPath | grep 'it worked'
@@ -21,7 +24,7 @@ stdenv.mkDerivation {
runHook postCheck
'';
installPhase = ''
- [[ $TEST_RAN == 1 ]]
+ [[ $TEST_RAN == 1 && $TEST_POST_HOOK_RAN == 1 ]]
touch $out
'';
}