bats: Add library test

Co-Authored-By: Silvan Mosberger <contact@infinisil.com>
This commit is contained in:
Travis A. Everett 2022-08-09 10:19:07 -05:00 committed by Silvan Mosberger
parent fbe194fdf6
commit d42f6128c7

View file

@ -16,6 +16,7 @@
, callPackages
, symlinkJoin
, makeWrapper
, runCommand
, doInstallCheck ? true
}:
@ -128,6 +129,32 @@ resholve.mkDerivation rec {
'';
};
passthru.tests.libraries = runCommand "${bats.name}-with-libraries-test" {
testScript = ''
setup() {
bats_load_library bats-support
bats_load_library bats-assert
bats_require_minimum_version 1.5.0
}
@test echo_hi {
run -0 echo hi
assert_output "hi"
}
@test cp_failure {
run ! cp
assert_line --index 0 "cp: missing file operand"
assert_line --index 1 "Try 'cp --help' for more information."
}
'';
passAsFile = [ "testScript" ];
} ''
${bats.withLibraries (p: [ p.bats-support p.bats-assert ])}/bin/bats "$testScriptPath"
touch "$out"
'';
passthru.tests.upstream = bats.unresholved.overrideAttrs (old: {
name = "${bats.name}-tests";
dontInstall = true; # just need the build directory