let maybe_dump_cache conf state =
  if state.tests_running = [] && state.tests_planned = [] then
    (* We are finished, all results are in, flush the cache. *)
    OUnitCache.dump conf
      (List.fold_left
         (fun cache (path, test_result, _) ->
            OUnitCache.add_result path test_result cache)
         state.cache
         (List.map fst state.tests_passed));
  state