fix(depotfmt): only exclude *imported* tvix tests

When we added the Nix language test suite in cl/6126, we excluded the
whole tvix tests folder from Nix formatting. This is unintentional, as
we probably want *our* tests to be formatted correctly.

Change-Id: I2b66d79e30fae17e75d5a1f8c44e279886091c5f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11154
Autosubmit: tazjin <tazjin@tvl.su>
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2024-03-15 16:42:37 +03:00 committed by clbot
parent d5b6704d3d
commit d3534ee051
91 changed files with 412 additions and 272 deletions

View file

@ -23,7 +23,7 @@ let
command = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt" command = "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt"
includes = [ "*.nix" ] includes = [ "*.nix" ]
excludes = [ excludes = [
"tvix/eval/src/tests/*", "tvix/eval/src/tests/nix_tests/*",
] ]
[formatter.rust] [formatter.rust]

View file

@ -2,7 +2,8 @@ let
# There is no syntax for accessing this identifier in an ordinary # There is no syntax for accessing this identifier in an ordinary
# way. # way.
"foo bar" = 42; "foo bar" = 42;
in ({ in
({
# but we *can* inherit it back out # but we *can* inherit it back out
inherit "foo bar"; inherit "foo bar";
})."foo bar" })."foo bar"

View file

@ -1,4 +1,3 @@
builtins.groupBy builtins.groupBy
(v: v.x) (v: v.x)
[ (rec { y = x; x = "fred"; }) ] [ (rec { y = x; x = "fred"; }) ]

View file

@ -1,4 +1,5 @@
let let
# self-recursive function should be able to close over itself # self-recursive function should be able to close over itself
f = n: if n <= 0 then "done" else f (n - 1); f = n: if n <= 0 then "done" else f (n - 1);
in f 10 in
f 10

View file

@ -1,6 +1,7 @@
with builtins; with builtins;
[ (concatStringsSep "" []) [
(concatStringsSep "" [ ])
(concatStringsSep "" [ "foo" "bar" "xyzzy" ]) (concatStringsSep "" [ "foo" "bar" "xyzzy" ])
(concatStringsSep ", " [ "foo" "bar" "xyzzy" ]) (concatStringsSep ", " [ "foo" "bar" "xyzzy" ])
(concatStringsSep ", " [ "foo" ]) (concatStringsSep ", " [ "foo" ])

View file

@ -15,4 +15,7 @@ with { c = 3; d = 3; };
_: _:
with { d = 4; }; with { d = 4; };
[ a b c d ]) null null null null [ a b c d ]) null
null
null
null

View file

@ -5,4 +5,5 @@ let
set = { set = {
value = 42; value = 42;
}; };
in result in
result

View file

@ -1,7 +1,9 @@
let let
fib' = i: n: m: if i == 0 fib' = i: n: m:
if i == 0
then n then n
else fib' (i - 1) m (n + m); else fib' (i - 1) m (n + m);
fib = n: fib' n 1 1; fib = n: fib' n 1 1;
in fib 10 in
fib 10

View file

@ -1,6 +1,7 @@
let let
fix = f: let x = f x; in x; fix = f: let x = f x; in x;
in fix(self: { in
fix (self: {
a = 1; a = 1;
b = self.a + 20; b = self.a + 20;
c = self.b * 2; c = self.b * 2;

View file

@ -15,7 +15,8 @@ let
{ name = "mplayer-${stdenv.name}.${xorg.libXv.name}-${xorg.libX11.name}"; }; { name = "mplayer-${stdenv.name}.${xorg.libXv.name}-${xorg.libX11.name}"; };
makeOverridable = f: origArgs: f origArgs // makeOverridable = f: origArgs: f origArgs //
{ override = newArgs: {
override = newArgs:
makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs)); makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs));
}; };
@ -37,7 +38,8 @@ let
mplayer = callPackage mplayerFun { stdenv = pkgs.stdenv2; enableFoo = false; }; mplayer = callPackage mplayerFun { stdenv = pkgs.stdenv2; enableFoo = false; };
nix = callPackage nixFun { }; nix = callPackage nixFun { };
}; };
in pkgs; in
pkgs;
libX11Fun = { stdenv, fetchurl }: { name = "libX11"; }; libX11Fun = { stdenv, fetchurl }: { name = "libX11"; };
libX11_2Fun = { stdenv, fetchurl }: { name = "libX11_2"; }; libX11_2Fun = { stdenv, fetchurl }: { name = "libX11_2"; };
@ -67,7 +69,8 @@ let
in in
[ pkgs.stdenv.name [
pkgs.stdenv.name
pkgs.fetchurl.name pkgs.fetchurl.name
pkgs.aterm.name pkgs.aterm.name
pkgs2.aterm.name pkgs2.aterm.name

View file

@ -4,4 +4,5 @@ let
set = { set = {
inherit ({ value = 42; }) "value"; inherit ({ value = 42; }) "value";
}; };
in set.value in
set.value

View file

@ -1,4 +1,5 @@
let let
f = n: n + a; f = n: n + a;
a = 2; a = 2;
in f 40 in
f 40

View file

@ -1,4 +1,5 @@
let let
a = b; a = b;
b = 42; b = 42;
in a in
a

View file

@ -6,7 +6,8 @@ let
list3 = [ (2 + 2) ]; list3 = [ (2 + 2) ];
list4 = [ (2 + 2) ]; list4 = [ (2 + 2) ];
list5 = [ (2 + 2) ]; list5 = [ (2 + 2) ];
in [ in
[
(attrs1 == attrs2) (attrs1 == attrs2)
(list1 == list2) (list1 == list2)
(list3 == list2) (list3 == list2)

View file

@ -2,4 +2,5 @@ let
a = 1; a = 1;
"b" = 2; "b" = 2;
${"c"} = 3; ${"c"} = 3;
in [ a b c ] in
[ a b c ]

View file

@ -9,4 +9,5 @@ in
}; };
inherit (set) a; inherit (set) a;
inherit (set2) b; inherit (set2) b;
in a + b in
a + b

View file

@ -2,4 +2,5 @@ let
a = 1; a = 1;
b = 2; b = 2;
c = a + b; c = a + b;
in c in
c

View file

@ -12,4 +12,5 @@ let
b = builtins.listToAttrs (list ++ list); b = builtins.listToAttrs (list ++ list);
r = builtins.listToAttrs [ (asi "result" [ a b ]) (asi "throw" (throw "this should not be thrown")) ]; r = builtins.listToAttrs [ (asi "result" [ a b ]) (asi "throw" (throw "this should not be thrown")) ];
x = builtins.listToAttrs [ (asi "foo" "bar") (asi "foo" "bla") ]; x = builtins.listToAttrs [ (asi "foo" "bar") (asi "foo" "bla") ];
in concat (map (x: x.a) r.result) + x.foo in
concat (map (x: x.a) r.result) + x.foo

View file

@ -6,4 +6,5 @@ let
a = 21; a = 21;
b = a * 2; b = a * 2;
}; };
in set.b in
set.b

View file

@ -1,6 +1,10 @@
let let
doubler = n: outer n; doubler = n: outer n;
outer = let inner = n: a * n; outer =
let
inner = n: a * n;
a = 2; a = 2;
in inner; in
in doubler 10 inner;
in
doubler 10

View file

@ -1,4 +1,5 @@
let let
inner = 21; inner = 21;
set.a.b = inner * 2; set.a.b = inner * 2;
in set in
set

View file

@ -6,12 +6,17 @@
let let
a = 1; a = 1;
b = 2; b = 2;
outer = let outer =
let
c = 3; c = 3;
d = 4; d = 4;
inner = let inner =
let
e = 5; e = 5;
f = 6; f = 6;
in g: [ a b c d e f g ]; in
in inner; g: [ a b c d e f g ];
in outer 7 in
inner;
in
outer 7

View file

@ -1,7 +1,10 @@
let let
a = let a =
let
b = 1; b = 1;
c = 2; c = 2;
in b + c; in
b + c;
b = 4; b = 4;
in a + b in
a + b

View file

@ -1,4 +1,5 @@
let let
null = 1; null = 1;
f = n: n + null; f = n: n + null;
in f 41 in
f 41

View file

@ -4,4 +4,5 @@ let
a = b; a = b;
b = c; b = c;
c = 42; c = 42;
in a in
a

View file

@ -1,4 +1,5 @@
let let
set1 = { a = 1; }; set1 = { a = 1; };
set2 = { a = 2; }; set2 = { a = 2; };
in with set1; with set2; a in
with set1; with set2; a

View file

@ -1,4 +1,3 @@
# the first dash followed by a non-alphabetic character separates # the first dash followed by a non-alphabetic character separates
# the "name" from the "version" # the "name" from the "version"

View file

@ -7,7 +7,8 @@ let
# foldl-based version of listToAttrs with the _opposite_ behaviour. # foldl-based version of listToAttrs with the _opposite_ behaviour.
listToAttrs' = list: foldl' (acc: elem: acc // { ${elem.name} = elem.value; }) { } list; listToAttrs' = list: foldl' (acc: elem: acc // { ${elem.name} = elem.value; }) { } list;
in [ in
[
(listToAttrs input).result (listToAttrs input).result
(listToAttrs' input).result (listToAttrs' input).result
] ]

View file

@ -1,4 +1,5 @@
let let
a = 1; a = 1;
b = 2; b = 2;
in a + b in
a + b

View file

@ -2,4 +2,5 @@ let
set = { set = {
a = 1; a = 1;
}; };
in with set; a in
with set; a

View file

@ -1,7 +1,8 @@
let let
__functor = f; __functor = f;
f = self: x: self.out * x; f = self: x: self.out * x;
in { in
{
inherit __functor; inherit __functor;
out = 21; out = 21;
} 2 } 2

View file

@ -1,6 +1,8 @@
let let
a = { }; a = { };
in let in
let
c = if builtins.isFunction a then a b else a; c = if builtins.isFunction a then a b else a;
b = { }; b = { };
in c in
c

View file

@ -4,4 +4,5 @@ let
set = { set = {
a = with { b = 42; }; b; a = with { b = 42; }; b;
}; };
in set.a in
set.a

View file

@ -5,6 +5,7 @@ let
a = 1; a = 1;
b = 2; b = 2;
c = 3; c = 3;
in { in
{
inherit a b c; inherit a b c;
} }

View file

@ -1,7 +1,10 @@
let let
poisoned = let poisoned =
let
true = 1; true = 1;
false = 2; false = 2;
null = 3; null = 3;
in [ true false null ]; in
in [ true false null ] ++ poisoned [ true false null ];
in
[ true false null ] ++ poisoned

View file

@ -9,7 +9,8 @@ with ({ x = 1;});
let inherit x; let inherit x;
# Provide another dynamic `x` identifier # Provide another dynamic `x` identifier
in with ({ x = 3; }); in
with ({ x = 3; });
# Inherited static identifier should have precedence # Inherited static identifier should have precedence
x x

View file

@ -9,4 +9,5 @@ let
${with set1; key} = 20; ${with set1; key} = 20;
${with { key = "c"; }; key} = 2; ${with { key = "c"; }; key} = 2;
}; };
in set2.a + set2.b + set2.c in
set2.a + set2.b + set2.c

View file

@ -6,7 +6,8 @@ let
set = { set = {
value = 2; value = 2;
}; };
in [ in
[
1 1
(with set; value) (with set; value)
3 3

View file

@ -20,9 +20,11 @@ rec {
sum = foldl' (x: y: add x y) 0; sum = foldl' (x: y: add x y) 0;
hasSuffix = ext: fileName: hasSuffix = ext: fileName:
let lenFileName = stringLength fileName; let
lenFileName = stringLength fileName;
lenExt = stringLength ext; lenExt = stringLength ext;
in !(lessThan lenFileName lenExt) && in
!(lessThan lenFileName lenExt) &&
substring (sub lenFileName lenExt) lenFileName fileName == ext; substring (sub lenFileName lenExt) lenFileName fileName == ext;
# Split a list at the given position. # Split a list at the given position.
@ -40,7 +42,8 @@ rec {
split = splitAt (div (length list) 2) list; split = splitAt (div (length list) 2) list;
first = sortBy comp split.first; first = sortBy comp split.first;
second = sortBy comp split.second; second = sortBy comp split.second;
in mergeLists comp first second in
mergeLists comp first second
else list; else list;
mergeLists = comp: list1: list2: mergeLists = comp: list1: list2:

View file

@ -10,23 +10,110 @@
let let
# C++ Nix 2.3 builtins except valueSize which is removed in later versions # C++ Nix 2.3 builtins except valueSize which is removed in later versions
minimalBuiltins = [ minimalBuiltins = [
"abort" "add" "addErrorContext" "all" "any" "appendContext" "attrNames" "abort"
"attrValues" "baseNameOf" "bitAnd" "bitOr" "bitXor" "builtins" "catAttrs" "add"
"compareVersions" "concatLists" "concatMap" "concatStringsSep" "addErrorContext"
"currentSystem" "currentTime" "deepSeq" "derivation" "derivationStrict" "all"
"dirOf" "div" "elem" "elemAt" "false" "fetchGit" "fetchMercurial" "any"
"fetchTarball" "fetchurl" "filter" "filterSource" "findFile" "foldl'" "appendContext"
"fromJSON" "fromTOML" "functionArgs" "genList" "genericClosure" "getAttr" "attrNames"
"getContext" "getEnv" "hasAttr" "hasContext" "hashFile" "hashString" "head" "attrValues"
"import" "intersectAttrs" "isAttrs" "isBool" "isFloat" "isFunction" "isInt" "baseNameOf"
"isList" "isNull" "isPath" "isString" "langVersion" "length" "lessThan" "bitAnd"
"listToAttrs" "map" "mapAttrs" "match" "mul" "nixPath" "nixVersion" "null" "bitOr"
"parseDrvName" "partition" "path" "pathExists" "placeholder" "readDir" "bitXor"
"readFile" "removeAttrs" "replaceStrings" "scopedImport" "seq" "sort" "builtins"
"split" "splitVersion" "storeDir" "storePath" "stringLength" "sub" "catAttrs"
"substring" "tail" "throw" "toFile" "toJSON" "toPath" "toString" "toXML" "compareVersions"
"trace" "true" "tryEval" "typeOf" "unsafeDiscardOutputDependency" "concatLists"
"unsafeDiscardStringContext" "unsafeGetAttrPos" "concatMap"
"concatStringsSep"
"currentSystem"
"currentTime"
"deepSeq"
"derivation"
"derivationStrict"
"dirOf"
"div"
"elem"
"elemAt"
"false"
"fetchGit"
"fetchMercurial"
"fetchTarball"
"fetchurl"
"filter"
"filterSource"
"findFile"
"foldl'"
"fromJSON"
"fromTOML"
"functionArgs"
"genList"
"genericClosure"
"getAttr"
"getContext"
"getEnv"
"hasAttr"
"hasContext"
"hashFile"
"hashString"
"head"
"import"
"intersectAttrs"
"isAttrs"
"isBool"
"isFloat"
"isFunction"
"isInt"
"isList"
"isNull"
"isPath"
"isString"
"langVersion"
"length"
"lessThan"
"listToAttrs"
"map"
"mapAttrs"
"match"
"mul"
"nixPath"
"nixVersion"
"null"
"parseDrvName"
"partition"
"path"
"pathExists"
"placeholder"
"readDir"
"readFile"
"removeAttrs"
"replaceStrings"
"scopedImport"
"seq"
"sort"
"split"
"splitVersion"
"storeDir"
"storePath"
"stringLength"
"sub"
"substring"
"tail"
"throw"
"toFile"
"toJSON"
"toPath"
"toString"
"toXML"
"trace"
"true"
"tryEval"
"typeOf"
"unsafeDiscardOutputDependency"
"unsafeDiscardStringContext"
"unsafeGetAttrPos"
]; ];
intersectLists = as: bs: builtins.filter (a: builtins.elem a bs) as; intersectLists = as: bs: builtins.filter (a: builtins.elem a bs) as;