mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-29 00:53:57 +00:00
31 lines
634 B
Nix
31 lines
634 B
Nix
{ 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
|
|
''
|