tests(f2/repl): migrate basic tests
Change-Id: I22241734a7249d376c86b3a226c5f1a82c03fd33
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
Errors at the top of an expression are printed normally:
|
||||
|
||||
nix-repl> builtins.throw "Evil puppy detected!!!"
|
||||
error:
|
||||
… caused by explicit throw
|
||||
at «string»:1:1:
|
||||
1| builtins.throw "Evil puppy detected!!!"
|
||||
| ^
|
||||
|
||||
error: Evil puppy detected!!!
|
||||
|
||||
Errors in attribute values are printed inline, to make it easier to explore
|
||||
values like nixpkgs where some parts of the value fail to evaluate:
|
||||
|
||||
nix-repl> { puppy = builtins.throw "This puppy is EVIL!!!"; puppy2 = "This puppy is GOOD :)"; }
|
||||
{
|
||||
puppy = «error: This puppy is EVIL!!!»;
|
||||
puppy2 = "This puppy is GOOD :)";
|
||||
}
|
||||
|
||||
Same for list values:
|
||||
|
||||
nix-repl> [ (builtins.throw "This puppy is EVIL!!!") ("This puppy is GOOD :)") ]
|
||||
[
|
||||
«error: This puppy is EVIL!!!»
|
||||
"This puppy is GOOD :)"
|
||||
]
|
||||
@@ -1,13 +0,0 @@
|
||||
A previously unforced thunk in an attribute set does not lead to indentation when it won't evaluate to a nested structure:
|
||||
nix-repl> :p let x = 1 + 2; in [ { inherit x; } { inherit x; } ]
|
||||
[
|
||||
{ x = 3; }
|
||||
{ x = 3; }
|
||||
]
|
||||
|
||||
Same for a list:
|
||||
nix-repl> :p let x = 1 + 2; in [ [ x ] [ x ] ]
|
||||
[
|
||||
[ 3 ]
|
||||
[ 3 ]
|
||||
]
|
||||
@@ -1,50 +0,0 @@
|
||||
@args -v
|
||||
Adding variables gives simple user feedback
|
||||
|
||||
Lix $VERSION
|
||||
Type :? for help.
|
||||
nix-repl> foo = 5
|
||||
Added foo.
|
||||
|
||||
nix-repl> foo = 10
|
||||
Updated foo.
|
||||
|
||||
Optional semicolon at the end, allow setting multiple variables in one line
|
||||
|
||||
nix-repl> foo = 2;
|
||||
Updated foo.
|
||||
|
||||
nix-repl> foo = 2; bar = 3;
|
||||
Updated foo.
|
||||
Added bar.
|
||||
|
||||
String identifiers work
|
||||
|
||||
nix-repl> "silly name" = null
|
||||
Added "silly name".
|
||||
|
||||
Attrset syntax works, but without dynamic attrs or merging
|
||||
|
||||
nix-repl> foo.bar = "baz"
|
||||
Updated foo.
|
||||
|
||||
nix-repl> foo
|
||||
{ bar = "baz"; }
|
||||
|
||||
nix-repl> foo."this works" = 42
|
||||
Updated foo.
|
||||
|
||||
nix-repl> foo
|
||||
{ "this works" = 42; }
|
||||
|
||||
nix-repl> foo.bar = "baz"; foo.more = "error"
|
||||
error: attribute 'foo' already defined at «string»:1:18
|
||||
at «string»:1:12:
|
||||
1| foo.bar = "baz"; foo.more = "error"
|
||||
| ^
|
||||
|
||||
nix-repl> ${foo} = 10
|
||||
error: dynamic attributes not allowed in REPL
|
||||
at «string»:1:1:
|
||||
1| ${foo} = 10
|
||||
| ^
|
||||
@@ -1,114 +0,0 @@
|
||||
Printing a string with escapes in it will render as a string normally.
|
||||
|
||||
nix-repl> "meow\n\nmeowmeowmeow"
|
||||
"meow\n\nmeowmeowmeow"
|
||||
|
||||
But with :p on the string itself it will print it literally to the output.
|
||||
|
||||
nix-repl> :p "meow\n\nmeowmeowmeow"
|
||||
meow
|
||||
|
||||
meowmeowmeow
|
||||
|
||||
nix-repl> builtins.listToAttrs (builtins.genList (x: { name = "meow${toString x}"; value = { meow = { inherit x; s = "meowmeow\n\n${toString x}"; }; }; }) 10)
|
||||
{
|
||||
meow0 = { ... };
|
||||
meow1 = { ... };
|
||||
meow2 = { ... };
|
||||
meow3 = { ... };
|
||||
meow4 = { ... };
|
||||
meow5 = { ... };
|
||||
meow6 = { ... };
|
||||
meow7 = { ... };
|
||||
meow8 = { ... };
|
||||
meow9 = { ... };
|
||||
}
|
||||
|
||||
Also, :p will expand attrs, but it will leave the strings escaped as normal if
|
||||
they aren't the top level item being printed.
|
||||
|
||||
nix-repl> :p builtins.listToAttrs (builtins.genList (x: { name = "meow${toString x}"; value = { meow = { inherit x; s = "meowmeow\n\n${toString x}"; }; }; }) 10)
|
||||
{
|
||||
meow0 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n0";
|
||||
x = 0;
|
||||
};
|
||||
};
|
||||
meow1 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n1";
|
||||
x = 1;
|
||||
};
|
||||
};
|
||||
meow2 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n2";
|
||||
x = 2;
|
||||
};
|
||||
};
|
||||
meow3 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n3";
|
||||
x = 3;
|
||||
};
|
||||
};
|
||||
meow4 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n4";
|
||||
x = 4;
|
||||
};
|
||||
};
|
||||
meow5 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n5";
|
||||
x = 5;
|
||||
};
|
||||
};
|
||||
meow6 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n6";
|
||||
x = 6;
|
||||
};
|
||||
};
|
||||
meow7 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n7";
|
||||
x = 7;
|
||||
};
|
||||
};
|
||||
meow8 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n8";
|
||||
x = 8;
|
||||
};
|
||||
};
|
||||
meow9 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n9";
|
||||
x = 9;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Printing an environment with :env after adding a variable to the scope
|
||||
|
||||
nix-repl> foo = "bar"
|
||||
nix-repl> :env
|
||||
Env level 0
|
||||
static: foo
|
||||
|
||||
Env level 1
|
||||
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true
|
||||
|
||||
Printing a derivation or something
|
||||
|
||||
nix-repl> fakeDrv = let drvAttrs = { builder = "meow"; system = "meower"; name = "mrowmrow"; }; in { inherit (drvAttrs) builder system name; inherit drvAttrs; type = "derivation"; }
|
||||
nix-repl> :p fakeDrv
|
||||
{
|
||||
builder = "meow";
|
||||
drvAttrs = «3 attributes elided»;
|
||||
name = "mrowmrow";
|
||||
system = "meower";
|
||||
type = "derivation";
|
||||
}
|
||||
@@ -176,16 +176,12 @@ TEST_F(ReplSessionTest, tidy)
|
||||
runReplTestPath(#name); \
|
||||
}
|
||||
|
||||
REPL_TEST(repl_input);
|
||||
REPL_TEST(repl_overlays);
|
||||
REPL_TEST(repl_overlays_regression_l777);
|
||||
REPL_TEST(repl_overlays_compose);
|
||||
REPL_TEST(repl_overlays_destructure_without_dotdotdot_errors);
|
||||
REPL_TEST(repl_overlays_destructure_without_formals_ok);
|
||||
REPL_TEST(repl_printing);
|
||||
REPL_TEST(stack_vars);
|
||||
REPL_TEST(errors);
|
||||
REPL_TEST(idempotent);
|
||||
REPL_TEST(stacktrace_invalid_arg);
|
||||
REPL_TEST(stacktrace_oob);
|
||||
REPL_TEST(stacktrace_relative);
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
Errors at the top of an expression are printed normally:
|
||||
|
||||
```nix
|
||||
builtins.throw "Evil puppy detected!!!"
|
||||
```
|
||||
```output
|
||||
error:
|
||||
… caused by explicit throw
|
||||
at «string»:1:1:
|
||||
1| builtins.throw "Evil puppy detected!!!"
|
||||
| ^
|
||||
|
||||
error: Evil puppy detected!!!
|
||||
|
||||
```
|
||||
|
||||
|
||||
Errors in attribute values are printed inline, to make it easier to explore
|
||||
values like nixpkgs where some parts of the value fail to evaluate:
|
||||
|
||||
```nix
|
||||
{ puppy = builtins.throw "This puppy is EVIL!!!"; puppy2 = "This puppy is GOOD :)"; }
|
||||
```
|
||||
```output
|
||||
{
|
||||
puppy = «error: This puppy is EVIL!!!»;
|
||||
puppy2 = "This puppy is GOOD :)";
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
Same for list values:
|
||||
|
||||
```nix
|
||||
[ (builtins.throw "This puppy is EVIL!!!") ("This puppy is GOOD :)") ]
|
||||
```
|
||||
```output
|
||||
[
|
||||
«error: This puppy is EVIL!!!»
|
||||
"This puppy is GOOD :)"
|
||||
]
|
||||
|
||||
```
|
||||
@@ -0,0 +1,26 @@
|
||||
A previously unforced thunk is an attribute set does not lead to indentation when it won't evalutate to a neted structure:
|
||||
|
||||
```nix
|
||||
:p let x = 1 + 2; in [ { inherit x; } { inherit x; } ]
|
||||
```
|
||||
```output
|
||||
[
|
||||
{ x = 3; }
|
||||
{ x = 3; }
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
|
||||
Same for a list:
|
||||
|
||||
```nix
|
||||
:p let x = 1 + 2; in [ [ x ] [ x ]]
|
||||
```
|
||||
```output
|
||||
[
|
||||
[ 3 ]
|
||||
[ 3 ]
|
||||
]
|
||||
|
||||
```
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
args: ['-v']
|
||||
---
|
||||
|
||||
Adding variables gives simple user feedback
|
||||
|
||||
```nix
|
||||
foo = 5
|
||||
foo = 10
|
||||
```
|
||||
```output
|
||||
Added foo.
|
||||
|
||||
Updated foo.
|
||||
|
||||
```
|
||||
|
||||
Optional semicolon at the end, allow setting multiple variables in one line
|
||||
|
||||
```nix
|
||||
foo = 2;
|
||||
foo = 2; bar = 3;
|
||||
```
|
||||
```output
|
||||
Updated foo.
|
||||
|
||||
Updated foo.
|
||||
Added bar.
|
||||
|
||||
```
|
||||
|
||||
String identifiers work
|
||||
|
||||
```nix
|
||||
"silly name" = null
|
||||
```
|
||||
```output
|
||||
Added "silly name".
|
||||
|
||||
```
|
||||
|
||||
Attrset syntax works, but without dynamic attrs or merging
|
||||
|
||||
```nix
|
||||
foo.bar = "baz"
|
||||
foo
|
||||
foo."this works" = 42
|
||||
foo
|
||||
foo.bar = "baz"; foo.more = "error"
|
||||
${foo} = 10
|
||||
```
|
||||
```output
|
||||
Updated foo.
|
||||
|
||||
{ bar = "baz"; }
|
||||
|
||||
Updated foo.
|
||||
|
||||
{ "this works" = 42; }
|
||||
|
||||
error: attribute 'foo' already defined at «string»:1:18
|
||||
at «string»:1:12:
|
||||
1| foo.bar = "baz"; foo.more = "error"
|
||||
| ^
|
||||
|
||||
error: dynamic attributes not allowed in REPL
|
||||
at «string»:1:1:
|
||||
1| ${foo} = 10
|
||||
| ^
|
||||
|
||||
```
|
||||
@@ -0,0 +1,145 @@
|
||||
Printing a string with escapes in it will render as a string normally
|
||||
|
||||
```nix
|
||||
"meow\n\nmeowmeowmeow"
|
||||
```
|
||||
```output
|
||||
"meow\n\nmeowmeowmeow"
|
||||
|
||||
```
|
||||
|
||||
|
||||
But with `:p` on the string itself it will print it literally to the output
|
||||
```nix
|
||||
:p "meow\n\nmeowmeow"
|
||||
```
|
||||
```output
|
||||
meow
|
||||
|
||||
meowmeow
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
Also, `:p` will expand attrs, but it will leave the strings escaped as normal if they aren't at the top level item being printed
|
||||
|
||||
```nix
|
||||
builtins.listToAttrs (builtins.genList (x: { name = "meow${toString x}"; value = { meow = { inherit x; s = "meowmeow\n\n${toString x}"; }; }; }) 10)
|
||||
:p builtins.listToAttrs (builtins.genList (x: { name = "meow${toString x}"; value = { meow = { inherit x; s = "meowmeow\n\n${toString x}"; }; }; }) 10)
|
||||
```
|
||||
```output
|
||||
{
|
||||
meow0 = { ... };
|
||||
meow1 = { ... };
|
||||
meow2 = { ... };
|
||||
meow3 = { ... };
|
||||
meow4 = { ... };
|
||||
meow5 = { ... };
|
||||
meow6 = { ... };
|
||||
meow7 = { ... };
|
||||
meow8 = { ... };
|
||||
meow9 = { ... };
|
||||
}
|
||||
|
||||
{
|
||||
meow0 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n0";
|
||||
x = 0;
|
||||
};
|
||||
};
|
||||
meow1 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n1";
|
||||
x = 1;
|
||||
};
|
||||
};
|
||||
meow2 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n2";
|
||||
x = 2;
|
||||
};
|
||||
};
|
||||
meow3 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n3";
|
||||
x = 3;
|
||||
};
|
||||
};
|
||||
meow4 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n4";
|
||||
x = 4;
|
||||
};
|
||||
};
|
||||
meow5 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n5";
|
||||
x = 5;
|
||||
};
|
||||
};
|
||||
meow6 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n6";
|
||||
x = 6;
|
||||
};
|
||||
};
|
||||
meow7 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n7";
|
||||
x = 7;
|
||||
};
|
||||
};
|
||||
meow8 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n8";
|
||||
x = 8;
|
||||
};
|
||||
};
|
||||
meow9 = {
|
||||
meow = {
|
||||
s = "meowmeow\n\n9";
|
||||
x = 9;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
Printing an environment with :env after adding a variable to the scope
|
||||
```nix
|
||||
foo = "bar"
|
||||
:env
|
||||
```
|
||||
```output
|
||||
Added foo.
|
||||
|
||||
Env level 0
|
||||
static: foo
|
||||
|
||||
Env level 1
|
||||
abort baseNameOf break builtins derivation derivationStrict dirOf false fetchGit fetchMercurial fetchTarball fetchTree fromTOML import isNull map null placeholder removeAttrs scopedImport throw toString true
|
||||
|
||||
```
|
||||
|
||||
|
||||
Printing a derivation or something
|
||||
```nix
|
||||
fakeDrv = let drvAttrs = { builder = "meow"; system = "meower"; name = "mrowmrow"; }; in { inherit (drvAttrs) builder system name; inherit drvAttrs; type = "derivation"; }
|
||||
:p fakeDrv
|
||||
```
|
||||
```output
|
||||
Added fakeDrv.
|
||||
|
||||
{
|
||||
builder = "meow";
|
||||
drvAttrs = «3 attributes elided»;
|
||||
name = "mrowmrow";
|
||||
system = "meower";
|
||||
type = "derivation";
|
||||
}
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user