Skip to content
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

passthru.tests but for modules #148364

Open
roberth opened this issue Dec 3, 2021 · 0 comments
Open

passthru.tests but for modules #148364

roberth opened this issue Dec 3, 2021 · 0 comments
Labels
0.kind: enhancement 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: developer experience 6.topic: module system About NixOS module system internals 6.topic: nixos 6.topic: testing Tooling for automated testing of packages and modules

Comments

@roberth
Copy link
Member

roberth commented Dec 3, 2021

Describe the problem

  • Connection between module and test is not always clear.
  • It's unclear how to test without VM tests. Some modules can and should be unit tested.
  • No way of figuring out which tests are relevant for a given configuration

Proposal

Use the module meta attribute to determine which tests exists and are applicable.

A new option in meta could work similar to the meta.maintainers module option in that it preserves the path of the defining module(s), which could be helpful for assigning unique names. Alternatively, we could just require module authors to enter a unique name for each test.

{ config, pkgs, ... }:
{
  imports = [ ];
  options = { };
  config = { };
  meta.maintainers = [ ]; # already exists
  meta.tests.foo = pkgs.callPackage ./test.nix { };
}

The last item, "No way of figuring out which tests are relevant for a given configuration" also needs a minimal module list in order to make this solution work. Otherwise, you'll always get all the tests.

Notify maintainers

Metadata

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
@roberth roberth added 0.kind: enhancement 6.topic: nixos 6.topic: developer experience 6.topic: testing Tooling for automated testing of packages and modules 6.topic: module system About NixOS module system internals labels Dec 3, 2021
@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: developer experience 6.topic: module system About NixOS module system internals 6.topic: nixos 6.topic: testing Tooling for automated testing of packages and modules
Projects
None yet
Development

No branches or pull requests

1 participant