nix(refactor): Split memoryTest from tests.nix into memory.nix

This commit is contained in:
Wolfgang Walther
2021-04-18 13:51:39 +02:00
committed by Wolfgang Walther
parent e199337a53
commit 2e73886adc
5 changed files with 39 additions and 27 deletions
+1 -1
View File
@@ -172,7 +172,7 @@ jobs:
cachix use postgrest cachix use postgrest
- run: - run:
name: Install testing scripts name: Install testing scripts
command: nix-env -f default.nix -iA tests tests.memoryTests withTools command: nix-env -f default.nix -iA tests memory withTools
- run: - run:
name: Run coverage (io tests and spec tests against PostgreSQL 13) name: Run coverage (io tests and spec tests against PostgreSQL 13)
command: postgrest-coverage command: postgrest-coverage
+5 -1
View File
@@ -118,11 +118,15 @@ rec {
# Scripts for running tests. # Scripts for running tests.
tests = tests =
pkgs.callPackage nix/tests.nix { pkgs.callPackage nix/tests.nix {
inherit postgrest postgrestProfiled devCabalOptions withTools; inherit postgrest devCabalOptions withTools;
ghc = pkgs.haskell.compiler."${compiler}"; ghc = pkgs.haskell.compiler."${compiler}";
hpc-codecov = pkgs.haskell.packages."${compiler}".hpc-codecov; hpc-codecov = pkgs.haskell.packages."${compiler}".hpc-codecov;
}; };
# Script for running memory tests.
memory =
pkgs.callPackage nix/memory.nix { inherit postgrestProfiled withTools; };
# Linting and styling scripts. # Linting and styling scripts.
style = style =
pkgs.callPackage nix/style.nix { }; pkgs.callPackage nix/style.nix { };
+30
View File
@@ -0,0 +1,30 @@
# The memory tests have large dependencies (a profiled build of PostgREST)
# and are run less often than the spec tests, so we don't include them in
# the default test environment. We make them available through a separate module.
{ buildEnv
, checkedShellScript
, curl
, postgrestProfiled
, withTools
}:
let
test =
checkedShellScript
{
name = "postgrest-test-memory";
docs = "Run the memory tests.";
inRootDir = true;
}
''
export PATH="${postgrestProfiled}/bin:${curl}/bin:$PATH"
${withTools.latest} test/memory-tests.sh
'';
in
buildEnv
{
name = "postgrest-memory";
paths = [ test.bin ];
} // { bashCompletion = test.bashCompletion; }
+1 -23
View File
@@ -3,7 +3,6 @@
{ buildEnv { buildEnv
, cabal-install , cabal-install
, checkedShellScript , checkedShellScript
, curl
, devCabalOptions , devCabalOptions
, ghc , ghc
, glibcLocales , glibcLocales
@@ -11,7 +10,6 @@
, haskell , haskell
, hpc-codecov , hpc-codecov
, postgrest , postgrest
, postgrestProfiled
, python3 , python3
, runtimeShell , runtimeShell
, withTools , withTools
@@ -69,19 +67,6 @@ let
${ioTestPython}/bin/pytest -- -v test/io-tests "''${_arg_leftovers[@]}" ${ioTestPython}/bin/pytest -- -v test/io-tests "''${_arg_leftovers[@]}"
''; '';
testMemory =
checkedShellScript
{
name = "postgrest-test-memory";
docs = "Run the memory tests.";
inRootDir = true;
}
''
export PATH="${postgrestProfiled}/bin:${curl}/bin:$PATH"
${withTools.latest} test/memory-tests.sh
'';
dumpSchema = dumpSchema =
checkedShellScript checkedShellScript
{ {
@@ -192,11 +177,4 @@ buildEnv
"postgrest-tests"; "postgrest-tests";
paths = builtins.map (tool: tool.bin) tools; paths = builtins.map (tool: tool.bin) tools;
} // { } // { inherit bashCompletion; }
inherit bashCompletion;
# The memory tests have large dependencies (a profiled build of PostgREST)
# and are run less often than the spec tests, so we don't include them in
# the default test environment. We make them available through a separate attribute:
memoryTests = testMemory;
}
+2 -2
View File
@@ -41,7 +41,7 @@ lib.overrideDerivation postgrest.env (
postgrest.nixpkgsUpgrade.bin postgrest.nixpkgsUpgrade.bin
] ]
++ modules ++ modules
++ lib.optional memoryTests postgrest.tests.memoryTests.bin ++ lib.optional memoryTests postgrest.memory
++ lib.optional docker postgrest.docker; ++ lib.optional docker postgrest.docker;
shellHook = shellHook =
@@ -53,7 +53,7 @@ lib.overrideDerivation postgrest.env (
builtins.map (bashCompletion: "source ${bashCompletion}") ( builtins.map (bashCompletion: "source ${bashCompletion}") (
builtins.concatLists (builtins.map (module: module.bashCompletion) modules) builtins.concatLists (builtins.map (module: module.bashCompletion) modules)
++ [ postgrest.hsie.bashCompletion postgrest.nixpkgsUpgrade.bashCompletion ] ++ [ postgrest.hsie.bashCompletion postgrest.nixpkgsUpgrade.bashCompletion ]
++ lib.optional memoryTests postgrest.tests.memoryTests.bashCompletion ++ lib.optional memoryTests postgrest.memory.bashCompletion
++ lib.optional docker postgrest.docker.bashCompletion ++ lib.optional docker postgrest.docker.bashCompletion
) )