blob: 4675aec05909f879ddfb2b61ab81d83c9fecfa32 [file] [log] [blame]
import os
import pytest
from buildstream._pipeline import PipelineError
from buildstream import _yaml
from tests.testutils import cli, create_repo
from import HAVE_BZR
DATA_DIR = os.path.join(
@pytest.mark.skipif(HAVE_BZR is False, reason="bzr is not available")
def test_fetch_checkout(cli, tmpdir, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
checkoutdir = os.path.join(str(tmpdir), 'checkout')
repo = create_repo('bzr', str(tmpdir))
ref = repo.create(os.path.join(project, 'basic'))
# Write out our test target
element = {
'kind': 'import',
'sources': [
_yaml.dump(element, os.path.join(project, 'target.bst'))
# Fetch, build, checkout
result =, args=['fetch', 'target.bst'])
assert result.exit_code == 0
result =, args=['build', 'target.bst'])
assert result.exit_code == 0
result =, args=['checkout', 'target.bst', checkoutdir])
assert result.exit_code == 0
# Assert we checked out the file as it was commited
with open(os.path.join(checkoutdir, 'test')) as f:
text =
assert text == 'test\n'