Skip to content

Commit

Permalink
Merge pull request #330434 from ShamrockLee/test-overriding-attrs
Browse files Browse the repository at this point in the history
tests.overriding: structure tests as an attribut set
  • Loading branch information
roberth authored Jul 28, 2024
2 parents 36c226b + fdd1672 commit 70d94d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2411.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
Refer to upstream [upgrade instructions](https://goteleport.com/docs/management/operations/upgrading/)
and [release notes for v16](https://goteleport.com/docs/changelog/#1600-061324).

- `tests.overriding` has its `passthru.tests` restructured as an attribute set instead of a list, making individual tests accessible by their names.

- `vaultwarden` lost the capability to bind to privileged ports. If you rely on
this behavior, override the systemd unit to allow `CAP_NET_BIND_SERVICE` in
your local configuration.
Expand Down
30 changes: 13 additions & 17 deletions pkgs/test/overriding.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,29 @@ let
let
p = pkgs.python3Packages.xpybutil.overridePythonAttrs (_: { dontWrapPythonPrograms = true; });
in
[
({
name = "overridePythonAttrs";
{
overridePythonAttrs = {
expr = !lib.hasInfix "wrapPythonPrograms" p.postFixup;
expected = true;
})
({
name = "repeatedOverrides-pname";
};
repeatedOverrides-pname = {
expr = repeatedOverrides.pname == "a-better-hello-with-blackjack";
expected = true;
})
({
name = "repeatedOverrides-entangled-pname";
};
repeatedOverrides-entangled-pname = {
expr = repeatedOverrides.entangled.pname == "a-better-figlet-with-blackjack";
expected = true;
})
({
name = "overriding-using-only-attrset";
};
overriding-using-only-attrset = {
expr = (pkgs.hello.overrideAttrs { pname = "hello-overriden"; }).pname == "hello-overriden";
expected = true;
})
({
};
overriding-using-only-attrset-no-final-attrs = {
name = "overriding-using-only-attrset-no-final-attrs";
expr = ((stdenvNoCC.mkDerivation { pname = "hello-no-final-attrs"; }).overrideAttrs { pname = "hello-no-final-attrs-overridden"; }).pname == "hello-no-final-attrs-overridden";
expected = true;
})
];
};
};

addEntangled = origOverrideAttrs: f:
origOverrideAttrs (
Expand Down Expand Up @@ -62,5 +58,5 @@ stdenvNoCC.mkDerivation {
passthru = { inherit tests; };
buildCommand = ''
touch $out
'' + lib.concatMapStringsSep "\n" (t: "([[ ${lib.boolToString t.expr} == ${lib.boolToString t.expected} ]] && echo '${t.name} success') || (echo '${t.name} fail' && exit 1)") tests;
'' + lib.concatStringsSep "\n" (lib.attrValues (lib.mapAttrs (name: t: "([[ ${lib.boolToString t.expr} == ${lib.boolToString t.expected} ]] && echo '${name} success') || (echo '${name} fail' && exit 1)") tests));
}

0 comments on commit 70d94d8

Please sign in to comment.