mirror of
https://github.com/NixOS/nix.git
synced 2025-12-10 02:51:02 +01:00
nix repl: add :log
Add a :log command that shows logs for a derivation. Closes https://github.com/NixOS/nix/issues/3504 Co-authored-by: Taeer Bar-Yam <taeer@bar-yam.me>
This commit is contained in:
parent
0a2fa2d684
commit
33926ed1e7
6 changed files with 54 additions and 4 deletions
|
|
@ -3,6 +3,13 @@ source common.sh
|
|||
replCmds="
|
||||
simple = import ./simple.nix
|
||||
:b simple
|
||||
:log simple
|
||||
"
|
||||
|
||||
replFailingCmds="
|
||||
failing = import ./simple-failing.nix
|
||||
:b failing
|
||||
:log failing
|
||||
"
|
||||
|
||||
testRepl () {
|
||||
|
|
@ -12,6 +19,12 @@ testRepl () {
|
|||
local outPath=$(echo "$replOutput" |&
|
||||
grep -o -E "$NIX_STORE_DIR/\w*-simple")
|
||||
nix path-info "${nixArgs[@]}" "$outPath"
|
||||
# simple.nix prints a PATH during build
|
||||
echo "$replOutput" | grep -qs 'PATH=' || fail "nix repl :log doesn't output logs"
|
||||
local replOutput="$(nix repl "${nixArgs[@]}" <<< "$replFailingCmds")"
|
||||
echo "$replOutput"
|
||||
echo "$replOutput" | grep -qs 'This should fail' \
|
||||
|| fail "nix repl :log doesn't output logs for a failed derivation"
|
||||
}
|
||||
|
||||
# Simple test, try building a drv
|
||||
|
|
|
|||
2
tests/simple-failing.builder.sh
Normal file
2
tests/simple-failing.builder.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
echo "This should fail"
|
||||
exit 1
|
||||
8
tests/simple-failing.nix
Normal file
8
tests/simple-failing.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
with import ./config.nix;
|
||||
|
||||
mkDerivation {
|
||||
name = "simple-failing";
|
||||
builder = ./simple-failing.builder.sh;
|
||||
PATH = "";
|
||||
goodPath = path;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue