1
1
Fork 0
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:
Alexander Bantyev 2021-11-26 18:03:07 +03:00
parent 0a2fa2d684
commit 33926ed1e7
No known key found for this signature in database
GPG key ID: E081FF12ADCB4AD5
6 changed files with 54 additions and 4 deletions

View file

@ -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

View file

@ -0,0 +1,2 @@
echo "This should fail"
exit 1

8
tests/simple-failing.nix Normal file
View file

@ -0,0 +1,8 @@
with import ./config.nix;
mkDerivation {
name = "simple-failing";
builder = ./simple-failing.builder.sh;
PATH = "";
goodPath = path;
}