nixpkgs/pkgs/development/interpreters/bats/default.nix

67 lines
1.4 KiB
Nix
Raw Normal View History

2022-01-09 18:44:08 +00:00
{ resholvePackage
, lib
, fetchFromGitHub
, bash
, coreutils
, gnugrep
, ncurses
, doInstallCheck ? true
}:
2016-02-07 11:11:31 +00:00
2022-01-09 18:44:08 +00:00
resholvePackage rec {
pname = "bats";
2021-10-29 08:25:13 +00:00
version = "1.5.0";
2016-02-07 11:11:31 +00:00
2022-01-07 16:11:59 +00:00
src = fetchFromGitHub {
owner = "bats-core";
repo = "bats-core";
rev = "v${version}";
sha256 = "sha256-MEkMi2w8G9FZhE3JvzzbqObcErQ9WFXy5mtKwQOoxbk=";
2016-02-07 11:11:31 +00:00
};
2018-10-27 13:18:53 +00:00
patchPhase = ''
2021-01-12 01:29:36 +00:00
patchShebangs .
'';
2021-01-12 01:29:36 +00:00
installPhase = ''
./install.sh $out
2018-10-27 13:18:53 +00:00
'';
2022-01-09 18:44:08 +00:00
solutions = {
bats = {
scripts = [ "bin/bats" ];
interpreter = "${bash}/bin/bash";
inputs = [ bash coreutils gnugrep ];
fake = {
external = [ "greadlink" ];
};
fix = {
"$BATS_ROOT" = [ "${placeholder "out"}" ];
};
keep = {
"${placeholder "out"}/libexec/bats-core/bats" = true;
};
};
};
inherit doInstallCheck;
installCheckInputs = [ ncurses ];
installCheckPhase = ''
# TODO: cut if https://github.com/bats-core/bats-core/issues/418 allows
sed -i '/test works even if PATH is reset/a skip' test/bats.bats
2021-01-12 01:29:36 +00:00
# test generates file with absolute shebang dynamically
substituteInPlace test/install.bats --replace \
"/usr/bin/env bash" "${bash}/bin/bash"
bin/bats test
'';
2016-02-07 11:11:31 +00:00
2021-01-12 01:29:36 +00:00
meta = with lib; {
homepage = "https://github.com/bats-core/bats-core";
2016-02-07 11:11:31 +00:00
description = "Bash Automated Testing System";
2021-01-12 01:29:36 +00:00
maintainers = with maintainers; [ abathur ];
2016-02-07 11:11:31 +00:00
license = licenses.mit;
platforms = platforms.unix;
};
}