tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
micro: add test with expect
Patrick Hilhorst
4 years ago
e2566775
5c713b55
+33
-1
2 changed files
expand all
collapse all
unified
split
pkgs
applications
editors
micro
default.nix
test-with-expect.nix
+3
-1
pkgs/applications/editors/micro/default.nix
···
1
1
-
{ lib, buildGoModule, fetchFromGitHub, installShellFiles }:
1
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
26
+
27
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
1
+
{ micro, expect, runCommand, writeScript, runtimeShell }:
2
2
+
3
3
+
let expect-script = writeScript "expect-script" ''
4
4
+
#!${expect}/bin/expect -f
5
5
+
6
6
+
spawn micro file.txt
7
7
+
expect "file.txt"
8
8
+
9
9
+
send "Hello world!"
10
10
+
expect "Hello world!"
11
11
+
12
12
+
# Send ctrl-q (exit)
13
13
+
send "\021"
14
14
+
15
15
+
expect "Save changes to file.txt before closing?"
16
16
+
send "y"
17
17
+
18
18
+
expect eof
19
19
+
''; in
20
20
+
runCommand "micro-test-expect"
21
21
+
{
22
22
+
nativeBuildInputs = [ micro expect ];
23
23
+
passthru = { inherit expect-script; };
24
24
+
} ''
25
25
+
# Micro really wants a writable $HOME for its config directory.
26
26
+
export HOME=$(pwd)
27
27
+
expect -f ${expect-script}
28
28
+
grep "Hello world!" file.txt
29
29
+
touch $out
30
30
+
''