diff --git a/.circleci/config.yml b/.circleci/config.yml index 8e90039aa96e073bf6c44aa887313316a69a5f13..e115cfd6b5f55882cbc3e0479d081f8f8edf143b 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 f424434d5fbde88b90588b25ecef9ef851d453bf..593f721975ada41aeb45fd05c8f163be280f01d7 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 ''