git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #103988 from NeQuissimus/nano_update

nano: Update script, test

commit098412567624d20f5e776aceb9fb3838159f950b authorTim Steinbach <NeQuissimus@users.noreply.github.com> dateTue 17 Nov 2020, 12:14 (6 years ago) parent805cedf0338f72
4 files changed+81−10
nixos/release-combined.nix+1 nixos/tests/all-tests.nix+1 nixos/tests/nano.nix+44 pkgs/applications/editors/nano/default.nix+35−10
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+35−10
@@ -1,10 +1,6 @@
1−{ stdenv, fetchurl, fetchFromGitHub
2−, ncurses
3−, texinfo
4−, gettext ? null
5−, enableNls ? true
6−, enableTiny ? false
7−}:
1+{ stdenv, fetchurl, fetchFromGitHub, ncurses, texinfo, writeScript
2+, common-updater-scripts, git, nix, nixfmt, coreutils, gnused, nixosTests
3+, gettext ? null, enableNls ? true, enableTiny ? false }:
84
95assert enableNls -> (gettext != null);
106
@@ -44,13 +40,42 @@ in stdenv.mkDerivation rec {
4440
4541 enableParallelBuilding = true;
4642
43+ passthru = {
44+ tests = { inherit (nixosTests) nano; };
45+
46+ updateScript = writeScript "update.sh" ''
47+ #!${stdenv.shell}
48+ set -o errexit
49+ PATH=${
50+ stdenv.lib.makeBinPath [
51+ common-updater-scripts
52+ git
53+ nixfmt
54+ nix
55+ coreutils
56+ gnused
57+ ]
58+ }
59+
60+ oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion ${pname}" | tr -d '"')"
61+ latestTag="$(git -c 'versionsort.suffix=-' ls-remote --exit-code --refs --sort='version:refname' --tags git://git.savannah.gnu.org/nano.git '*' | tail --lines=1 | cut --delimiter='/' --fields=3 | sed 's|^v||g')"
62+
63+ if [ ! "$oldVersion" = "$latestTag" ]; then
64+ update-source-version ${pname} "$latestTag" --version-key=version --print-changes
65+ nixpkgs="$(git rev-parse --show-toplevel)"
66+ default_nix="$nixpkgs/pkgs/applications/editors/nano/default.nix"
67+ nixfmt "$default_nix"
68+ else
69+ echo "${pname} is already up-to-date"
70+ fi
71+ '';
72+ };
73+
4774 meta = {
4875 homepage = "https://www.nano-editor.org/";
4976 description = "A small, user-friendly console text editor";
5077 license = licenses.gpl3Plus;
51− maintainers = with maintainers; [
52− joachifm
53− ];
78+ maintainers = with maintainers; [ joachifm nequissimus ];
5479 platforms = platforms.all;
5580 };
5681}