bats: Add library test
Co-Authored-By: Silvan Mosberger <contact@infinisil.com>
This commit is contained in:
parent
fbe194fdf6
commit
d42f6128c7
1 changed files with 27 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue