-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
Closed
Labels
0.kind: enhancementAdd something new or improve an existing system.Add something new or improve an existing system.6.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: testingTooling for automated testing of packages and modulesTooling for automated testing of packages and modules9.needs: documentationThis needs to be documented well.This needs to be documented well.
Description
We have documentation on how to write NixOS (module) tests.
But how to write tests for packages?
I asked on IRC and got some helpful informations:
<davidak> are the nixos tests also intended for applications or only for nixos modules? there is for example chromium and fish, but mostly modules
<davidak> i want to add tests for my cli application packages
<gchristensen> they have a very high cost to run
<clever> davidak: for cli apps, its usually simpler to just put it into the derivation, as a checkPhase
<clever> i think the only reason things like chromium are in a nixos test, is because it needs X11 to test
<clever> so chromium itself isnt a module, but it relies on a module to start
...
<davidak> clever, this is a nice simple example of a test every program should have https://github.com/NixOS/nixpkgs/blob/076860e0340a5e4a909b9a710e186508b14d1c90/pkgs/development/tools/scalafix/default.nix#L34
<davidak> clever, eny idea how to test programs that connect to the intenet like `tldr --update`
<clever> davidak: the internet is disabled during all testing
<davidak> clever, so the answer ist "we can't test such cases"? that would be bad :/
gchristensen> we can't actually
<clever> davidak: what exactly is it fetching from the internet? could you fake it with an nginx server and /etc/hosts?
<davidak> i think it clones a git repo or download some archive
* mananamenos has quit (Ping timeout: 240 seconds)
<davidak> with that method it would need a nixos module test, but i think that's too costly for such a small program just a few people use
So my goal with this issue is to get this information documented.
- explain the difference between NixOS module tests and package tests
- explain when to use which
- link to good examples for both
- create one example for a module test with nginx to test a package that needs internet access to download stuff
We maybe have to decide on a policy when a test should be added and when not (e.g. it's not important enough to use costly module tests)
Related issues:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
0.kind: enhancementAdd something new or improve an existing system.Add something new or improve an existing system.6.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: testingTooling for automated testing of packages and modulesTooling for automated testing of packages and modules9.needs: documentationThis needs to be documented well.This needs to be documented well.