2022-04-15 01:41:22 +00:00
|
|
|
{ resholve
|
2022-02-10 20:34:41 +00:00
|
|
|
, lib
|
2022-03-05 16:20:37 +00:00
|
|
|
, stdenv
|
2022-02-10 20:34:41 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, bash
|
|
|
|
, coreutils
|
|
|
|
, gnugrep
|
|
|
|
, ncurses
|
2022-05-18 14:49:53 +00:00
|
|
|
, findutils
|
|
|
|
, hostname
|
|
|
|
, parallel
|
|
|
|
, flock
|
|
|
|
, ps
|
|
|
|
, bats
|
2022-03-05 16:20:37 +00:00
|
|
|
, lsof
|
2022-02-10 20:34:41 +00:00
|
|
|
, doInstallCheck ? true
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
resholve.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "bats";
|
2022-06-16 17:23:12 +00:00
|
|
|
version = "1.7.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-13 20:06:32 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "bats-core";
|
|
|
|
repo = "bats-core";
|
|
|
|
rev = "v${version}";
|
2022-06-16 17:23:12 +00:00
|
|
|
sha256 = "sha256-joNne/dDVCNtzdTQ64rK8GimT+DOWUa7f410hml2s8Q=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patchPhase = ''
|
2021-02-05 17:12:51 +00:00
|
|
|
patchShebangs .
|
|
|
|
'';
|
2020-05-03 17:38:23 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
installPhase = ''
|
|
|
|
./install.sh $out
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
solutions = {
|
|
|
|
bats = {
|
2022-05-18 14:49:53 +00:00
|
|
|
scripts = [
|
|
|
|
"bin/bats"
|
|
|
|
"libexec/bats-core/*"
|
|
|
|
"lib/bats-core/*"
|
|
|
|
];
|
2022-02-10 20:34:41 +00:00
|
|
|
interpreter = "${bash}/bin/bash";
|
2022-05-18 14:49:53 +00:00
|
|
|
inputs = [
|
|
|
|
bash
|
|
|
|
coreutils
|
|
|
|
gnugrep
|
|
|
|
ncurses
|
|
|
|
findutils
|
|
|
|
hostname
|
|
|
|
parallel
|
|
|
|
flock
|
|
|
|
"lib/bats-core"
|
|
|
|
"libexec/bats-core"
|
|
|
|
];
|
2022-02-10 20:34:41 +00:00
|
|
|
fake = {
|
2022-05-18 14:49:53 +00:00
|
|
|
external = [
|
|
|
|
"greadlink"
|
|
|
|
"shlock"
|
|
|
|
];
|
2022-02-10 20:34:41 +00:00
|
|
|
};
|
|
|
|
fix = {
|
|
|
|
"$BATS_ROOT" = [ "${placeholder "out"}" ];
|
2022-05-18 14:49:53 +00:00
|
|
|
"$BATS_LIBEXEC" = [ "${placeholder "out"}/libexec/bats-core" ];
|
2022-02-10 20:34:41 +00:00
|
|
|
};
|
|
|
|
keep = {
|
|
|
|
"${placeholder "out"}/libexec/bats-core/bats" = true;
|
2022-05-18 14:49:53 +00:00
|
|
|
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-06-16 17:23:12 +00:00
|
|
|
"${placeholder "out"}/lib/bats-core/warnings.bash"
|
|
|
|
"$setup_suite_file" # via cli arg
|
2022-05-18 14:49:53 +00:00
|
|
|
];
|
|
|
|
"$report_formatter" = true;
|
|
|
|
"$formatter" = true;
|
|
|
|
"$pre_command" = true;
|
|
|
|
"$BATS_TEST_NAME" = true;
|
|
|
|
"${placeholder "out"}/libexec/bats-core/bats-exec-test" = true;
|
2022-02-10 20:34:41 +00:00
|
|
|
};
|
2022-05-18 14:49:53 +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-02-10 20:34:41 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
passthru.tests.upstream = bats.unresholved.overrideAttrs (old: {
|
|
|
|
name = "${bats.name}-tests";
|
2022-06-16 17:23:12 +00:00
|
|
|
dontInstall = true; # just need the build directory
|
2022-05-18 14:49:53 +00:00
|
|
|
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
|
2021-03-19 17:17:44 +00:00
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
});
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/bats-core/bats-core";
|
|
|
|
description = "Bash Automated Testing System";
|
2021-02-05 17:12:51 +00:00
|
|
|
maintainers = with maintainers; [ abathur ];
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|