From 89858a803c85af42f9df8ae16bba4f6fd5ca9557 Mon Sep 17 00:00:00 2001 From: Bryan Gardiner Date: Thu, 27 Aug 2020 19:01:50 -0700 Subject: [PATCH] nixos/python-test-driver: add option to disable the linter without warning This follows up from nixpkgs#76171 to add a way to disable the linter for NixOS tests using the Python driver, without printing a warning to the console, as `skipLint` does. Linting is skipped if either `skipLint` or the new `skipLintSilently` option are true, but a warning about skipping is only printed if `skipLintSilently` is false. This is meant to allow running tests during development, or outside of Nixpkgs, without forcing unnecessary work to conform to a style guide when it's not relevant. --- nixos/lib/testing-python.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix index 4812567b8c62617..6ea89f6038ecb71 100644 --- a/nixos/lib/testing-python.nix +++ b/nixos/lib/testing-python.nix @@ -79,6 +79,8 @@ rec { , name ? "unnamed" # Skip linting (mainly intended for faster dev cycles) , skipLint ? false + # Skip linting without displaying a warning (do not use for tests in Nixpkgs) + , skipLintSilently ? false , ... } @ t: @@ -117,7 +119,9 @@ rec { # Generate convenience wrappers for running the test driver # interactively with the specified network, and for starting the # VMs from the command line. - driver = let warn = if skipLint then lib.warn "Linting is disabled!" else lib.id; in warn (runCommand testDriverName + driver = let + warn = if skipLint && !skipLintSilently then lib.warn "Linting is disabled!" else lib.id; + in warn (runCommand testDriverName { buildInputs = [ makeWrapper]; testScript = testScript'; preferLocalBuild = true; @@ -127,7 +131,7 @@ rec { mkdir -p $out/bin echo -n "$testScript" > $out/test-script - ${lib.optionalString (!skipLint) '' + ${lib.optionalString (!(skipLint || skipLintSilently)) '' ${python3Packages.black}/bin/black --check --diff $out/test-script ''}