-
-
Notifications
You must be signed in to change notification settings - Fork 16.5k
lib.tests.modules: create nix-unit test scaffolding #381342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
I'd like to provide some insights why we think using
Those and further benefits can also be found on the project page: https://github.com/nix-community/nix-unit |
We currently run the suite against multiple Nix versions. If we have a pairing of
Does that include intermediate values, like the whole |
Another thing is that in the test suite we often use the same module for multiple assertions. # group for a specific but large module
intTypes =
let
inherit (evalModules ...) config;
in
{
# test cases for each assertion
negativeInt = ... config.negativeInt ...;
}; Now I'm not sure that this is even the right pattern, as it's probably better to keep the test cases small and focused, so I guess that's something to pay attention to. |
This could be done by having version conditionals using That way the existing |
c3e211a
to
973e8ce
Compare
I just pushed a commit with all tests translated. While doing so i didn't change any of the tests although there where about 10 that had minor discrepancies in the regex behavior. We can see that translation is relatively trivial and that the result is absolutely identical. Despite we lack the ability for now to test against different nix versions.
Pros:
Cons:
Maybe we can find a suitable way of providing nix-unit with more than one nix version. |
3 of them are currently being tested: Line 8 in 78fdbc7
I think this is really neat overall, but testing with multiple Nix versions is fairly important. However I think it would be fine to drop |
@infinisil looking at the bigger picture, don't we want to use this infrastructure for all of lib's unit tests? Relatedly, we should certainly add the NixOS-stable default version as well. I believe that might currently coincide with |
Things done
Together with @hsjobeki at thaigersprint
EDIT by @hsjobeki together with @infinisil :
Plan to move on:
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.
cc Thaigersprint/thaigersprint-2025#1