diff --git a/pkgs/development/interpreters/bats/default.nix b/pkgs/development/interpreters/bats/default.nix index b9899fc229dd..89539850163e 100644 --- a/pkgs/development/interpreters/bats/default.nix +++ b/pkgs/development/interpreters/bats/default.nix @@ -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