about summary refs log tree commit diff
path: root/nixos/lib/testing-python.nix
AgeCommit message (Collapse)AuthorFilesLines
2021-06-18nixos/test-driver: Fix passing passthru attributeaszlig1-2/+2
Apparently this looks like it was forgotten when doing commit 3884ff70badca0c93c717e6190946a9a2846e948, which refactored the test runner and driver a bit. The passthru argument actually was correctly reintroduced in setupDriverForTest, but the actual makeTest function didn't use it. This fixes the nixpkgs tarball job, which previously failed with: attribute 'elkPackages' missing, at /build/source/pkgs/tools/misc/logstash/6.x.nix:58:30 Signed-off-by: aszlig <aszlig@nix.build> Acked-by: David Arnold <dar@xoe.solutions> Fixes: https://github.com/NixOS/nixpkgs/issues/127274 Merges: https://github.com/NixOS/nixpkgs/pull/127346
2021-06-13nixos/tests/test-driver: cleanup nix expressionDavid Arnold1-122/+135
Less nesting, where that improves readability. More nesteing, where that improves readability, but most importantly: Expose individual functions separately so that they can be more easily built directly, eg.: `nix build --impure --expr '(import ./testing-python.nix {system = builtins.currentSystem;}).mkTestDriver'`
2021-06-06nixos/tests/test-driver: cleanup "dead" code (USE_SERIAL)David Arnold1-2/+1
At nixpkgs root: `rg redirectSerial ./` does not result in any other match nor does `rg USE_SERIAL ./` except for an unrelated match in: pkgs/tools/graphics/argyllcms/default.nix
2021-06-03make-test-python: disallow aliasesFrederik Rietdijk1-1/+7
When importing Nixpkgs within Nixpkgs, we should not consider aliases to ensure we don't rely on them internally. There are probably more places that need to be converted.
2021-05-14nixos/testing: add interactive serial stdout logs switch and dim themDavid Arnold1-1/+1
2021-05-09nixos/testing-python.nix: Move makeWrapper to nativeBuildInputsRobert Hensing1-1/+1
2021-05-09nixos/testing: Set up scope for testScript linterRobert Hensing1-1/+16
Our test driver exposes a bunch of variables and functions, which pyflakes doesn't recognise by default because it assumes that the test script is executed standalone. In reality however the test driver script is using exec() on the testScript. Fortunately pyflakes has $PYFLAKES_BUILTINS, which are the attributes that are globally available on all modules to be checked. Since we only have one module, using this environment variable is fine as opposed to my first approach to this, which tried to use the unstable internal API of pyflakes. The attributes are gathered by the main derivation of the test driver, because we don't want to end up defining a new attribute in the test driver module just to being confused why using it in a test will result in an error. Another way we could have gathered these attributes would be in mkDriver, which is where the linting takes place. However, we do have a different set of Python dependencies in scope and duplicating these will again just cause confusion over having it at one location only. Signed-off-by: aszlig <aszlig@nix.build> Co-Authored-By: aszlig <aszlig@nix.build>
2021-05-09nixos/testing-python.nix: Expose driverRobert Hensing1-1/+3
(cherry picked from commit a2c9220568648b4528154ebd8e657add243ed0b4)
2021-05-09nixos/testing: Switch from black to pyflakesaszlig1-1/+1
So far, we have used "black" for formatting the test code, which is rather strict and opinionated and when used inline in Nix expressions it creates all sorts of trouble. One of the main annoyances is that when using strings coming from Nix expressions (eg. store paths or option definitions from NixOS modules), completely unrelated changes could cause tests to fail, since eg. black wants lines to be broken. Another downside of enforcing a certain kind of formatting is that it makes the Nix expression code inconsistent because we're mixing two spaces of indentation (common in nixpkgs) with four spaces of indentation as defined in PEP-8. While this is perfectly fine for standalone Python files, it really looks ugly and inconsistent IMO when used within Nix strings. What we actually want though is a linter that catches problems early on before actually running the test, because this is *actually* helping in development because running the actual VM test takes much longer. This is the reason why I switched from black to pyflakes, because the latter actually has useful checks, eg. usage of undefined variables, invalid format arguments, duplicate arguments, shadowed loop vars and more. Signed-off-by: aszlig <aszlig@nix.build> Closes: https://github.com/NixOS/nixpkgs/issues/72964
2021-05-03testing-python.nix: document runTests pos argumentRobert Hensing1-2/+7
2021-05-03Merge pull request #112504 from hercules-ci/fix-nixosTest-meta-positionRobert Hensing1-2/+9
nixosTest: fix meta.position
2021-04-28treewide: use lib.warnIf where appropriateAlyssa Ross1-3/+1
2021-03-23nixosTest: fix meta.positionRobert Hensing1-2/+9
2020-12-09nixos/lib/testing-python.nix: Wire up passthruRobert Hensing1-1/+4
2020-10-27nixos/tests: fix wrong inherit that passes on the nodes attrsAndreas Rammhold1-1/+1
The hydra tarball step would fail due to the nodes attribute not being properly inherited. Since we can't execute all the tests and release steps locally anymore (thanks to the JSONification and faster hydra eval) these errors will probably keep in appearing. This is hopefully the last of those introduced by me test runner refactoring. Error was seen on hydra (https://hydra.nixos.org/build/129282411): > unpacking sources > unpacking source archive /nix/store/bp95x52h6nv3j8apxrryyj2rviw682k1-source > source root is source > patching sources > autoconfPhase > No bootstrap, bootstrap.sh, configure.in or configure.ac. Assuming this is not an GNU Autotools package. > configuring > release name is nixpkgs-21.03pre249116.1088f059401 > git-revision is 1088f059401c43450ed85e4a4ec3f57dc8aa992f > building > no Makefile, doing nothing > running tests > warning: you did not specify '--add-root'; the result might be removed by the garbage collector > warning: you did not specify '--add-root'; the result might be removed by the garbage collector > checking Nixpkgs on i686-linux > checking Nixpkgs on x86_64-linux > checking Nixpkgs on x86_64-darwin > checking eval-release.nix > trace: `mkStrict' is obsolete; use `mkOverride 0' instead. > trace: `lib.nixpkgsVersion` is deprecated, use `lib.version` instead! > trace: warning: lib.readPathsFromFile is deprecated, use a list instead > trace: Warning: `showVal` is deprecated and will be removed in the next release, please use `traceSeqN` > trace: lib.zip is deprecated, use lib.zipAttrsWith instead > checking find-tarballs.nix > trace: `mkStrict' is obsolete; use `mkOverride 0' instead. > trace: `lib.nixpkgsVersion` is deprecated, use `lib.version` instead! > trace: warning: lib.readPathsFromFile is deprecated, use a list instead > trace: Warning: `showVal` is deprecated and will be removed in the next release, please use `traceSeqN` > trace: lib.zip is deprecated, use lib.zipAttrsWith instead > error: while evaluating anonymous function at /build/source/maintainers/scripts/find-tarballs.nix:6:1, called from undefined position: > while evaluating 'operator' at /build/source/maintainers/scripts/find-tarballs.nix:27:16, called from undefined position: > while evaluating 'immediateDependenciesOf' at /build/source/maintainers/scripts/find-tarballs.nix:39:29, called from /build/source/maintainers/scripts/find-tarballs.nix:27:44: > while evaluating anonymous function at /build/source/lib/attrsets.nix:234:10, called from undefined position: > while evaluating anonymous function at /build/source/maintainers/scripts/find-tarballs.nix:40:37, called from /build/source/lib/attrsets.nix:234:16: > while evaluating 'derivationsIn' at /build/source/maintainers/scripts/find-tarballs.nix:42:19, called from /build/source/maintainers/scripts/find-tarballs.nix:40:40: > while evaluating 'canEval' at /build/source/maintainers/scripts/find-tarballs.nix:48:13, called from /build/source/maintainers/scripts/find-tarballs.nix:43:9: > while evaluating the attribute 'nodes' at /build/source/nixos/lib/testing-python.nix:195:23: > attribute 'nodes' missing, at /build/source/nixos/lib/testing-python.nix:193:16 > build time elapsed: 0m0.122s 0m0.043s 17m51.526s 0m56.668s > builder for '/nix/store/96rk3c74vrk6m3snm7n6jhis3j640pn4-nixpkgs-tarball-21.03pre249116.1088f059401.drv' failed with exit code 1
2020-10-25nixos/tests: fix runInMachineAndreas Rammhold1-1/+1
In 5500dc8 we introduced the --keep-vm-state flag and defaulted to that flag not being set. This lead to the `runInMachine` tests not longer working and that going unnoticed for quite some time now.
2020-10-25nixos/tests: fix testDriver reference in runInMachine functionAndreas Rammhold1-1/+2
In a previous commit I broke this as there is no longer one testDriver but only a function to generate one based on some QEMU inputs.
2020-10-25nixos/tests: format the testing-python.nix file more consistenlyAndreas Rammhold1-98/+106
2020-10-25nixos/tests: restructure test driver so that QEMU is actually overridenAndreas Rammhold1-31/+48
Previously you would be able to override only the QEMU package to be used in the test runner. Frankly that doesn't help a lot if you are trying to get a graphical session. The graphical session requires the option in the NixOS module system to bet set to the correct QEMU package. In this commit I moved most of the test node configuration and transformations into the `mkDriver` function (previously called `driver`). The motivation was to be able to create a `driver` instance with a given QEMU package that will be used consistently througout the test expression.
2020-10-19nixos/tests: expose both the interactive and non-interactive driverAndreas Rammhold1-1/+2
For a lot of the work the non-interactive drivers are enough and it is probably a good idea to keep it accessible for debugging without touching the Nix expression.
2020-10-19nixos/tests: make the `driver` attribute use a rich qemuAndreas Rammhold1-6/+13
Since we previously stripped down the features of `qemu_test` some of the features users are used to while running tests through the (impure) driver didn't work anymore. Most notably we lost support for graphical output and audio. With this change the `driver` attribute uses are more feature complete version of QEmu compared to the one used in the pure Nix builds. This gives us the best of both worlds. Users are able to see the graphical windows of VMs while CI and regular nix builds do not have to download all the (unnecessary) dependencies.
2020-09-14nixos/testing: Add support for specialArgsJanne Heß1-1/+3
Since using flakes disallows the usage of <unstable> (which I use in some tests), this adds an alternative. By setting specialArgs, all VMs can get the `unstable` flake input as an arg. This is not possible with extraConfigurations, as that would lead to infinite recursions.
2020-09-05nixos/testing: remove remaining coverage-data logicFlorian Klink1-8/+1
This isn't used anymore as per https://github.com/NixOS/nixpkgs/pull/72354#discussion_r451031449.
2020-08-30Revert "Merge pull request #96254 from Mic92/logging"Anders Kaseorg1-1/+1
This reverts commit 4fc708567f6d9cf28f9ba426702069aa5a0b89c2, reversing changes made to 0e54f3a6d8393c31cfae43316904375dcfc77a46. Fixes #96699. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2020-08-25nixos/test-driver: switch to pythons' logging libJörg Thalheim1-1/+1
- Less code - more thread-safe according to @flokli
2020-06-30testing-python: fix typoAlexandre Esteves1-1/+1
2020-05-14Remove unused filesEelco Dolstra1-5/+1
2020-05-07testing{-python}.nix: Remove log pretty-printing cruftEelco Dolstra1-16/+2
This completes the removal of the nested log feature, which previously got removed from Nix, Hydra, stdenv and GNU Make. In particular, this means that the output of VM builds no longer contains a copy of jQuery.
2020-03-13nixos/python-test-driver: allow single char as hostName and fix misleading ↵Maximilian Bosch1-2/+2
error-message In case of invalid chars, the error-message references "perl variables" which is not the case here as the python-based framework is used.
2020-02-09testing-python: readd auto displayManagerworldofpeace1-1/+4
we import it for the runInMachineWithX
2020-02-09testing-python: fix runInMachineworldofpeace1-5/+5
The test script's were unported. It's unclear whether the preBuild or postBuild will work as expect, due to the linting of the test scripts.
2020-01-14test-driver.py: specify coreutils dependencyErik Arvstedt1-1/+1
Otherwise the driver script fails when coreutils are not in PATH.
2019-12-22nixos/python-test-driver: add an option to disable python linterMaximilian Bosch1-3/+7
While it's a good idea to automate the linting of the python code used for our tests, I think that it can be quite distracting when hacking on a NixOS test. I figured that it might be more convenient to add an option as a shortcut for this to avoid that everyone needs to dig into the test driver again.
2019-12-15nixos/displayManager: deprecate separate options for default wm/dmJan Tojnar1-2/+1
The upstream session files display managers use have no concept of sessions being composed from desktop manager and window manager. To be able to set upstream session files as default session, we need a single option. Having two different ways to set default session would be confusing, though, so we decided to deprecate the old method. We also created separate script for each session, just like we already had a separate desktop file for each one, and started using displayManager.sessionPackages mechanism to make the session handling more uniform.
2019-11-15Merge pull request #73251 from worldofpeace/remove-slimworldofpeace1-1/+0
nixos/slim: remove
2019-11-11nixos/slim: removeworldofpeace1-1/+0
The SLIM project is abandoned and their last release was in 2013. Because of this it poses a security risk to systems, no one is working on it or picked up maintenance. It also lacks compatibility with systemd and logind sessions. For users, there liikely isn't anything like slim that's as lightweight in terms of dependencies.
2019-11-11test-driver: add mypy supportJörg Thalheim1-1/+4
It's a good idea to expand this in future to test code as well, so we get type checking there as well.
2019-11-04nixos/test: use ptpython as replFlorian Klink1-1/+1
2019-11-04nixos/test: Port test driver to pythonJacek Galowicz1-0/+279
Thanks @blitz and @jtraue for help with implementing machine methods