postgresqlTestHook: shutdown on failure

Previously, the user of postgresqlTestHook would have needed to set
failureHook accordingly. However, this was not a clean solution, because
postgresqlStop would also run for configure or build failures, before
the server was even started. This gave odd errors from a failed shutdown
in the log.

Now postgresqlStop is only called when it makes sense - and whenever
postgresqlTestHook is used.

+4 -5
+4 -2
pkgs/by-name/po/postgresqlTestHook/postgresql-test-hook.sh
··· 1 - preCheckHooks+=('postgresqlStart') 2 - postCheckHooks+=('postgresqlStop') 1 + preCheckHooks+=(postgresqlStart) 2 + postCheckHooks+=(postgresqlStop) 3 3 4 4 5 5 postgresqlStart() { ··· 69 69 70 70 echo 'starting postgresql' 71 71 eval "${postgresqlStartCommands:-pg_ctl start}" 72 + failureHooks+=(postgresqlStop) 72 73 73 74 echo 'setting up postgresql' 74 75 eval "$postgresqlTestSetupCommands" ··· 80 81 postgresqlStop() { 81 82 echo 'stopping postgresql' 82 83 pg_ctl stop 84 + failureHooks=("${failureHooks[@]/postgresqlStop}") 83 85 }
-1
pkgs/servers/sql/postgresql/ext/pgtap.nix
··· 45 45 SELECT * FROM finish(); 46 46 ROLLBACK; 47 47 ''; 48 - failureHook = "postgresqlStop"; 49 48 checkPhase = '' 50 49 runHook preCheck 51 50 psql -a -v ON_ERROR_STOP=1 -f $sqlPath
-1
pkgs/servers/sql/postgresql/ext/postgis.nix
··· 92 92 ]; 93 93 94 94 postgresqlTestUserOptions = "LOGIN SUPERUSER"; 95 - failureHook = "postgresqlStop"; 96 95 97 96 # postgis config directory assumes /include /lib from the same root for json-c library 98 97 env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib";
-1
pkgs/servers/sql/postgresql/postgresqlTestExtension.nix
··· 21 21 postgresqlTestHook 22 22 (postgresql.withPackages (ps: [ finalPackage ] ++ (map (p: ps."${p}") withPackages))) 23 23 ]; 24 - failureHook = "postgresqlStop"; 25 24 postgresqlTestUserOptions = "LOGIN SUPERUSER"; 26 25 passAsFile = [ "sql" ]; 27 26 sql =