mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 00:12:56 +00:00
Merge pull request #162096 from Synthetica9/micro-test-expect
This commit is contained in:
commit
5e9f61240c
@ -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";
|
||||
|
30
pkgs/applications/editors/micro/test-with-expect.nix
Normal file
30
pkgs/applications/editors/micro/test-with-expect.nix
Normal file
@ -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
|
||||
''
|
Loading…
Reference in New Issue
Block a user