summaryrefslogtreecommitdiff
path: root/tests/remoteexecution/partial.py
blob: ee0fc25b4b607f9b57f8ab5bca5d2fd36e2f44d7 (plain)
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
import os
import pytest

from buildstream._exceptions import ErrorDomain
from buildstream.testing import cli_remote_execution as cli
from buildstream.testing.integration import assert_contains


pytestmark = pytest.mark.remoteexecution


DATA_DIR = os.path.join(
    os.path.dirname(os.path.realpath(__file__)),
    "project"
)


# Test that `bst build` does not download file blobs of a build-only dependency
# to the local cache.
@pytest.mark.datafiles(DATA_DIR)
def test_build_dependency_partial_local_cas(cli, datafiles):
    project = str(datafiles)
    element_name = 'no-runtime-deps.bst'
    builddep_element_name = 'autotools/amhello.bst'
    checkout = os.path.join(cli.directory, 'checkout')
    builddep_checkout = os.path.join(cli.directory, 'builddep-checkout')

    services = cli.ensure_services()
    assert set(services) == set(['action-cache', 'execution', 'storage'])

    result = cli.run(project=project, args=['build', element_name])
    result.assert_success()

    # Verify that the target element is available in local cache
    result = cli.run(project=project, args=['artifact', 'checkout', element_name,
                                            '--directory', checkout])
    result.assert_success()
    assert_contains(checkout, ['/test'])

    # Verify that the build-only dependency is not (complete) in the local cache
    result = cli.run(project=project, args=['artifact', 'checkout', builddep_element_name,
                                            '--directory', builddep_checkout])
    result.assert_main_error(ErrorDomain.STREAM, 'uncached-checkout-attempt')