git.iko.soy/typeable/nixpkgs
on master help sign in
nano: Add test
commit0338f728c01329427c407ccd0bf6e527eee2358c authorTim Steinbach <tim@nequissimus.com> dateMon 16 Nov 2020, 13:59 (6 years ago) parent701df1a
4 files changed+51−3
nixos/release-combined.nix+1 nixos/tests/all-tests.nix+1 nixos/tests/nano.nix+44 pkgs/applications/editors/nano/default.nix+5−3
nixos/release-combined.nix+1
@@ -97,6 +97,7 @@ in rec {
9797 (onFullSupported "nixos.tests.login")
9898 (onFullSupported "nixos.tests.misc")
9999 (onFullSupported "nixos.tests.mutableUsers")
100+ (onFullSupported "nixos.tests.nano")
100101 (onFullSupported "nixos.tests.nat.firewall-conntrack")
101102 (onFullSupported "nixos.tests.nat.firewall")
102103 (onFullSupported "nixos.tests.nat.standalone")
nixos/tests/all-tests.nix+1
@@ -225,6 +225,7 @@ in
225225 mysql-backup = handleTest ./mysql/mysql-backup.nix {};
226226 mysql-replication = handleTest ./mysql/mysql-replication.nix {};
227227 nagios = handleTest ./nagios.nix {};
228+ nano = handleTest ./nano.nix {};
228229 nar-serve = handleTest ./nar-serve.nix {};
229230 nat.firewall = handleTest ./nat.nix { withFirewall = true; };
230231 nat.firewall-conntrack = handleTest ./nat.nix { withFirewall = true; withConntrackHelpers = true; };
nixos/tests/nano.nixnew file+44
@@ -0,0 +1,44 @@
1+import ./make-test-python.nix ({ pkgs, ...} : {
2+ name = "nano";
3+ meta = with pkgs.stdenv.lib.maintainers; {
4+ maintainers = [ nequissimus ];
5+ };
6+
7+ machine = { lib, ... }: {
8+ environment.systemPackages = [ pkgs.nano ];
9+ };
10+
11+ testScript = { ... }: ''
12+ start_all()
13+
14+ with subtest("Create user and log in"):
15+ machine.wait_for_unit("multi-user.target")
16+ machine.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
17+ machine.succeed("useradd -m alice")
18+ machine.succeed("(echo foobar; echo foobar) | passwd alice")
19+ machine.wait_until_tty_matches(1, "login: ")
20+ machine.send_chars("alice\n")
21+ machine.wait_until_tty_matches(1, "login: alice")
22+ machine.wait_until_succeeds("pgrep login")
23+ machine.wait_until_tty_matches(1, "Password: ")
24+ machine.send_chars("foobar\n")
25+ machine.wait_until_succeeds("pgrep -u alice bash")
26+ machine.screenshot("prompt")
27+
28+ with subtest("Use nano"):
29+ machine.send_chars("nano /tmp/foo")
30+ machine.send_key("ret")
31+ machine.sleep(2)
32+ machine.send_chars("42")
33+ machine.sleep(1)
34+ machine.send_key("ctrl-x")
35+ machine.sleep(1)
36+ machine.send_key("y")
37+ machine.sleep(1)
38+ machine.screenshot("nano")
39+ machine.sleep(1)
40+ machine.send_key("ret")
41+ machine.wait_for_file("/tmp/foo")
42+ assert "42" in machine.succeed("cat /tmp/foo")
43+ '';
44+})
pkgs/applications/editors/nano/default.nix+5−3
@@ -1,6 +1,6 @@
11{ stdenv, fetchurl, fetchFromGitHub, ncurses, texinfo, writeScript
2−, common-updater-scripts, git, nix, nixfmt, coreutils, gnused, gettext ? null
3−, enableNls ? true, enableTiny ? false }:
2+, common-updater-scripts, git, nix, nixfmt, coreutils, gnused, nixosTests
3+, gettext ? null, enableNls ? true, enableTiny ? false }:
44
55assert enableNls -> (gettext != null);
66
@@ -41,6 +41,8 @@ in stdenv.mkDerivation rec {
4141 enableParallelBuilding = true;
4242
4343 passthru = {
44+ tests = { inherit (nixosTests) nano; };
45+
4446 updateScript = writeScript "update.sh" ''
4547 #!${stdenv.shell}
4648 set -o errexit
@@ -73,7 +75,7 @@ in stdenv.mkDerivation rec {
7375 homepage = "https://www.nano-editor.org/";
7476 description = "A small, user-friendly console text editor";
7577 license = licenses.gpl3Plus;
76− maintainers = with maintainers; [ joachifm ];
78+ maintainers = with maintainers; [ joachifm nequissimus ];
7779 platforms = platforms.all;
7880 };
7981}