From c3c76afda4aa3fca2cb0365626f52b55fda98510 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 6 May 2024 17:25:58 +0300 Subject: [PATCH] flake/tests: initial test script --- .gitignore | 1 + flake/tests/checks/homeManagerModule.nix | 37 +++++++++++++++++++++++- flake/tests/default.nix | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 972ffd5..ab94f28 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ result result/ .direnv +.nixos-test-history # Ignore files generated by common IDEs .vscode/* diff --git a/flake/tests/checks/homeManagerModule.nix b/flake/tests/checks/homeManagerModule.nix index f6a29f9..f568243 100644 --- a/flake/tests/checks/homeManagerModule.nix +++ b/flake/tests/checks/homeManagerModule.nix @@ -6,6 +6,7 @@ }: nixosTest { name = "home-manager-test"; + skipLint = true; nodes.machine = { imports = [ @@ -27,5 +28,39 @@ nixosTest { }; }; - testScript = ""; + testScript = '' + import subprocess + machine.wait_for_unit("default.target") + + def check_errs(process): + # Check for errors + print("Connecting to Neovim process") + + # Capture stdout and stderr + stdout, stderr = process.communicate() + + # Print captured stdout and stderr + if stdout: + print("Captured stdout:") + print(stdout.decode('utf-8')) + if stderr: + print("Captured stderr:") + print(stderr.decode('utf-8')) + + def run_neovim_headless(): + print("Running Neovim in headless mode.") + + # Run Neovim in headless mode + nvim_process = subprocess.Popen(['nvim', '--headless'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + check_errs(nvim_process) + + # Load configuration file + nvim_process.stdin.write(b':NonExistentCommand\n') + nvim_process.stdin.flush() + + # run Neovim in headless mode + # and expect it to return sucessfully + machine.succeed(run_neovim_headless()) + ''; } diff --git a/flake/tests/default.nix b/flake/tests/default.nix index 4db2ffa..11463e4 100644 --- a/flake/tests/default.nix +++ b/flake/tests/default.nix @@ -22,6 +22,7 @@ in { checks = packagesFromDirectoryRecursive { inherit callPackage; + testProfile = ../profiles/minimal.nix; directory = ./checks; };