From d424b51d945cf7b97431c85610169f5fd3b56828 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone <exarkun@twistedmatrix.com> Date: Wed, 7 Aug 2019 12:14:03 -0400 Subject: [PATCH] Some reporting for the success case --- .circleci/config.yml | 2 +- nixos/tests.nix | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8e90039a..e115cfd6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,7 +40,7 @@ jobs: - run: name: "Run Tests" command: | - nix-build nixos/tests.nix + nix-build nixos/tests.nix && cat result build: docker: diff --git a/nixos/tests.nix b/nixos/tests.nix index f424434d..593f7219 100644 --- a/nixos/tests.nix +++ b/nixos/tests.nix @@ -2,6 +2,9 @@ let pkgs = import <nixpkgs> { }; + # Total the numbers in a list. + sum = builtins.foldl' (a: b: a + b) 0; + # A helper for loading tests. loadTest = moduleUnderTest: testModule: (import testModule (pkgs.callPackage moduleUnderTest { })); @@ -12,11 +15,17 @@ let [ (loadTest ./lib/ini.nix ./lib/tests/test_ini.nix) ]; + # Count up the tests we're going to run. + numTests = sum (map (s: builtins.length (builtins.attrNames s)) testModules); + + # Convert it into a string for interpolation into the shell script. + numTestsStr = builtins.toString numTests; + # Run the tests and collect the failures. failures = map pkgs.lib.runTests testModules; # Count the number of failures in each module. - numFailures = builtins.foldl' (a: b: a + b) 0 (map builtins.length failures); + numFailures = sum (map builtins.length failures); # Convert the total into a string for easy interpolation into the shell script. numFailuresStr = builtins.toString (numFailures); @@ -30,6 +39,6 @@ if [ ${numFailuresStr} -gt 0 ]; then echo '${failuresStr}' exit 1 else - echo 'OK' > $out + echo '${numTestsStr} tests OK' > $out fi '' -- GitLab