From fe8fa45573b5eff05c44d6c70976c61e4b372cdd Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Sat, 28 Nov 2020 13:33:16 -0500 Subject: [PATCH] bat: Add test --- nixos/tests/all-tests.nix | 1 + nixos/tests/bat.nix | 12 ++++++++++++ pkgs/tools/misc/bat/default.nix | 3 +++ 3 files changed, 16 insertions(+) create mode 100644 nixos/tests/bat.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 863031c04f8c..8cb27074f387 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -30,6 +30,7 @@ in avahi-with-resolved = handleTest ./avahi.nix { networkd = true; }; awscli = handleTest ./awscli.nix { }; babeld = handleTest ./babeld.nix {}; + bat = handleTest ./bat.nix {}; bazarr = handleTest ./bazarr.nix {}; bcachefs = handleTestOn ["x86_64-linux"] ./bcachefs.nix {}; # linux-4.18.2018.10.12 is unsupported on aarch64 beanstalkd = handleTest ./beanstalkd.nix {}; diff --git a/nixos/tests/bat.nix b/nixos/tests/bat.nix new file mode 100644 index 000000000000..8e65e235d94f --- /dev/null +++ b/nixos/tests/bat.nix @@ -0,0 +1,12 @@ +import ./make-test-python.nix ({ pkgs, ... }: { + name = "bat"; + meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ nequissimus ]; }; + + machine = { pkgs, ... }: { environment.systemPackages = [ pkgs.bat ]; }; + + testScript = '' + machine.succeed("echo 'Foobar\n\n\n42' > /tmp/foo") + assert "Foobar" in machine.succeed("bat -p /tmp/foo") + assert "42" in machine.succeed("bat -p /tmp/foo -r 4:4") + ''; +}) diff --git a/pkgs/tools/misc/bat/default.nix b/pkgs/tools/misc/bat/default.nix index da1f0d54f6f0..5c60305a2e74 100644 --- a/pkgs/tools/misc/bat/default.nix +++ b/pkgs/tools/misc/bat/default.nix @@ -1,4 +1,5 @@ { stdenv +, nixosTests , rustPlatform , fetchFromGitHub , pkg-config @@ -38,6 +39,8 @@ rustPlatform.buildRustPackage rec { --prefix PATH : "${stdenv.lib.makeBinPath [ less ]}" ''; + passthru.tests = { inherit (nixosTests) bat; }; + meta = with stdenv.lib; { description = "A cat(1) clone with syntax highlighting and Git integration"; homepage = "https://github.com/sharkdp/bat";