[nix] some attempt to make tests work

parent ac6ce3c0
Pipeline #7745 failed with stages
in 56 minutes and 33 seconds
...@@ -107,3 +107,44 @@ test: ...@@ -107,3 +107,44 @@ test:
chown -R root:root /root/ chown -R root:root /root/
chown -R root:root $STORE_DIR chown -R root:root $STORE_DIR
chown -R root:root /root/.cache/cabal/logs/ chown -R root:root /root/.cache/cabal/logs/
test-flake:
stage: test
# The tests needs to run as the 'test' user, because they leverage the
# initdb utility from postgres that cannot be run by 'root'.
before_script:
- echo "Creating test user..."
- mkdir -p /home/test
- mkdir -p /root/.config
- useradd -U test
- chown -R test:test dist-newstyle/
- chown -R test:test /root/
- chown -R test:test $STORE_DIR
- chown -R test:test ${CABAL_DIR}
- mkdir -p "$XDG_CACHE_HOME/nix"
- chown -R test:test "$XDG_CACHE_HOME/nix"
cache:
key: cabal.project
paths:
- dist-newstyle/
- .cabal/
policy: pull-push
script:
- |
git config --global --add safe.directory $XDG_CACHE_HOME/nix/tarball-cache
git config --global --add safe.directory '*'
export TEST_TMPDIR="${CI_PROJECT_DIR}/tmp"
mkdir -p "$TEST_TMPDIR"
nix-shell --run "./bin/update-project-dependencies $STORE_DIR"
mkdir -p /root/.cache/cabal/logs
chown -R test:test /root/.cache/cabal/logs/
chown -R test:test "$TEST_TMPDIR"
chown -R test:test /root/.config/
su -m test -c "export TMPDIR=$TEST_TMPDIR && cd /builds/gargantext/haskell-gargantext; nix run .#gargantext:test:garg-test"
chown -R root:root dist-newstyle/
chown -R root:root /root/
chown -R root:root $STORE_DIR
chown -R root:root /root/.cache/cabal/logs/
...@@ -209,12 +209,12 @@ ...@@ -209,12 +209,12 @@
# Preserve rev for the inputMap # Preserve rev for the inputMap
passthru.rev = src.rev; passthru.rev = src.rev;
}; };
applyPatches = inputName: patches: pkgs.buildPackages.applyPatches # applyPatches = inputName: patches: pkgs.buildPackages.applyPatches
{ # {
name = "${inputName}-patched"; # name = "${inputName}-patched";
src = inputs.${inputName}; # src = inputs.${inputName};
inherit patches; # inherit patches;
} // { inherit (inputs.${inputName}) rev; }; # } // { inherit (inputs.${inputName}) rev; };
in in
{ {
#"https://github.com/AccelerateHS/accelerate-llvm.git" = inputs.accelerate-llvm; #"https://github.com/AccelerateHS/accelerate-llvm.git" = inputs.accelerate-llvm;
...@@ -295,6 +295,9 @@ ...@@ -295,6 +295,9 @@
}; };
packages.llvm-hs.components.library.build-tools = lib.mkOverride 49 [ pkgs.llvmPackages_12.llvm ]; packages.llvm-hs.components.library.build-tools = lib.mkOverride 49 [ pkgs.llvmPackages_12.llvm ];
#packages.gargantext.components.tests.garg-test.systemDepends = [ pkgs.postgresql_14 ];
packages.postgresql-simple.components.library.libs = [ pkgs.postgresql_14 ];
}) })
]; ];
...@@ -541,31 +544,17 @@ ...@@ -541,31 +544,17 @@
''; '';
}; };
}; };
# For garg-test-hspec
coreNLP = pkgs.callPackage ./nix/corenlp.nix { };
# # Avoid recompiling openjdk due to any overlay used in the common pkgs.
# let pkgs = import inputs.nixpkgs { inherit system; }; in
# inputs.flake-utils.lib.mkApp {
# drv = pkgs.writeShellApplication {
# name = "coreNLP";
# text = ''
# set -x
# exec ${pkgs.openjdk}/bin/java -mx4g -cp '${inputs.coreNLP}/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000
# '';
# };
# };
}; };
# For running all checks (very slow): # For running all checks (very slow):
# $ nix -L flake check # $ nix -L flake check
# #
# For building a specific check of the project: # For building a specific check of the project:
# $ nix -L build .#project.hsPkgs.gargantext.components.tests.garg-test-tasty # $ nix -L build .#project.hsPkgs.gargantext.components.tests.garg-test
# $ result/bin/garg-test-tasty # $ result/bin/garg-test
# #
# Alternatively, but slower: # Alternatively, but slower:
# $ nix -L build .#checks.x86_64-linux.gargantext:test:garg-test-tasty # $ nix -L build .#checks.x86_64-linux.gargantext:test:garg-test
# $ bat result/test-stdout # $ bat result/test-stdout
# #
# See names from: # See names from:
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
export GARGANTEXT_CORENLP_SERVER="${pkgs.nixVersions.stable}/bin/nix run .#coreNLP" export GARGANTEXT_CORENLP_SERVER="${pkgs.nixVersions.stable}/bin/nix run .#coreNLP"
''; '';
packages.gargantext.components.tests.garg-test-hspec.testFlags = [ packages.gargantext.components.tests.garg-test.testFlags = [
# FIXME: # FIXME:
# test/Test/Database/Operations.hs:64:7: # test/Test/Database/Operations.hs:64:7:
# 1) Database.Read/Writes, Corpus creation, Can add documents to a Corpus # 1) Database.Read/Writes, Corpus creation, Can add documents to a Corpus
...@@ -32,19 +32,12 @@ ...@@ -32,19 +32,12 @@
# (ConnectionFailure Network.Socket.connect: <socket: 18>: does not exist (Connection refused)) # (ConnectionFailure Network.Socket.connect: <socket: 18>: does not exist (Connection refused))
"--match" "--match"
"'!/Database/Read/Writes/Corpus creation/Can add documents to a Corpus/'" "'!/Database/Read/Writes/Corpus creation/Can add documents to a Corpus/'"
];
# Beware those failures are non-deterministic. # Beware those failures are non-deterministic.
# For reproducing it may help to use a project's variant like "coverage": # For reproducing it may help to use a project's variant like "coverage":
# $ nix -L build .#project.projectVariants.coverage.hsPkgs.gargantext.components.tests.garg-test-tasty # $ nix -L build .#project.projectVariants.coverage.hsPkgs.gargantext.components.tests.garg-test-tasty
# $ for i in {1..100}; do result/bin/garg-test-tasty --hide-successes || break; done # $ for i in {1..100}; do result/bin/garg-test-tasty --hide-successes || break; done
# Note that testFlags are only applied on checks.*, not on tests.* # Note that testFlags are only applied on checks.*, not on tests.*
packages.gargantext.components.tests.garg-test-tasty = {
build-tools = [
pkgs.graphviz
];
testFlags = [
"--pattern"
("'" + lib.concatStringsSep " && " [ ("'" + lib.concatStringsSep " && " [
# FAIL: (non-deterministic) # FAIL: (non-deterministic)
# Graph Clustering # Graph Clustering
...@@ -145,7 +138,6 @@ ...@@ -145,7 +138,6 @@
"!/Conditional/" "!/Conditional/"
] + "'") ] + "'")
]; ];
};
}) })
]; ];
} }
...@@ -74,7 +74,7 @@ killProcessTree :: (Handle, Handle, ProcessHandle) -> IO () ...@@ -74,7 +74,7 @@ killProcessTree :: (Handle, Handle, ProcessHandle) -> IO ()
killProcessTree (_, _, ph) = do killProcessTree (_, _, ph) = do
pid <- getPid ph pid <- getPid ph
case pid of case pid of
Nothing -> putText "Process already terminated" Nothing -> putText "[killProcessTree] Process already terminated"
Just p -> do Just p -> do
pgid <- getProcessGroupIDOf p pgid <- getProcessGroupIDOf p
signalProcessGroup keyboardSignal pgid signalProcessGroup keyboardSignal pgid
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment