tests: split into a separate all-tests.nix file

This will make the list much easier to re-use, eg. for `nixosTests`

The drawback is that this approaches makes the
```
nix-build release.nix -A tests.opensmtpd.x86_64-linux
```
command about twice as slow (3s to 6s): it now has to evaluate `nixpkgs`
once for each architecture, instead of just having the hardcoded list of
tests that allowed to say “ok just evaluate for x86_64-linux”.

On the other hand, complete evaluation of `release.nix` should be much
faster because we no longer import `nixpkgs` for each test: testing with
the following command went from 30s to 18s, and that's just for a few
tests.
```
time nix-instantiate --eval --strict nixos/release.nix -A tests.nat
```
I initially wanted to test on the whole `release.nix`, but there are too
many broken tests and it takes too long to eval them all, especially
compared to the fact that the current implementation breaks some setup.

Given developers can just `nix-build nixos/tests/my-test.nix`, it sounds
like an overall win.
This commit is contained in:
Léo Gaspard
2018-11-11 23:11:46 +09:00
parent 6c68fbd4e1
commit 83b27f60ce
3 changed files with 232 additions and 218 deletions
+4 -2
View File
@@ -168,9 +168,11 @@ let
# TODO: refactor once something like Profpatsch's types-simple will land
tests = attrsOf (mkOptionType {
name = "test";
check = x: isDerivation x &&
check = x: x == {} || ( # Accept {} for tests that are unsupported
isDerivation x &&
x ? meta.timeout &&
x ? meta.needsVMSupport;
x ? meta.needsVMSupport
);
merge = lib.options.mergeOneOption;
});
needsVMSupport = bool;