micro: add test with expect

+33 -1
+3 -1
pkgs/applications/editors/micro/default.nix
··· 1 - { lib, buildGoModule, fetchFromGitHub, installShellFiles }: 1 + { lib, buildGoModule, fetchFromGitHub, installShellFiles, callPackage }: 2 2 3 3 buildGoModule rec { 4 4 pname = "micro"; ··· 23 23 installManPage assets/packaging/micro.1 24 24 install -Dt $out/share/applications assets/packaging/micro.desktop 25 25 ''; 26 + 27 + passthru.tests.expect = callPackage ./test-with-expect.nix {}; 26 28 27 29 meta = with lib; { 28 30 homepage = "https://micro-editor.github.io";
+30
pkgs/applications/editors/micro/test-with-expect.nix
··· 1 + { micro, expect, runCommand, writeScript, runtimeShell }: 2 + 3 + let expect-script = writeScript "expect-script" '' 4 + #!${expect}/bin/expect -f 5 + 6 + spawn micro file.txt 7 + expect "file.txt" 8 + 9 + send "Hello world!" 10 + expect "Hello world!" 11 + 12 + # Send ctrl-q (exit) 13 + send "\021" 14 + 15 + expect "Save changes to file.txt before closing?" 16 + send "y" 17 + 18 + expect eof 19 + ''; in 20 + runCommand "micro-test-expect" 21 + { 22 + nativeBuildInputs = [ micro expect ]; 23 + passthru = { inherit expect-script; }; 24 + } '' 25 + # Micro really wants a writable $HOME for its config directory. 26 + export HOME=$(pwd) 27 + expect -f ${expect-script} 28 + grep "Hello world!" file.txt 29 + touch $out 30 + ''