about summary refs log tree commit diff
path: root/nix/runTestsuite
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-01-30T16·06+0300
committertazjin <tazjin@tvl.su>2022-01-31T16·11+0000
commitaa122cbae78ce97d60c0c98ba14df753d97e40b1 (patch)
tree12b98d85c4b18fe870feb26de70db9ba61837bd7 /nix/runTestsuite
parent2d10d60fac0fd00a71b65cfdcb9fba0477b2086c (diff)
style: format entire depot with nixpkgs-fmt r/3723
This CL can be used to compare the style of nixpkgs-fmt against other
formatters (nixpkgs, alejandra).

Change-Id: I87c6abff6bcb546b02ead15ad0405f81e01b6d9e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4397
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: lukegb <lukegb@tvl.fyi>
Reviewed-by: wpcarro <wpcarro@gmail.com>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Reviewed-by: tazjin <tazjin@tvl.su>
Reviewed-by: cynthia <cynthia@tvl.fyi>
Reviewed-by: edef <edef@edef.eu>
Reviewed-by: eta <tvl@eta.st>
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'nix/runTestsuite')
-rw-r--r--nix/runTestsuite/default.nix76
1 files changed, 48 insertions, 28 deletions
diff --git a/nix/runTestsuite/default.nix b/nix/runTestsuite/default.nix
index 9eb507099678..8b02ed86d8ea 100644
--- a/nix/runTestsuite/default.nix
+++ b/nix/runTestsuite/default.nix
@@ -38,11 +38,11 @@ let
     ;
 
   bins = depot.nix.getBins pkgs.coreutils [ "printf" ]
-      // depot.nix.getBins pkgs.s6-portable-utils [ "s6-touch" "s6-false" "s6-cat" ];
+    // depot.nix.getBins pkgs.s6-portable-utils [ "s6-touch" "s6-false" "s6-cat" ];
 
   # Returns true if the given expression throws when `deepSeq`-ed
   throws = expr:
-    !(builtins.tryEval (builtins.deepSeq expr {})).success;
+    !(builtins.tryEval (builtins.deepSeq expr { })).success;
 
   # rewrite the builtins.partition result
   # to use `ok` and `err` instead of `right` and `wrong`.
@@ -99,11 +99,12 @@ let
     (context: desc: res:
       if res
       then { yep = { test = desc; }; }
-      else { nope = {
-        test = desc;
-        inherit context;
-      };
-    });
+      else {
+        nope = {
+          test = desc;
+          inherit context;
+        };
+      });
 
   # assert that left and right values are equal
   assertEq = defun [ string any any AssertResult ]
@@ -111,7 +112,7 @@ let
       let
         context = { not-equal = { inherit left right; }; };
       in
-        assertBoolContext context desc (left == right));
+      assertBoolContext context desc (left == right));
 
   # assert that the expression throws when `deepSeq`-ed
   assertThrows = defun [ string any AssertResult ]
@@ -119,7 +120,7 @@ let
       let
         context = { should-throw = { inherit expr; }; };
       in
-        assertBoolContext context desc (throws expr));
+      assertBoolContext context desc (throws expr));
 
   # assert that the expression does not throw when `deepSeq`-ed
   assertDoesNotThrow = defun [ string any AssertResult ]
@@ -144,31 +145,50 @@ let
           yep = _: true;
           nope = _: false;
         };
-        res = partitionTests (it:
-          (partitionTests goodAss it.asserts).err == []
-        ) itResults;
-        prettyRes = lib.generators.toPretty {} res;
+        res = partitionTests
+          (it:
+            (partitionTests goodAss it.asserts).err == [ ]
+          )
+          itResults;
+        prettyRes = lib.generators.toPretty { } res;
       in
-        if res.err == []
-        then depot.nix.runExecline.local "testsuite-${name}-successful" {} [
-          "importas" "out" "out"
+      if res.err == [ ]
+      then
+        depot.nix.runExecline.local "testsuite-${name}-successful" { } [
+          "importas"
+          "out"
+          "out"
           # force derivation to rebuild if test case list changes
-          "ifelse" [ bins.s6-false ] [
-            bins.printf "" (builtins.hashString "sha512" prettyRes)
+          "ifelse"
+          [ bins.s6-false ]
+          [
+            bins.printf
+            ""
+            (builtins.hashString "sha512" prettyRes)
           ]
-          "if" [ bins.printf "%s\n" "testsuite ${name} successful!" ]
-          bins.s6-touch "$out"
+          "if"
+          [ bins.printf "%s\n" "testsuite ${name} successful!" ]
+          bins.s6-touch
+          "$out"
         ]
-        else depot.nix.runExecline.local "testsuite-${name}-failed" {
-          stdin = prettyRes + "\n";
-        } [
-          "importas" "out" "out"
-          "if" [ bins.printf "%s\n" "testsuite ${name} failed!" ]
-          "if" [ bins.s6-cat ]
-          "exit" "1"
+      else
+        depot.nix.runExecline.local "testsuite-${name}-failed"
+          {
+            stdin = prettyRes + "\n";
+          } [
+          "importas"
+          "out"
+          "out"
+          "if"
+          [ bins.printf "%s\n" "testsuite ${name} failed!" ]
+          "if"
+          [ bins.s6-cat ]
+          "exit"
+          "1"
         ]);
 
-in {
+in
+{
   inherit
     assertEq
     assertThrows