mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
7c09104a94
I haven't checked when this was exactly introduced, but on Nix 2.16 I realized that the additional lines inserted when using `--precise` are completely separated from the tree: nix why-depends /nix/store/ccgr4faaxys39s091qridxg1947lggh4-evcxr-0.14.2 /nix/store/b7hvml0m3qmqraz1022fwvyyg6fc1vdy-gcc-12.2.0 --precise --extra-experimental-features nix-command /nix/store/ccgr4faaxys39s091qridxg1947lggh4-evcxr-0.14.2 → /nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0 → /nix/store/b7hvml0m3qmqraz1022fwvyyg6fc1vdy-gcc-12.2.0 └───bin/evcxr: …':'}.PATH=${PATH/':''/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin'':'/':'}… └───bin/cpp: …k disable=SC2193.[[ "/nix/store/b7hvml0m3qmqraz1022fwvyyg6fc1vdy-gcc-12.2.0/bin/cpp" = *++ ]] &&… This is apparently because `std::cout` is buffered and flushed in the end whereas the rest of the output isn't. The fix is rather simple, just use `logger->cout` as it's already the case for the rest of the code. This way we also don't need to insert additional newlines in the `hits` map since that's something the logger takes care of. Also added a small test to make sure that the layout of this is somehow tested to reduce the risk of further regressions here.
29 lines
1.3 KiB
Bash
29 lines
1.3 KiB
Bash
source common.sh
|
|
|
|
clearStore
|
|
|
|
cp ./dependencies.nix ./dependencies.builder0.sh ./config.nix $TEST_HOME
|
|
|
|
cd $TEST_HOME
|
|
|
|
nix why-depends --derivation --file ./dependencies.nix input2_drv input1_drv
|
|
nix why-depends --file ./dependencies.nix input2_drv input1_drv
|
|
|
|
nix-build ./dependencies.nix -A input0_drv -o dep
|
|
nix-build ./dependencies.nix -o toplevel
|
|
|
|
FAST_WHY_DEPENDS_OUTPUT=$(nix why-depends ./toplevel ./dep)
|
|
PRECISE_WHY_DEPENDS_OUTPUT=$(nix why-depends ./toplevel ./dep --precise)
|
|
|
|
# Both outputs should show that `input-2` is in the dependency chain
|
|
echo "$FAST_WHY_DEPENDS_OUTPUT" | grepQuiet input-2
|
|
echo "$PRECISE_WHY_DEPENDS_OUTPUT" | grepQuiet input-2
|
|
|
|
# But only the “precise” one should refer to `reference-to-input-2`
|
|
echo "$FAST_WHY_DEPENDS_OUTPUT" | grepQuietInverse reference-to-input-2
|
|
echo "$PRECISE_WHY_DEPENDS_OUTPUT" | grepQuiet reference-to-input-2
|
|
|
|
<<<"$PRECISE_WHY_DEPENDS_OUTPUT" sed -n '2p' | grepQuiet "└───reference-to-input-2 -> "
|
|
<<<"$PRECISE_WHY_DEPENDS_OUTPUT" sed -n '3p' | grep " →" | grepQuiet "dependencies-input-2"
|
|
<<<"$PRECISE_WHY_DEPENDS_OUTPUT" sed -n '4p' | grepQuiet " └───input0: …" # in input-2, file input0
|
|
<<<"$PRECISE_WHY_DEPENDS_OUTPUT" sed -n '5p' | grep " →" | grepQuiet "dependencies-input-0" # is dependencies-input-0 referenced
|