From 9aa588ecc394f140681a0d68b635b3cf45ade411 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Thu, 14 Jul 2022 11:57:37 +0200 Subject: [PATCH] nixos/documentation: Add unit test --- .../misc/documentation/test-dummy.chapter.xml | 0 nixos/modules/misc/documentation/test.nix | 49 +++++++++++++++++++ nixos/tests/all-tests.nix | 1 + 3 files changed, 50 insertions(+) create mode 100644 nixos/modules/misc/documentation/test-dummy.chapter.xml create mode 100644 nixos/modules/misc/documentation/test.nix diff --git a/nixos/modules/misc/documentation/test-dummy.chapter.xml b/nixos/modules/misc/documentation/test-dummy.chapter.xml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/nixos/modules/misc/documentation/test.nix b/nixos/modules/misc/documentation/test.nix new file mode 100644 index 000000000000..1eaa63b1fb6c --- /dev/null +++ b/nixos/modules/misc/documentation/test.nix @@ -0,0 +1,49 @@ +{ nixosLib, pkgsModule, runCommand }: + +let + sys = nixosLib.evalModules rec { + modules = [ + pkgsModule + ../documentation.nix + ../version.nix + + ({ lib, someArg, ... }: { + # Make sure imports from specialArgs are respected + imports = [ someArg.myModule ]; + + # TODO test this + meta.doc = ./test-dummy.chapter.xml; + }) + + { + _module.args = { + baseModules = [ + ../documentation.nix + ../version.nix + ]; + extraModules = [ ]; + inherit modules; + }; + documentation.nixos.includeAllModules = true; + } + ]; + specialArgs.someArg.myModule = { lib, ... }: { + options.foobar = lib.mkOption { + type = lib.types.str; + description = "The foobar option was added via specialArgs"; + default = "qux"; + }; + }; + }; + +in +runCommand "documentation-check" +{ + inherit (sys.config.system.build.manual) optionsJSON; +} '' + json="$optionsJSON/share/doc/nixos/options.json" + echo checking $json + + grep 'The foobar option was added via specialArgs' <"$json" >/dev/null + touch $out +'' diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 5164451cbe03..7602bc04cfe2 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -127,6 +127,7 @@ in { docker-tools-cross = handleTestOn ["x86_64-linux" "aarch64-linux"] ./docker-tools-cross.nix {}; docker-tools-overlay = handleTestOn ["x86_64-linux"] ./docker-tools-overlay.nix {}; documize = handleTest ./documize.nix {}; + documentation = pkgs.callPackage ../modules/misc/documentation/test.nix { inherit nixosLib; }; doh-proxy-rust = handleTest ./doh-proxy-rust.nix {}; dokuwiki = handleTest ./dokuwiki.nix {}; domination = handleTest ./domination.nix {};