From e0f9929a6940eaaf9b30a2201c3c4afe7c6c50a8 Mon Sep 17 00:00:00 2001 From: "Travis A. Everett" Date: Sat, 13 Apr 2024 12:34:27 -0500 Subject: [PATCH 1/4] resholve: patch test breaks coming in bats 1.11 I'm preparing to update bats to 1.11.0, but a change it includes will require updating 3 of resholve's tests. Since a full resholve source bump would need to go through staging now, I'm just patching the tests in the separate test derivation. --- pkgs/development/misc/resholve/test.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 = '' From bb0331762d4c08afe762708dc706cc5ead98a459 Mon Sep 17 00:00:00 2001 From: "Travis A. Everett" Date: Sat, 13 Apr 2024 12:51:13 -0500 Subject: [PATCH 2/4] bats: reformat passthru.tests Upcoming commit will add packages that use bats to passthru.tests, which is a little more clear when this is one attrset. Splitting this format-only change out for easier review. --- .../development/interpreters/bats/default.nix | 122 +++++++++--------- 1 file changed, 62 insertions(+), 60 deletions(-) diff --git a/pkgs/development/interpreters/bats/default.nix b/pkgs/development/interpreters/bats/default.nix index afffef1d1f68..3828ed8a0968 100644 --- a/pkgs/development/interpreters/bats/default.nix +++ b/pkgs/development/interpreters/bats/default.nix @@ -134,78 +134,80 @@ 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 + ''; + }); + }; meta = with lib; { homepage = "https://github.com/bats-core/bats-core"; From 7fb2aab0151067b4df1d374707d158254c63c6ec Mon Sep 17 00:00:00 2001 From: "Travis A. Everett" Date: Sat, 13 Apr 2024 12:58:44 -0500 Subject: [PATCH 3/4] bats: add bats-tested packages to passthru.tests It would have been ~easy for someone to update bats without noticing whether the update broke any packages that depend directly on the nixpkgs-packaged bats for their tests. (I'm phrasing this tediously because there are also some packages that vendor a copy of bats.) Hopefully this will make it easier to confirm future updates. --- pkgs/development/interpreters/bats/default.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkgs/development/interpreters/bats/default.nix b/pkgs/development/interpreters/bats/default.nix index 3828ed8a0968..8591552d45dd 100644 --- a/pkgs/development/interpreters/bats/default.nix +++ b/pkgs/development/interpreters/bats/default.nix @@ -18,6 +18,11 @@ , makeWrapper , runCommand , doInstallCheck ? true +# packages that use bats (for update testing) +, bash-preexec +, kikit +, locate-dominating-file +, packcc }: resholve.mkDerivation rec { @@ -207,6 +212,16 @@ resholve.mkDerivation rec { 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; { From 1f9a9252a7f268cc05066d5ee2e2793ecf2ebdb4 Mon Sep 17 00:00:00 2001 From: "Travis A. Everett" Date: Sat, 13 Apr 2024 13:09:17 -0500 Subject: [PATCH 4/4] bats: 0.10.0 -> 0.11.0 Also conditionally excludes pkill from resolution on macOS, since the procps package should contain pkill on other platforms. --- pkgs/development/interpreters/bats/default.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkgs/development/interpreters/bats/default.nix b/pkgs/development/interpreters/bats/default.nix index 8591552d45dd..cbb490615b7d 100644 --- a/pkgs/development/interpreters/bats/default.nix +++ b/pkgs/development/interpreters/bats/default.nix @@ -27,13 +27,13 @@ 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 = '' @@ -69,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 = { @@ -99,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 = [ /* @@ -115,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" ]; }; };