Fix buildgraph autotest.

This one broke an impressive number of invariants, which finally
resulted in a crash on a build machine.

Change-Id: Ia6dc57a2681b780faa17ebc4f130251da23a89a0
Reviewed-by: Christian Stenger <christian.stenger@digia.com>