timokau / nix-bisect

Bisect nix builds. Status: alpha/proof of concept. You'll probably have to dig into the implementation if you want to use it. Built for personal use, lightly maintained. PRs welcome. Issues welcome, but I make no promises regarding responses or fix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow marking as bad immediately after encountering --failure-line

jtojnar opened this issue · comments

Recently, I have been bisecting GNOME failing to start in VM. The failure could be discerned by a permission error being logged shortly after boot but the test VM continued running, trying to start the session. And when that failed, the test got stuck waiting for X that would never arrive.

In the end I decided to use the following bisection script but it would be nice if nix-build-status could terminate the build immediately after `--failure-line appears.

content=$(timeout 1m nix-build nixos/release-combined.nix -A nixos.tests.gnome3-xorg.x86_64-linux 2>&1)

if [[ $content =~ "systemd-logind: failed to take device /dev/dri/card0: Operation not permitted" ]]; then
    exit 1
elif [[ $content =~ 'systemd-logind: got fd for /dev/dri/card0' ]]; then
    exit 0
else
    exit 125
fi

Yes, I agree that this would be nice. I tried supporting that in some early prototype. The problem is that nix build truncates its output and actually skips some lines (it has some sort of limited refresh rate). Because of that, it is not useful to parse the output of nix build. At the same time I think printing the output of nix build to the terminal during bisection is very helpful, so we can't just use nix-build instead. Currently I use nix build followed by nix log, but that makes it necessary to wait for the build to succeed.

It might actually be possible to query the log of an unfinished build, but that would be a pretty hacky solution requiring multiple threads.

I recently discovered the -L flag to nix build. That would make it possible to parse the output while still displaying a well-formatted status to the user. Experimenting with that is already on my todo list.