From d42f6128c7075a5babf21e4716f0d071724359e1 Mon Sep 17 00:00:00 2001 From: "Travis A. Everett" Date: Tue, 9 Aug 2022 10:19:07 -0500 Subject: [PATCH] bats: Add library test Co-Authored-By: Silvan Mosberger --- .../development/interpreters/bats/default.nix | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) 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