summaryrefslogtreecommitdiff
path: root/test/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'test/flake.nix')
-rw-r--r--test/flake.nix89
1 files changed, 66 insertions, 23 deletions
diff --git a/test/flake.nix b/test/flake.nix
index 724fc9c..c465c0e 100644
--- a/test/flake.nix
+++ b/test/flake.nix
@@ -26,35 +26,78 @@
lib,
pkgs,
...
- }: {
- procfiles.daemons.processes = {
- redis = lib.getExe' pkgs.redis "redis-server";
- };
+ }: let
+ mkTestShell = runtimeInputs: text:
+ pkgs.mkShellNoCC {
+ packages = [
+ (pkgs.writeShellApplication {
+ name = "run-ci";
+
+ inherit runtimeInputs text;
+ })
+ ];
+ };
- devShells.default = pkgs.mkShellNoCC {
- packages = [
- (pkgs.writeShellApplication {
- name = "run-ci";
+ testScript = exe: check: kill: ''
+ set -x
- runtimeInputs = [pkgs.overmind];
+ ${exe}
+ sleep 5 # avoid race conditions
- text = ''
- set -x
+ if ${check}; then
+ echo "Processes failed to launch! Exiting with error"
+ ${kill}
+ exit 1
+ fi
- exec ${lib.getExe config.procfiles.daemons.package} &
- sleep 5 # avoid race conditions
+ ${kill}
+ echo "Process finished! Exiting as success"
+ '';
+
+ processes = {
+ redis = lib.getExe' pkgs.redis "redis-server";
+ };
+ in {
+ procfiles = {
+ # overmind as default
+ overmind-dft = {inherit processes;};
+
+ # explicit overmind
+ overmind = {
+ inherit processes;
+ procRunner = pkgs.overmind;
+ };
+
+ # honcho
+ honcho = {
+ inherit processes;
+ procRunner = pkgs.honcho;
+ };
+ };
- if ! overmind status | grep running; then
- echo "Processes failed to launch! Exiting with error"
- overmind kill
- exit 1
- fi
+ devShells = {
+ overmind-dft = mkTestShell [pkgs.overmind] (
+ testScript
+ "exec ${(lib.getExe config.procfiles.overmind-dft.package)} &"
+ "! overmind status | grep running"
+ "overmind kill"
+ );
- overmind kill
- echo "Process finished! Exiting as success"
- '';
- })
- ];
+ overmind = mkTestShell [pkgs.overmind] (
+ testScript
+ "exec ${(lib.getExe config.procfiles.overmind.package)} &"
+ "! overmind status | grep running"
+ "overmind kill"
+ );
+ honcho = mkTestShell [pkgs.honcho] (
+ testScript
+ ''
+ exec ${(lib.getExe config.procfiles.honcho.package)} & \
+ PROC_PID=$!
+ ''
+ "! ps -p \"$PROC_PID\" > /dev/null"
+ "kill -2 $PROC_PID; pkill -f \"redis\""
+ );
};
};
};