about summary refs log tree commit diff
path: root/pkgs/applications/editors
diff options
context:
space:
mode:
authorBen Siraphob <bensiraphob@gmail.com>2022-03-24 23:23:55 -0500
committerGitHub <noreply@github.com>2022-03-24 23:23:55 -0500
commit5e9f61240cef3c4e5a247aa7745afd203f82da35 (patch)
tree15036050bd1688da9b73ce7ab12357cd41508ea6 /pkgs/applications/editors
parentfcd48783a72d0880844872835b754c396e5d7a74 (diff)
parente2566775c76ae2e98617941c2555b439bc15de6d (diff)
downloadnixlib-5e9f61240cef3c4e5a247aa7745afd203f82da35.tar
nixlib-5e9f61240cef3c4e5a247aa7745afd203f82da35.tar.gz
nixlib-5e9f61240cef3c4e5a247aa7745afd203f82da35.tar.bz2
nixlib-5e9f61240cef3c4e5a247aa7745afd203f82da35.tar.lz
nixlib-5e9f61240cef3c4e5a247aa7745afd203f82da35.tar.xz
nixlib-5e9f61240cef3c4e5a247aa7745afd203f82da35.tar.zst
nixlib-5e9f61240cef3c4e5a247aa7745afd203f82da35.zip
Merge pull request #162096 from Synthetica9/micro-test-expect
Diffstat (limited to 'pkgs/applications/editors')
-rw-r--r--pkgs/applications/editors/micro/default.nix4
-rw-r--r--pkgs/applications/editors/micro/test-with-expect.nix30
2 files changed, 33 insertions, 1 deletions
diff --git a/pkgs/applications/editors/micro/default.nix b/pkgs/applications/editors/micro/default.nix
index c3c42ac24cba..d9805cbb36a9 100644
--- a/pkgs/applications/editors/micro/default.nix
+++ b/pkgs/applications/editors/micro/default.nix
@@ -1,4 +1,4 @@
-{ lib, buildGoModule, fetchFromGitHub, installShellFiles }:
+{ lib, buildGoModule, fetchFromGitHub, installShellFiles, callPackage }:
 
 buildGoModule rec {
   pname = "micro";
@@ -24,6 +24,8 @@ buildGoModule rec {
     install -Dt $out/share/applications assets/packaging/micro.desktop
   '';
 
+  passthru.tests.expect = callPackage ./test-with-expect.nix {};
+
   meta = with lib; {
     homepage = "https://micro-editor.github.io";
     description = "Modern and intuitive terminal-based text editor";
diff --git a/pkgs/applications/editors/micro/test-with-expect.nix b/pkgs/applications/editors/micro/test-with-expect.nix
new file mode 100644
index 000000000000..d3e1d60e0874
--- /dev/null
+++ b/pkgs/applications/editors/micro/test-with-expect.nix
@@ -0,0 +1,30 @@
+{ micro, expect, runCommand, writeScript, runtimeShell }:
+
+let expect-script = writeScript "expect-script" ''
+  #!${expect}/bin/expect -f
+
+  spawn micro file.txt
+  expect "file.txt"
+
+  send "Hello world!"
+  expect "Hello world!"
+
+  # Send ctrl-q (exit)
+  send "\021"
+
+  expect "Save changes to file.txt before closing?"
+  send "y"
+
+  expect eof
+''; in
+runCommand "micro-test-expect"
+{
+  nativeBuildInputs = [ micro expect ];
+  passthru = { inherit expect-script; };
+} ''
+  # Micro really wants a writable $HOME for its config directory.
+  export HOME=$(pwd)
+  expect -f ${expect-script}
+  grep "Hello world!" file.txt
+  touch $out
+''