def test_version_act_completed(gitrepo): # This test runs an activity a, undoes a, then runs an activity b that depends on a # During the last run, a should not be rerun since it was already # run the first time. with open('rever.xsh', 'w') as f: f.write(EMPTY_REVER_XSH) env = builtins.__xonsh__.env dag = env['DAG'] a = dag['a'] = Activity(name='a') b = dag['b'] = Activity(name='b', deps={'a'}) # run the first time env_main(args=['--activities', 'a', 'x.y.z']) done = compute_activities_completed() assert done == {'a'} # Now that we changed the version the activity is not done env['VERSION'] = 'x.y.zz' done = compute_activities_completed() assert done == set() env_main(args=['--activities', 'a', 'x.y.zz']) done = compute_activities_completed() assert done == set('a') env_main(args=['--undo', 'a', 'x.y.z']) done = compute_activities_completed() assert done == set() env['VERSION'] = 'x.y.zz' done = compute_activities_completed() assert done == set('a')
def test_dont_redo_deps(gitrepo): # This test runs an activity a, then runs an activity b that depends on a # During the second run, a should not be rerun since it was already # run the first time. env = builtins.__xonsh__.env dag = env['DAG'] a = dag['a'] = Activity(name='a') b = dag['b'] = Activity(name='b', deps={'a'}) # run the first time env_main(args=['--activities', 'a', 'x.y.z']) done = compute_activities_completed() assert done == {'a'} # test what we we need to run if we wanted to run b path, already_done = compute_activities_to_run(activities=['b']) assert path == ['b'] assert already_done == ['a'] # run for the second time env_main(args=['--activities', 'b', 'x.y.z']) done = compute_activities_completed() assert done == {'a', 'b'} # make sure a and b were each run exactly once entries = env['LOGGER'].load() a_ends = [ e for e in entries if e['activity'] == 'a' and e['category'] == 'activity-end' ] assert len(a_ends) == 1 b_ends = [ e for e in entries if e['activity'] == 'b' and e['category'] == 'activity-end' ] assert len(b_ends) == 1
def test_compute_activities_completed(gitrepo): l = current_logger() env = builtins.__xonsh__.env env['VERSION'] = 'x.y.z' l.log('logging a', activity='a', category='activity-end', data={'start_rev': 'hi'}) e = l.load() assert compute_activities_completed() == {'a'} env['VERSION'] = 'x.y.zz' assert compute_activities_completed() == set()