diff --git a/pkgs/development/interpreters/bats/default.nix b/pkgs/development/interpreters/bats/default.nix index 000c6045922c..17d22a14cae5 100644 --- a/pkgs/development/interpreters/bats/default.nix +++ b/pkgs/development/interpreters/bats/default.nix @@ -18,17 +18,22 @@ , makeWrapper , runCommand , doInstallCheck ? true +# packages that use bats (for update testing) +, bash-preexec +, kikit +, locate-dominating-file +, packcc }: resholve.mkDerivation rec { pname = "bats"; - version = "1.10.0"; + version = "1.11.0"; src = fetchFromGitHub { owner = "bats-core"; repo = "bats-core"; rev = "v${version}"; - sha256 = "sha256-gy4dyoKRlf2WFmH1/mSNwhVR3df92BgpT4TjTpV4FyQ="; + hash = "sha256-goHIhbBoCf1eb1N8xIHdVvAURofvLDgEDXofhDHrr7Y="; }; patchPhase = '' @@ -64,11 +69,13 @@ resholve.mkDerivation rec { external = [ "greadlink" "shlock" + ] ++ lib.optionals stdenv.isDarwin [ "pkill" # procps doesn't supply this on darwin ]; }; fix = { "$BATS_ROOT" = [ "${placeholder "out"}" ]; + "$BATS_LIBDIR" = [ "lib" ]; "$BATS_LIBEXEC" = [ "${placeholder "out"}/libexec/bats-core" ]; }; keep = { @@ -94,6 +101,7 @@ resholve.mkDerivation rec { "$BATS_LINE_REFERENCE_FORMAT" = "comma_line"; "$BATS_LOCKING_IMPLEMENTATION" = "${flock}/bin/flock"; "$parallel_binary_name" = "${parallel}/bin/parallel"; + "${placeholder "out"}/libexec/bats-core/bats-preprocess" = true; }; execer = [ /* @@ -110,6 +118,10 @@ resholve.mkDerivation rec { # these do exec, but other internal files "cannot:libexec/bats-core/bats-exec-file" "cannot:libexec/bats-core/bats-exec-suite" + "cannot:libexec/bats-core/bats-gather-tests" + ] ++ lib.optionals (!stdenv.isDarwin) [ + # checked invocations for exec + "cannot:${procps}/bin/pkill" ]; }; }; @@ -134,78 +146,90 @@ 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_load_library bats-file - bats_load_library bats-detik/detik.bash + passthru.tests = { + libraries = runCommand "${bats.name}-with-libraries-test" { + testScript = '' + setup() { + bats_load_library bats-support + bats_load_library bats-assert + bats_load_library bats-file + bats_load_library bats-detik/detik.bash - bats_require_minimum_version 1.5.0 + bats_require_minimum_version 1.5.0 - TEST_TEMP_DIR="$(temp_make --prefix 'nixpkgs-bats-test')" - } + TEST_TEMP_DIR="$(temp_make --prefix 'nixpkgs-bats-test')" + } - teardown() { - temp_del "$TEST_TEMP_DIR" - } + teardown() { + temp_del "$TEST_TEMP_DIR" + } - @test echo_hi { - run -0 echo hi - assert_output "hi" - } + @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." - } + @test cp_failure { + run ! cp + assert_line --index 0 "cp: missing file operand" + assert_line --index 1 "Try 'cp --help' for more information." + } - @test file_exists { - echo "hi" > "$TEST_TEMP_DIR/hello.txt" - assert_file_exist "$TEST_TEMP_DIR/hello.txt" - run cat "$TEST_TEMP_DIR/hello.txt" - assert_output "hi" - } + @test file_exists { + echo "hi" > "$TEST_TEMP_DIR/hello.txt" + assert_file_exist "$TEST_TEMP_DIR/hello.txt" + run cat "$TEST_TEMP_DIR/hello.txt" + assert_output "hi" + } + ''; + passAsFile = [ "testScript" ]; + } '' + ${bats.withLibraries (p: [ p.bats-support p.bats-assert p.bats-file p.bats-detik ])}/bin/bats "$testScriptPath" + touch "$out" ''; - passAsFile = [ "testScript" ]; - } '' - ${bats.withLibraries (p: [ p.bats-support p.bats-assert p.bats-file p.bats-detik ])}/bin/bats "$testScriptPath" - touch "$out" - ''; - passthru.tests.upstream = bats.unresholved.overrideAttrs (old: { - name = "${bats.name}-tests"; - dontInstall = true; # just need the build directory - nativeInstallCheckInputs = [ - ncurses - parallel # skips some tests if it can't detect - flock # skips some tests if it can't detect - procps - ] ++ lib.optionals stdenv.isDarwin [ lsof ]; - inherit doInstallCheck; - installCheckPhase = '' - # TODO: cut if https://github.com/bats-core/bats-core/issues/418 allows - sed -i '/test works even if PATH is reset/a skip "disabled for nix build"' test/bats.bats + upstream = bats.unresholved.overrideAttrs (old: { + name = "${bats.name}-tests"; + dontInstall = true; # just need the build directory + nativeInstallCheckInputs = [ + ncurses + parallel # skips some tests if it can't detect + flock # skips some tests if it can't detect + procps + ] ++ lib.optionals stdenv.isDarwin [ lsof ]; + inherit doInstallCheck; + installCheckPhase = '' + # TODO: cut if https://github.com/bats-core/bats-core/issues/418 allows + sed -i '/test works even if PATH is reset/a skip "disabled for nix build"' test/bats.bats - # skip tests that assume bats `install.sh` will be in BATS_ROOT - rm test/root.bats + # skip tests that assume bats `install.sh` will be in BATS_ROOT + rm test/root.bats - '' + (lib.optionalString stdenv.hostPlatform.isDarwin '' - # skip new timeout tests which are failing on macOS for unclear reasons - # This might relate to procps not having a pkill? - rm test/timeout.bats - '') + '' + '' + (lib.optionalString stdenv.hostPlatform.isDarwin '' + # skip new timeout tests which are failing on macOS for unclear reasons + # This might relate to procps not having a pkill? + rm test/timeout.bats + '') + '' - # test generates file with absolute shebang dynamically - substituteInPlace test/install.bats --replace \ - "/usr/bin/env bash" "${bash}/bin/bash" + # test generates file with absolute shebang dynamically + substituteInPlace test/install.bats --replace \ + "/usr/bin/env bash" "${bash}/bin/bash" - ${bats}/bin/bats test - touch $out - ''; - }); + ${bats}/bin/bats test + touch $out + ''; + }); + + # to see when updates would break things, include packages + # that use nixpkgs' bats for testing (as long as they + # aren't massive builds) + inherit bash-preexec locate-dominating-file packcc; + resholve = resholve.tests.cli; + } // lib.optionalAttrs (!stdenv.isDarwin) { + # TODO: kikit's kicad dependency is marked broken on darwin atm + # may be able to fold this up if that resolves. + inherit kikit; + }; meta = with lib; { homepage = "https://github.com/bats-core/bats-core"; diff --git a/pkgs/development/misc/resholve/test.nix b/pkgs/development/misc/resholve/test.nix index d9862bef7cf5..e9551b5be2a9 100644 --- a/pkgs/development/misc/resholve/test.nix +++ b/pkgs/development/misc/resholve/test.nix @@ -18,6 +18,7 @@ , gettext , rSrc , runDemo ? false +, fetchpatch , binlore , sqlite , unixtools @@ -122,6 +123,21 @@ rec { name = "resholve-test"; src = rSrc; + # TODO: should be removable on next resholve update--just + # temporarily work around test breaks caused by changes in + # bats 1.10.0. Since this is just about fixing tests, I'm + # patching test source to avoid going through staging. + patches = [ + (fetchpatch { + url = "https://github.com/abathur/resholve/commit/e1d6ccbc9cd5ec26122997610954dcb7d826f652.patch"; + hash = "sha256-XA9KUc/OAD2S8Vpt+C7KcjTP44rnZ4FLdgnnRqVWdWY="; + }) + (fetchpatch { + url = "https://github.com/abathur/resholve/commit/50db1a6a97baa7d7543a8abe33dddda62b487c65.patch"; + hash = "sha256-m1dKaLI02Wag7uacG4BkcdCXw30Kn6J4ydTqPd7bsak="; + }) + ]; + dontBuild = true; installPhase = ''