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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

145 lines
3.8 KiB
Nix
Raw Normal View History

{ resholve
2022-01-09 18:44:08 +00:00
, lib
2022-02-25 04:44:30 +00:00
, stdenv
2022-01-09 18:44:08 +00:00
, fetchFromGitHub
, bash
, coreutils
, gnugrep
, ncurses
, findutils
, hostname
, parallel
, flock
, ps
, bats
2022-02-25 04:44:30 +00:00
, lsof
, callPackages
2022-01-09 18:44:08 +00:00
, doInstallCheck ? true
}:
2016-02-07 11:11:31 +00:00
resholve.mkDerivation rec {
pname = "bats";
2022-05-16 15:35:28 +00:00
version = "1.7.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}";
2022-05-16 15:35:28 +00:00
sha256 = "sha256-joNne/dDVCNtzdTQ64rK8GimT+DOWUa7f410hml2s8Q=";
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"
"libexec/bats-core/*"
"lib/bats-core/*"
];
2022-01-09 18:44:08 +00:00
interpreter = "${bash}/bin/bash";
inputs = [
bash
coreutils
gnugrep
ncurses
findutils
hostname
parallel
flock
"lib/bats-core"
"libexec/bats-core"
];
2022-01-09 18:44:08 +00:00
fake = {
external = [
"greadlink"
"shlock"
];
2022-01-09 18:44:08 +00:00
};
fix = {
"$BATS_ROOT" = [ "${placeholder "out"}" ];
"$BATS_LIBEXEC" = [ "${placeholder "out"}/libexec/bats-core" ];
2022-01-09 18:44:08 +00:00
};
keep = {
"${placeholder "out"}/libexec/bats-core/bats" = true;
source = [
"${placeholder "out"}/lib/bats-core/validator.bash"
"${placeholder "out"}/lib/bats-core/preprocessing.bash"
"$BATS_TEST_SOURCE"
"${placeholder "out"}/lib/bats-core/tracing.bash"
"${placeholder "out"}/lib/bats-core/test_functions.bash"
"$library_load_path"
"${placeholder "out"}/lib/bats-core/common.bash"
"${placeholder "out"}/lib/bats-core/semaphore.bash"
"${placeholder "out"}/lib/bats-core/formatter.bash"
2022-05-16 15:35:28 +00:00
"${placeholder "out"}/lib/bats-core/warnings.bash"
"$setup_suite_file" # via cli arg
];
"$report_formatter" = true;
"$formatter" = true;
"$pre_command" = true;
"$BATS_TEST_NAME" = true;
"${placeholder "out"}/libexec/bats-core/bats-exec-test" = true;
2022-01-09 18:44:08 +00:00
};
execer = [
/*
both blatant lies for expedience; these can certainly exec args
they may be safe here, because they may always run things that
are ultimately in libexec?
TODO: handle parallel and flock in binlore/resholve
*/
"cannot:${parallel}/bin/parallel"
"cannot:${flock}/bin/flock"
"cannot:libexec/bats-core/bats-preprocess"
# these do exec, but other internal files
"cannot:libexec/bats-core/bats-exec-file"
"cannot:libexec/bats-core/bats-exec-suite"
];
2022-01-09 18:44:08 +00:00
};
};
passthru.libraries = callPackages ./libraries.nix {};
passthru.tests.upstream = bats.unresholved.overrideAttrs (old: {
name = "${bats.name}-tests";
2022-05-16 15:35:28 +00:00
dontInstall = true; # just need the build directory
installCheckInputs = [
ncurses
parallel # skips some tests if it can't detect
flock # skips some tests if it can't detect
ps
] ++ lib.optionals stdenv.isDarwin [ lsof ];
inherit doInstallCheck;
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 "disabled for nix build"' test/bats.bats
# skip tests that assume bats `install.sh` will be in BATS_ROOT
rm test/root.bats
# test generates file with absolute shebang dynamically
substituteInPlace test/install.bats --replace \
"/usr/bin/env bash" "${bash}/bin/bash"
${bats}/bin/bats test
touch $out
'';
});
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;
};
}