Example #1
0
def git(repo_path, request):
    assert not os.system(
        'cd {path} && git init'.format(path=repo_path))
    for commit in request.param:
        assert not os.system(
            'cd {p} && touch {c} && git add {c} && git commit -m {c}'.format(p=repo_path, c=commit))
    return GitVcs(path=repo_path)
Example #2
0
def test_history_limit(runner):
    history_limit = 5
    with mock.patch('easyci.commands.test.load_user_config') as mocked:
        mocked.return_value = {
            'tests': ['true', 'true'],
            'history_limit': history_limit,
            'collect_results': [],
        }
        for x in range(history_limit + 1):
            assert not os.system('touch {x} && git add {x}'.format(x=x))
            result = runner.invoke(cli, ['test'])
            assert result.exit_code == 0
            result = runner.invoke(cli, ['test'])
    git = GitVcs()
    evidence = os.path.join(git.private_dir(), 'passed')
    with open(evidence, 'r') as f:
        signatures = f.read().split()
        assert len(signatures) == history_limit
        assert signatures[-1] == git.get_signature()
Example #3
0
def cli(ctx):
    git = GitVcs()
    if ctx.args[0] != 'init':
        try:
            version = get_installed_version(git)
        except VersionNotInstalledError:
            click.echo('Please run `eci init` first.')
            ctx.abort()
        if version != easyci.__version__:
            click.echo('EasyCI version mismatch. Please rerun `eci init`.')
            ctx.abort()
    ctx.obj = dict()
    ctx.obj['vcs'] = git
Example #4
0
def test_already_staged_or_committed(runner):
    config = {
        'tests': ['true', 'true'],
        'history_limit': 1,
        'collect_results': [],
    }
    git = GitVcs()
    signature = git.get_signature()

    # test staged
    stage_signature(git, signature)
    with mock.patch('easyci.commands.test.load_user_config') as mocked:
        mocked.return_value = config
        result = runner.invoke(cli, ['test'])
    assert result.exit_code == exit_codes.ALREADY_RUNNING
    assert 'In Progress' in result.output

    # test committed
    commit_signature(git, config, signature)
    with mock.patch('easyci.commands.test.load_user_config') as mocked:
        mocked.return_value = config
        result = runner.invoke(cli, ['test'])
    assert result.exit_code == exit_codes.SUCCESS
    assert 'OK' in result.output