From aa122cbae78ce97d60c0c98ba14df753d97e40b1 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 30 Jan 2022 19:06:58 +0300 Subject: style: format entire depot with nixpkgs-fmt 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 Reviewed-by: lukegb Reviewed-by: wpcarro Reviewed-by: Profpatsch Reviewed-by: kanepyork Reviewed-by: tazjin Reviewed-by: cynthia Reviewed-by: edef Reviewed-by: eta Reviewed-by: grfn --- nix/runTestsuite/default.nix | 76 ++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 28 deletions(-) (limited to 'nix/runTestsuite/default.nix') 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 -- cgit 1.4.1