diff --git a/default.nix b/default.nix index 7c5ac22d6..58be30fdc 100644 --- a/default.nix +++ b/default.nix @@ -112,10 +112,13 @@ rec { nixpkgsUpgrade = pkgs.callPackage nix/nixpkgs-upgrade.nix { }; + withTmpDb = + pkgs.callPackage nix/withtmpdb.nix { }; + # Scripts for running tests. tests = pkgs.callPackage nix/tests.nix { - inherit postgrest postgrestProfiled postgresqlVersions devCabalOptions; + inherit postgrest postgrestProfiled postgresqlVersions devCabalOptions withTmpDb; ghc = pkgs.haskell.compiler."${compiler}"; hpc-codecov = pkgs.haskell.packages."${compiler}".hpc-codecov; }; diff --git a/nix/tests.nix b/nix/tests.nix index 078b29459..050712290 100644 --- a/nix/tests.nix +++ b/nix/tests.nix @@ -17,29 +17,10 @@ , postgrestProfiled , python3 , runtimeShell +, withTmpDb , yq }: let - # Wrap the `test/with_tmp_db` script with the required dependencies from Nix. - withTmpDb = - postgresql: - checkedShellScript - { - name = "postgrest-test-withtmpdb-${postgresql.name}"; - docs = "Run the given command in a temporary database"; - inRootDir = true; - } - '' - # avoid starting multiple layers of with_tmp_db - if test ! -v PGRST_DB_URI; then - export PATH=${postgresql}/bin:"$PATH" - - exec test/with_tmp_db "$@" - else - "$@" - fi - ''; - # Create a `withPostgresql` for each PostgreSQL version that we want to test # against. withPostgresqlVersions = diff --git a/nix/withtmpdb.nix b/nix/withtmpdb.nix new file mode 100644 index 000000000..7d5363e64 --- /dev/null +++ b/nix/withtmpdb.nix @@ -0,0 +1,20 @@ +# Wrap the `test/with_tmp_db` script with the required dependencies from Nix. +{ checkedShellScript }: + +postgresql: +checkedShellScript +{ + name = "postgrest-test-withtmpdb-${postgresql.name}"; + docs = "Run the given command in a temporary database"; + inRootDir = true; +} + '' + # avoid starting multiple layers of with_tmp_db + if test ! -v PGRST_DB_URI; then + export PATH=${postgresql}/bin:"$PATH" + + exec test/with_tmp_db "$@" + else + "$@" + fi + ''