-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
[RFC] Use meta.tests
to link from packages to the tests that test them
#44439
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -250,6 +250,61 @@ meta.platforms = stdenv.lib.platforms.linux; | |
</para> | ||
</listitem> | ||
</varlistentry> | ||
<varlistentry> | ||
<term> | ||
<varname>tests</varname> | ||
</term> | ||
<listitem> | ||
<para> | ||
An attribute set with as values tests. A test is a derivation, which | ||
builds successfully when the test passes, and fails to build otherwise. A | ||
derivation that is a test requires some <literal>meta</literal> elements | ||
to be defined: <literal>needsVMSupport</literal> (automatically filled-in | ||
for NixOS tests) and <literal>timeout</literal>. | ||
</para> | ||
<para> | ||
The NixOS tests are available as <literal>nixosTests</literal> in | ||
parameters of derivations. For instance, the OpenSMTPD derivation | ||
includes lines similar to: | ||
<programlisting> | ||
{ /* ... */, nixosTests }: | ||
{ | ||
# ... | ||
meta.tests = { | ||
basic-functionality-and-dovecot-integration = nixosTests.opensmtpd; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this has been discussed before (can't find it with a quick skim), but is there a reason to make this a set instead of a simple list? I feel like having to give every test a new name only reduces redundancy. If there is additional information (like what exactly is tested in this case), maybe renaming the original test or a comment would be better? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had originally implemented this as a list, and @Profpatsch's comment (#44439 (comment)) made me notice it could be written as an attrset. At the time, it was a good thing, because tests needed to be Now that the tests are easily accessible from the fixpoint… I don't have any strong sentiment about it. @Profpatsch maybe has? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A list is kinda hard to work with, it can only be mapped over and replaced by an other list. There is no (sane) way to reference single elements in it. So if there should ever be the need to work with one of these tests especially (e.g. for overriding or removing it), you don’t have a good reference to work with (and no, the test’s name attribute is not a good reference). Same problem with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't like the "UX" of attribute sets here very much, but your argument makes sense. Using So as a summary I'm not quite happy but have no better idea. |
||
}; | ||
} | ||
</programlisting> | ||
</para> | ||
</listitem> | ||
</varlistentry> | ||
<varlistentry> | ||
<term> | ||
<varname>timeout</varname> | ||
</term> | ||
<listitem> | ||
<para> | ||
A timeout (in seconds) for building the derivation. If the derivation | ||
takes longer than this time to build, it can fail due to breaking the | ||
timeout. However, all computers do not have the same computing power, | ||
hence some builders may decide to apply a multiplicative factor to this | ||
value. When filling this value in, try to keep it approximately | ||
consistent with other values already present in | ||
<literal>nixpkgs</literal>. | ||
</para> | ||
</listitem> | ||
</varlistentry> | ||
<varlistentry> | ||
<term> | ||
<varname>needsVMSupport</varname> | ||
</term> | ||
<listitem> | ||
<para> | ||
A boolan that states whether the derivation requires build-time support | ||
for Virtual Machine to build successfully. | ||
</para> | ||
</listitem> | ||
</varlistentry> | ||
<varlistentry> | ||
<term> | ||
<varname>hydraPlatforms</varname> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,26 @@ with pkgs; | |
|
||
common-updater-scripts = callPackage ../common-updater/scripts.nix { }; | ||
|
||
### Push NixOS tests inside the fixed point | ||
|
||
nixosTests = | ||
let | ||
# TODO(Ericson2314,ekleog): Check this will work correctly with cross- | ||
system = builtins.currentSystem; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn’t work, I think. cc @Ericson2314 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really know: NixOS test derivations are supposed to be built on the local system, which I'd guess to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Ericson2314 ping :) (2 months sounds like a reasonable waiting time :p) |
||
rawTests = (import ../../nixos/release.nix { | ||
nixpkgs = pkgs; | ||
}).tests; | ||
testNames = builtins.attrNames rawTests; | ||
filteredList = builtins.filter | ||
(test: rawTests.${test} ? ${system}) | ||
testNames; | ||
finalList = map | ||
(test: { name = test; value = rawTests.${test}.${system}; }) | ||
filteredList; | ||
finalTests = builtins.listToAttrs finalList; | ||
in | ||
finalTests; | ||
|
||
### BUILD SUPPORT | ||
|
||
autoreconfHook = makeSetupHook | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably not be created, since this is already covered by the requiredFeatures of the derivation.