postgresqlTestHook: run postgresqlTestSetupPost hook after setting up

Nick Cao 0ea2d480 a5088fdb

+12 -1
+6
doc/hooks/postgresql-test-hook.section.md
··· 46 - `postgresqlEnableTCP`: set to `1` to enable TCP listening. Flaky; not recommended. 47 - `postgresqlStartCommands`: defaults to `pg_ctl start`. 48 49 ## TCP and the Nix sandbox {#sec-postgresqlTestHook-tcp} 50 51 `postgresqlEnableTCP` relies on network sandboxing, which is not available on macOS and some custom Nix installations, resulting in flaky tests.
··· 46 - `postgresqlEnableTCP`: set to `1` to enable TCP listening. Flaky; not recommended. 47 - `postgresqlStartCommands`: defaults to `pg_ctl start`. 48 49 + ## Hooks {#sec-postgresqlTestHook-hooks} 50 + 51 + A number of additional hooks are ran in postgresqlTestHook 52 + 53 + - `postgresqlTestSetupPost`: ran after postgresql has been set up. 54 + 55 ## TCP and the Nix sandbox {#sec-postgresqlTestHook-tcp} 56 57 `postgresqlEnableTCP` relies on network sandboxing, which is not available on macOS and some custom Nix installations, resulting in flaky tests.
+2
pkgs/build-support/setup-hooks/postgresql-test-hook/postgresql-test-hook.sh
··· 71 header 'setting up postgresql' 72 eval "$postgresqlTestSetupCommands" 73 74 } 75 76 postgresqlStop() {
··· 71 header 'setting up postgresql' 72 eval "$postgresqlTestSetupCommands" 73 74 + runHook postgresqlTestSetupPost 75 + 76 } 77 78 postgresqlStop() {
+4 -1
pkgs/build-support/setup-hooks/postgresql-test-hook/test.nix
··· 14 INSERT INTO hello VALUES ('it '||'worked'); 15 SELECT * FROM hello; 16 ''; 17 checkPhase = '' 18 runHook preCheck 19 psql <$sqlPath | grep 'it worked' ··· 21 runHook postCheck 22 ''; 23 installPhase = '' 24 - [[ $TEST_RAN == 1 ]] 25 touch $out 26 ''; 27 }
··· 14 INSERT INTO hello VALUES ('it '||'worked'); 15 SELECT * FROM hello; 16 ''; 17 + postgresqlTestSetupPost = '' 18 + TEST_POST_HOOK_RAN=1 19 + ''; 20 checkPhase = '' 21 runHook preCheck 22 psql <$sqlPath | grep 'it worked' ··· 24 runHook postCheck 25 ''; 26 installPhase = '' 27 + [[ $TEST_RAN == 1 && $TEST_POST_HOOK_RAN == 1 ]] 28 touch $out 29 ''; 30 }