Unverified Commit 065fefd9 authored by Wolfgang Walther's avatar Wolfgang Walther
Browse files

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.
parent 1cf2d608
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
preCheckHooks+=('postgresqlStart')
postCheckHooks+=('postgresqlStop')
preCheckHooks+=(postgresqlStart)
postCheckHooks+=(postgresqlStop)


postgresqlStart() {
@@ -69,6 +69,7 @@ EOF

  echo 'starting postgresql'
  eval "${postgresqlStartCommands:-pg_ctl start}"
  failureHooks+=(postgresqlStop)

  echo 'setting up postgresql'
  eval "$postgresqlTestSetupCommands"
@@ -80,4 +81,5 @@ EOF
postgresqlStop() {
  echo 'stopping postgresql'
  pg_ctl stop
  failureHooks=("${failureHooks[@]/postgresqlStop}")
}
+0 −1
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ postgresqlBuildExtension (finalAttrs: {
      SELECT * FROM finish();
      ROLLBACK;
    '';
    failureHook = "postgresqlStop";
    checkPhase = ''
      runHook preCheck
      psql -a -v ON_ERROR_STOP=1 -f $sqlPath
+0 −1
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@ postgresqlBuildExtension (finalAttrs: {
  ];

  postgresqlTestUserOptions = "LOGIN SUPERUSER";
  failureHook = "postgresqlStop";

  # postgis config directory assumes /include /lib from the same root for json-c library
  env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib";
+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ stdenvNoCC.mkDerivation (
      postgresqlTestHook
      (postgresql.withPackages (ps: [ finalPackage ] ++ (map (p: ps."${p}") withPackages)))
    ];
    failureHook = "postgresqlStop";
    postgresqlTestUserOptions = "LOGIN SUPERUSER";
    passAsFile = [ "sql" ];
    sql =