mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-04 12:53:05 +00:00
bats: Add library wrapper
Adds a `bats.withLibraries (p: [ ... ])` function, which creates a `bats` wrapper where the `BATS_LIB_PATH` environment variable contains fallbacks for the given list of libraries. This allows to e.g. use the `bats-assert` library (which itself requires the `bats-support` library) with bats.withLibraries (p: [ p.bats-support p.bats-assert ]) In a `.bats` file you can then call `bats_load_library` [1] to load the libraries in the `setup()` function: setup() { bats_load_library bats-support bats_load_library bats-assert } [1]: https://bats-core.readthedocs.io/en/stable/writing-tests.html?highlight=library#bats-load-library-load-system-wide-libraries
This commit is contained in:
parent
d1949b739a
commit
fbe194fdf6
@ -14,6 +14,8 @@
|
||||
, bats
|
||||
, lsof
|
||||
, callPackages
|
||||
, symlinkJoin
|
||||
, makeWrapper
|
||||
, doInstallCheck ? true
|
||||
}:
|
||||
|
||||
@ -108,6 +110,24 @@ resholve.mkDerivation rec {
|
||||
|
||||
passthru.libraries = callPackages ./libraries.nix {};
|
||||
|
||||
passthru.withLibraries = selector:
|
||||
symlinkJoin {
|
||||
name = "bats-with-libraries-${bats.version}";
|
||||
|
||||
paths = [
|
||||
bats
|
||||
] ++ selector bats.libraries;
|
||||
|
||||
nativeBuildInputs = [
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
postBuild = ''
|
||||
wrapProgram "$out/bin/bats" \
|
||||
--suffix BATS_LIB_PATH : "$out/share/bats"
|
||||
'';
|
||||
};
|
||||
|
||||
passthru.tests.upstream = bats.unresholved.overrideAttrs (old: {
|
||||
name = "${bats.name}-tests";
|
||||
dontInstall = true; # just need the build directory
|
||||
|
Loading…
Reference in New Issue
Block a user