diff options
author | Robert Helgesson <robert@rycee.net> | 2020-05-28 01:24:49 +0200 |
---|---|---|
committer | Robert Helgesson <robert@rycee.net> | 2020-05-28 01:37:27 +0200 |
commit | 8bbefa77f7e95c80005350aeac6fe425ce47c288 (patch) | |
tree | cfff10e2b832121c36e8ef737429e18d4c45100d /tests/meta | |
parent | 3a80ece9fa0de388ad27503059f7856c9315d491 (diff) |
tests: perform code formatting test in test suite
This should improve visibility when CI job fails due to bad
formatting.
Diffstat (limited to 'tests/meta')
-rw-r--r-- | tests/meta/default.nix | 1 | ||||
-rw-r--r-- | tests/meta/formatting.nix | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/meta/default.nix b/tests/meta/default.nix new file mode 100644 index 00000000000..0f02fcfb453 --- /dev/null +++ b/tests/meta/default.nix @@ -0,0 +1 @@ +{ meta-formatting = ./formatting.nix; } diff --git a/tests/meta/formatting.nix b/tests/meta/formatting.nix new file mode 100644 index 00000000000..2d5800c53cd --- /dev/null +++ b/tests/meta/formatting.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + pinnedNixpkgs = builtins.fetchTarball { + url = + "https://github.com/NixOS/nixpkgs/archive/05f0934825c2a0750d4888c4735f9420c906b388.tar.gz"; + sha256 = "1g8c2w0661qn89ajp44znmwfmghbbiygvdzq0rzlvlpdiz28v6gy"; + }; + + pinnedPkgs = import pinnedNixpkgs { }; + +in { + config = { + nmt.script = '' + PATH="${with pinnedPkgs; lib.makeBinPath [ findutils nixfmt ]}:$PATH" + cd ${../..} + if ! ${pkgs.runtimeShell} format -c; then + fail "${'' + Expected source code to be formatted with nixfmt but it was not. + This error can be resolved by running the './format' in the project root directory.''}" + fi + ''; + }; +} |