-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Tracking: migrate NixOS handleTest -> runTest #386873
Copy link
Copy link
Open
Labels
11.by: package-maintainerThis PR was created by a maintainer of all the package it changes.This PR was created by a maintainer of all the package it changes.3.skill: good-first-bugThis seems like it's fixable by a non-expertThis seems like it's fixable by a non-expert3.skill: trivialThis is trivial to complete (typically find-and-replace)This is trivial to complete (typically find-and-replace)5.scope: trackingLong-lived issue tracking long-term fixes or multiple sub-problemsLong-lived issue tracking long-term fixes or multiple sub-problems6.topic: darwinRunning or building packages on DarwinRunning or building packages on Darwin6.topic: developer experiencenixpkgs development workflownixpkgs development workflow6.topic: hygieneCleaning up and removing cruftCleaning up and removing cruft6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOSIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS6.topic: portabilityGeneral portability concerns, not specific to cross-compilation or a specific platformGeneral portability concerns, not specific to cross-compilation or a specific platform6.topic: testingTooling for automated testing of packages and modulesTooling for automated testing of packages and modules
Metadata
Metadata
Assignees
Labels
11.by: package-maintainerThis PR was created by a maintainer of all the package it changes.This PR was created by a maintainer of all the package it changes.3.skill: good-first-bugThis seems like it's fixable by a non-expertThis seems like it's fixable by a non-expert3.skill: trivialThis is trivial to complete (typically find-and-replace)This is trivial to complete (typically find-and-replace)5.scope: trackingLong-lived issue tracking long-term fixes or multiple sub-problemsLong-lived issue tracking long-term fixes or multiple sub-problems6.topic: darwinRunning or building packages on DarwinRunning or building packages on Darwin6.topic: developer experiencenixpkgs development workflownixpkgs development workflow6.topic: hygieneCleaning up and removing cruftCleaning up and removing cruft6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOSIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS6.topic: portabilityGeneral portability concerns, not specific to cross-compilation or a specific platformGeneral portability concerns, not specific to cross-compilation or a specific platform6.topic: testingTooling for automated testing of packages and modulesTooling for automated testing of packages and modules
Fields
Give feedbackNo fields configured for issues without a type.
What
nixos/all-tests.nixto userunTestinstead ofhandleTest.Why
Benefits of runTest and runTestOn:
pkgsinstanceHow
Many tests are trivial to migrate, but here's the complete guide, also available in a comment in
all-tests.nix.Testing the darwin support is optional and largely unnecessary.
Changes required to migrate to runTest:
Remove any
import ../make-test-python.nixor similar calls, leaving onlythe callback function.
Convert the function header to make it a module.
Packages can be taken from the following. For VM host portability, use
config.node.pkgs.<name>orconfig.nodes.foo.nixpkgs.pkgs.<name>to referto the Nixpkgs used on the VM guest(s).
hostPkgs.<name>when invoking commands on the VM host (e.g. in Pythonos.system("foo"))Since the runTest argument is a module instead of a function, arguments
must be passed as option definitions.
You may declare explicit
optionsfor the test parameter(s), or use theless explicit
_module.args.<name>to pass arguments to the module.Example call with arguments:
If your test requires any definitions in
nixpkgs.*options, setnode.pkgsReadOnly = falsein the test configuration.Test matrix
Pass the
runTestfunction into the test file and use it instead ofmake-test-python.nixor similar.Context
Written as a Nixpkgs maintainer, nothing special.