示例#1
0
def test_find_branch_tips(dummy_runs: List[Run], stored_runs: Storage):
    tips = stored_runs.find_branch_tips()
    assert tips["main"] == dummy_runs[int(len(dummy_runs) / 2 - 1)].commit
    assert tips["feature"] == dummy_runs[-1].commit

    assert stored_runs.find_branch_tips() == stored_runs.find_branch_tips_slow(
    )
示例#2
0
def do_list(
    spec_file: typer.FileText,
) -> None:
    spec = load_spec(spec_file)
    storage = Storage(spec.storage_dir)

    tips = storage.find_branch_tips()
    for key, tip in tips.items():
        print(key)
        for i in storage.iterate(tip):
            print("-", i.commit.hash[:8], i.commit.date, i.commit.message)
示例#3
0
def test_run(stored_runs: Storage, dummy_runs: List[Run]):
    # assert len(dummy_runs) == 2*10

    mid = int(len(dummy_runs) / 2)

    tips = stored_runs.find_branch_tips()
    loaded_runs = sum(
        [list(reversed(list(stored_runs.iterate(t)))) for t in tips.values()],
        [])

    print()
    print(len(loaded_runs))

    assert loaded_runs[0].parent is None
    assert loaded_runs[mid].parent is None

    for run_prev, run in zip(loaded_runs[:mid], loaded_runs[1:mid]):
        assert run_prev.commit == run.parent
        assert run.parent is not None

    for run_prev, run in zip(loaded_runs[mid:], loaded_runs[mid + 1:]):
        assert run_prev.commit == run.parent
        assert run.parent is not None