def test_remove_results(vcs): # empty case with pytest.raises(ResultsNotFoundError): remove_results(vcs, 'signature1') # non-empty case results_dir = _get_results_directory(vcs, 'signature1') os.makedirs(results_dir) assert not os.system('touch {}'.format(os.path.join(results_dir, 'a'))) remove_results(vcs, 'signature1') assert not os.path.exists(results_dir)
def gc(ctx): """Runs housekeeping tasks to free up space. For now, this only removes saved but unused (unreachable) test results. """ vcs = ctx.obj['vcs'] count = 0 with locking.lock(vcs, locking.Lock.tests_history): known_signatures = set(get_committed_signatures(vcs) + get_staged_signatures(vcs)) for signature in get_signatures_with_results(vcs): if signature not in known_signatures: count += 1 remove_results(vcs, signature) click.echo('Removed {} saved results.'.format(count))