From 05bf935bc6dbffaec6fe11ddb29390e495393927 Mon Sep 17 00:00:00 2001 From: Tim Steinbach Date: Wed, 23 Dec 2020 12:30:39 -0500 Subject: [PATCH] ripgrep: Add test --- nixos/tests/all-tests.nix | 1 + nixos/tests/ripgrep.nix | 13 +++++++++++++ pkgs/tools/text/ripgrep/default.nix | 3 +++ 3 files changed, 17 insertions(+) create mode 100644 nixos/tests/ripgrep.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 306aca79d13..37e030992f0 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -324,6 +324,7 @@ in redis = handleTest ./redis.nix {}; redmine = handleTest ./redmine.nix {}; restic = handleTest ./restic.nix {}; + ripgrep = handleTest ./ripgrep.nix {}; robustirc-bridge = handleTest ./robustirc-bridge.nix {}; roundcube = handleTest ./roundcube.nix {}; rspamd = handleTest ./rspamd.nix {}; diff --git a/nixos/tests/ripgrep.nix b/nixos/tests/ripgrep.nix new file mode 100644 index 00000000000..9f76290488f --- /dev/null +++ b/nixos/tests/ripgrep.nix @@ -0,0 +1,13 @@ +import ./make-test-python.nix ({ pkgs, ... }: { + name = "ripgrep"; + meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ nequissimus ]; }; + + nodes.ripgrep = { pkgs, ... }: { environment.systemPackages = [ pkgs.ripgrep ]; }; + + testScript = '' + ripgrep.succeed('echo "abc\nbcd\ncde" > /tmp/foo') + assert "bcd" in ripgrep.succeed("rg -N 'bcd' /tmp/foo") + assert "bcd\ncde" in ripgrep.succeed("rg -N 'cd' /tmp/foo") + assert "ripgrep ${pkgs.ripgrep.version}" in ripgrep.succeed("rg --version | head -1") + ''; +}) diff --git a/pkgs/tools/text/ripgrep/default.nix b/pkgs/tools/text/ripgrep/default.nix index 7bd8a74f458..c69c6fef8cb 100644 --- a/pkgs/tools/text/ripgrep/default.nix +++ b/pkgs/tools/text/ripgrep/default.nix @@ -1,4 +1,5 @@ { stdenv +, nixosTests , fetchFromGitHub , rustPlatform , asciidoctor @@ -34,6 +35,8 @@ rustPlatform.buildRustPackage rec { installShellCompletion --zsh complete/_rg ''; + passthru.tests = { inherit (nixosTests) ripgrep; }; + meta = with stdenv.lib; { description = "A utility that combines the usability of The Silver Searcher with the raw speed of grep"; homepage = "https://github.com/BurntSushi/ripgrep";