-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Reworking test infrastructure #18142
Conversation
@ericsagnes, thanks for your PR! By analyzing the annotation information on this pull request, we identified @edolstra, @aszlig and @kampfschlaefer to be potential reviewers |
064ea6f
to
ef748d4
Compare
Cool, this was something on my TODO list for quite a while. I already have an implementation of this in vuizvui for machine-dependant tests: https://github.com/openlab-aux/vuizvui/blob/master/modules/core/tests.nix Having tests in within the meta attributes however won't help for machine-related tests (I'm building channels based on which settings are enabled in the machine configuration) so maybe it's a better idea to add them as a module option. Which benefit does it have if the tests are defined in the meta attributes? |
5226884
to
181bf34
Compare
Thanks for looking at this!
The benefits I can see of having the tests in meta are:
To be honest I haven't thought at all about machine-related tests for this. One approach I can think of (no idea if it is realistic or not), would be to define a function Test pseudo code: { pkgs, ... } :
{
name = "foo";
relevant = config:
config.services.httpd.enable && elem "proxy_balancer" config.services.httpd.extraModules;
nodes = {
# ...
};
testScript = ''
...
'';
}
dummyAttrs = { ... };
moduleTests = (import lib/eval-config.nix { modules = []; }).config.meta.tests;
relevantTests = config: filterAttrs (k: v: (v dummyAttrs).relevant config) moduleTests;
testsForMachineA = relevantTests machineAConfig; |
006b21f
to
ade56f4
Compare
Update: Added a few commits and updated the PR description. |
ade56f4
to
82e8342
Compare
3315471
to
1fa1e12
Compare
Update The PR is almost complete functionality wise, from now I am just planning to test and fix any problems that could rise without changing much of its logic. It changed a lot since its creation so please take the time to read the updated description. As this contains some changes that could be considered controversial (see description for a list) and touch a wide range of files, I am very interested in getting some feedback. Especially from @edolstra and @aszlig as they are the main contributors to the current test infrastructure and @domenkozar and @joachifm as they were interested by the concept. Thank you! |
4ab6f6e
to
6f0ee57
Compare
The downside of this is that once modules are refactored it's very likely that people forget to adapt the test definitions. In Of course this has the downside that it's no longer that easy to enumerate all tests, except by using a dummy config that enables all modules with tests. Another thing I'm interested is having NixOS tests for normal packages, like for example for Chromium. Possibly also tied to whether such a package is defined in
Why would one need to declare an option for a test? |
Also, I'd rename |
If that breaks tests for some, they will fix the definitions.
Actually, now that tests files can be moved around easily, I was thinking to move packages related tests in packages meta and closer to packages files in a second phase.
Sorry, I was a little fast on reading your config. No, there is no need for that. Anyway, the original goal of this PR was to tie modules and tests together so modules and tests maintainership can be improved. But let me know if you think that some changes this PR brings would make a future implementation machine-dependent testing difficult, I would be very happy to fix these.
I was hesitating on this point, |
72064a0
to
6c36d4e
Compare
Blacklists the module tests that were not originally in release.nix.
18c6bc0
to
bbd357b
Compare
@ericsagnes Does it just smell funny or is it dead? |
@ericsagnes Are you still willing to push this forward? If not, given how badly this appears to have bitrotten, maybe it would make sense to open an issue with the changes you tried to do (from a quick read, replace in-file |
Are there any updates on this pull request, please? |
Instead of #44439 The testing situation has also changed lastly. Module tests have been rewritten in Python. Package tests are possible now. @ericsagnes can you create individual issues or PRs for the changes that are still missing? |
Updated the PR description and title on 2016/09/03 according to current state.
Motivation for this change
This PR has the following goals:
callTest
andnix-run-test
)Main improvements
make-test.nix
anymore, and can be run from anywherenix-run-test
commandcallTest
tolib
, so it can easily be called from custom projectsChanges
meta.tests
attribute to modulescallTest
function that has a wider use range than the previous onecallTest
,callSubTests
as their functionality is superseded by the newcallTest
callTest
tolib.testing
so it can easily be called from other places thanrelease.nix
meta.tests
attributestests.module
subset ofrelease.nix
makeTest
in test files, test files should be a test set, a set of test sets, or a test derivationnixos/lib
, namelytest-driver/*
andtesting.nix
, are relocated inlib/testing
nix-run-test
command had been added to run test in an easy waynixos/tests/make-test.nix
Possibly controversial changes
callTest
,callSubTests
as their functionality is superseded by the newcallTest
nixos/lib
, namelytest-driver/*
andtesting.nix
, are relocated inlib/testing
nixos/tests/make-test.nix
How it works
modules
meta.tests
is a new attribute of modules that takes a set of tests.Key is the set name, value is the test file, eg:
release.nix
In
release.nix
, module tests are gathered with themoduleTests
function, and added in thetests.module
set.Problematic tests can be blacklisted by adding their name to the
blacklistedModuleTests
list.Module tests can be run like any other tests, eg:
The
moduleTests
accept a set argument to set arguments on dedicated tests if needed.callTest
callTest
has been reworked to accept test sets, set of tests sets or test derivations.Also, there is no need to use
makeTest
in the test files anymore.A new
lib
subset,lib.testing
was added.lib.testing
expose only thecallTest
function.This change make
callTest
a part oflib
, so it can be called from places other thanrelease.nix
, examples:a. Call a test:
b. Call a test for only x86_64-linux:
c. Call a test with custom parameters:
nix-run-test
nix-run-test
, a new utility to run nix tests has been added. It is just a wrapper aroundnix-build
andcallTest
to run tests in an easy manner.a. Call a test:
b. Prepare an interactive test:
TODO
Things done
(nix.useChroot on NixOS,
or option
build-use-chroot
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)