1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
import os
import pytest
from buildstream import SourceError
from tests.testutils import cli
DATA_DIR = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
'local',
)
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_missing_file(cli, tmpdir, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
# Removing the local file causes preflight to fail
localfile = os.path.join(datafiles.dirname, datafiles.basename, 'file.txt')
os.remove(localfile)
result = cli.run(project=project, args=[
'show', 'target.bst'
])
assert result.exit_code != 0
assert result.exception
assert isinstance(result.exception, SourceError)
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_stage_file(cli, tmpdir, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
checkoutdir = os.path.join(str(tmpdir), "checkout")
# Track, fetch, build, checkout
result = cli.run(project=project, args=['track', 'target.bst'])
assert result.exit_code == 0
result = cli.run(project=project, args=['fetch', 'target.bst'])
assert result.exit_code == 0
result = cli.run(project=project, args=['build', 'target.bst'])
assert result.exit_code == 0
result = cli.run(project=project, args=['checkout', 'target.bst', checkoutdir])
assert result.exit_code == 0
# Check that the checkout contains the expected file
assert(os.path.exists(os.path.join(checkoutdir, 'file.txt')))
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'directory'))
def test_stage_directory(cli, tmpdir, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
checkoutdir = os.path.join(str(tmpdir), "checkout")
# Track, fetch, build, checkout
result = cli.run(project=project, args=['track', 'target.bst'])
assert result.exit_code == 0
result = cli.run(project=project, args=['fetch', 'target.bst'])
assert result.exit_code == 0
result = cli.run(project=project, args=['build', 'target.bst'])
assert result.exit_code == 0
result = cli.run(project=project, args=['checkout', 'target.bst', checkoutdir])
assert result.exit_code == 0
# Check that the checkout contains the expected file and directory and other file
assert(os.path.exists(os.path.join(checkoutdir, 'file.txt')))
assert(os.path.exists(os.path.join(checkoutdir, 'subdir', 'anotherfile.txt')))
|