[Notes] [Git][BuildStream/buildstream][willsalmon/outOfSourecBuild] 2 commits: Adding Tests for Out of Source Build examples



Title: GitLab

Will Salmon pushed to branch willsalmon/outOfSourecBuild at BuildStream / buildstream

Commits:

5 changed files:

Changes:

  • buildstream/buildelement.py
    ... ... @@ -23,6 +23,38 @@ BuildElement - Abstract class for build elements
    23 23
     The BuildElement class is a convenience element one can derive from for
    
    24 24
     implementing the most common case of element.
    
    25 25
     
    
    26
    +Built-in functionality
    
    27
    +----------------------
    
    28
    +
    
    29
    +The BuildElement base class provides built in functionality that could be overridden by the
    
    30
    +individual plugins.
    
    31
    +
    
    32
    +This section will give a brief summary of how some of the common features work, some of them or the variables they
    
    33
    +use will be further detailed in the following sections.
    
    34
    +
    
    35
    +* Location for running commands
    
    36
    +
    
    37
    + The ``command-subdir`` variable sets where the build commands will be executed, if the directory dose not exist it
    
    38
    + will be created, it is defined relative to the buildroot.
    
    39
    +
    
    40
    +* Location for configuring the project
    
    41
    +
    
    42
    + The ``conf-root`` is defined by default as ``.`` and is the location that specific build element can use to look
    
    43
    + for build configuration files, currently autotools and cmake use this.
    
    44
    +
    
    45
    + The configuration commands are run in ``command-subdir`` and by default ``conf-root`` is ``.`` so if
    
    46
    + ``conf-root`` is not set the configuration files in ``command-subdir`` will be used.
    
    47
    +
    
    48
    + By setting ``conf-root`` to ``"%{build-root}/Source/conf_location"`` and your source elements ``directory`` variable
    
    49
    + to ``Source`` then the configuration files in the directory ``conf_location`` with in your Source will be used.
    
    50
    + However the location where your configuration command will be run will still be wherever you set your
    
    51
    + ``command-subdir`` to be.
    
    52
    +
    
    53
    +* Install Location
    
    54
    +
    
    55
    +  You should not change the ``install-root`` variable as it is a special writeable location in the sandbox but it is
    
    56
    +  useful when writing custom install instructions as it may need to be supplied as the ``DESTDIR``, please see the
    
    57
    +  cmake build element for example.
    
    26 58
     
    
    27 59
     Abstract method implementations
    
    28 60
     -------------------------------
    

  • buildstream/source.py
    ... ... @@ -20,6 +20,19 @@
    20 20
     Source - Base source class
    
    21 21
     ==========================
    
    22 22
     
    
    23
    +Built-in functionality
    
    24
    +----------------------
    
    25
    +
    
    26
    +The Source base class provides built in functionality that could be overridden by the
    
    27
    +individual plugins.
    
    28
    +
    
    29
    +* Directory
    
    30
    +
    
    31
    +  The ``directory`` variable can be set for all sources of a type in project.conf
    
    32
    +  or per source within a element.
    
    33
    +
    
    34
    +  This sets the location with in the build root that the content of the source will be
    
    35
    +  loaded in to. If the location dose not exist it will be created.
    
    23 36
     
    
    24 37
     .. _core_source_abstract_methods:
    
    25 38
     
    

  • tests/examples/autotools-outofsource.py
    1
    +import os
    
    2
    +import pytest
    
    3
    +
    
    4
    +from tests.testutils import cli_integration as cli
    
    5
    +from tests.testutils.integration import assert_contains
    
    6
    +from tests.testutils.site import IS_LINUX
    
    7
    +
    
    8
    +pytestmark = pytest.mark.integration
    
    9
    +
    
    10
    +DATA_DIR = os.path.join(
    
    11
    +    os.path.dirname(os.path.realpath(__file__)), '..', '..', 'doc', 'examples',
    
    12
    +    'out-of-source-autotool-in-source-tree'
    
    13
    +)
    
    14
    +
    
    15
    +
    
    16
    +# Tests a build of the autotools amhello project on a alpine-linux base runtime
    
    17
    +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
    
    18
    +@pytest.mark.datafiles(DATA_DIR)
    
    19
    +def test_autotools_build(cli, tmpdir, datafiles):
    
    20
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    21
    +    checkout = os.path.join(cli.directory, 'checkout')
    
    22
    +
    
    23
    +    # Check that the project can be built correctly.
    
    24
    +    result = cli.run(project=project, args=['build', 'hello.bst'])
    
    25
    +    result.assert_success()
    
    26
    +
    
    27
    +    result = cli.run(project=project, args=['checkout', 'hello.bst', checkout])
    
    28
    +    result.assert_success()
    
    29
    +
    
    30
    +    assert_contains(checkout, ['/usr', '/usr/lib', '/usr/bin',
    
    31
    +                               '/usr/share', '/usr/lib/debug',
    
    32
    +                               '/usr/lib/debug/usr', '/usr/lib/debug/usr/bin',
    
    33
    +                               '/usr/lib/debug/usr/bin/hello',
    
    34
    +                               '/usr/bin/hello',
    
    35
    +                               '/usr/share/doc', '/usr/share/doc/amhello',
    
    36
    +                               '/usr/share/doc/amhello/README'])
    
    37
    +
    
    38
    +
    
    39
    +# Test running an executable built with autotools.
    
    40
    +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
    
    41
    +@pytest.mark.datafiles(DATA_DIR)
    
    42
    +def test_autotools_run(cli, tmpdir, datafiles):
    
    43
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    44
    +
    
    45
    +    result = cli.run(project=project, args=['build', 'hello.bst'])
    
    46
    +    result.assert_success()
    
    47
    +
    
    48
    +    result = cli.run(project=project, args=['shell', 'hello.bst', 'hello'])
    
    49
    +    result.assert_success()
    
    50
    +    assert result.output == 'Hello World!\nThis is amhello 1.0.\n'

  • tests/examples/cmake.py
    1
    +import os
    
    2
    +import pytest
    
    3
    +
    
    4
    +from tests.testutils import cli_integration as cli
    
    5
    +from tests.testutils.integration import assert_contains
    
    6
    +from tests.testutils.site import IS_LINUX
    
    7
    +
    
    8
    +pytestmark = pytest.mark.integration
    
    9
    +
    
    10
    +DATA_DIR = os.path.join(
    
    11
    +    os.path.dirname(os.path.realpath(__file__)), '..', '..', 'doc', 'examples', 'cmake'
    
    12
    +)
    
    13
    +
    
    14
    +
    
    15
    +# Tests a build using cmake with the C complier from alpine-linux base runtime
    
    16
    +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
    
    17
    +@pytest.mark.datafiles(DATA_DIR)
    
    18
    +def test_autotools_build(cli, tmpdir, datafiles):
    
    19
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    20
    +    checkout = os.path.join(cli.directory, 'checkout')
    
    21
    +
    
    22
    +    # Check that the project can be built correctly.
    
    23
    +    result = cli.run(project=project, args=['build', 'hello.bst'])
    
    24
    +    result.assert_success()
    
    25
    +
    
    26
    +    result = cli.run(project=project, args=['checkout', 'hello.bst', checkout])
    
    27
    +    result.assert_success()
    
    28
    +
    
    29
    +    assert_contains(checkout, ['/usr', '/usr/lib', '/usr/bin',
    
    30
    +                               '/usr/share',
    
    31
    +                               '/bin/hello_buildstream'])
    
    32
    +
    
    33
    +
    
    34
    +# Test running an executable built with cmake.
    
    35
    +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
    
    36
    +@pytest.mark.datafiles(DATA_DIR)
    
    37
    +def test_autotools_run(cli, tmpdir, datafiles):
    
    38
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    39
    +
    
    40
    +    result = cli.run(project=project, args=['build', 'hello.bst'])
    
    41
    +    result.assert_success()
    
    42
    +
    
    43
    +    result = cli.run(project=project, args=['shell', 'hello.bst', 'hello_buildstream'])
    
    44
    +    result.assert_success()
    
    45
    +    assert result.output == 'Hello, World!\n'

  • tests/examples/helloworld-outofsource.py
    1
    +import os
    
    2
    +import pytest
    
    3
    +
    
    4
    +from tests.testutils import cli_integration as cli
    
    5
    +from tests.testutils.integration import assert_contains
    
    6
    +from tests.testutils.site import IS_LINUX
    
    7
    +
    
    8
    +pytestmark = pytest.mark.integration
    
    9
    +
    
    10
    +DATA_DIR = os.path.join(
    
    11
    +    os.path.dirname(os.path.realpath(__file__)), '..', '..', 'doc', 'examples',
    
    12
    +    'out-of-source-build-helloworld'
    
    13
    +)
    
    14
    +
    
    15
    +
    
    16
    +# Tests a build of the autotools amhello project on a alpine-linux base runtime
    
    17
    +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
    
    18
    +@pytest.mark.datafiles(DATA_DIR)
    
    19
    +def test_autotools_build(cli, tmpdir, datafiles):
    
    20
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    21
    +    checkout = os.path.join(cli.directory, 'checkout')
    
    22
    +
    
    23
    +    # Check that the project can be built correctly.
    
    24
    +    result = cli.run(project=project, args=['build', 'hello.bst'])
    
    25
    +    result.assert_success()
    
    26
    +
    
    27
    +    result = cli.run(project=project, args=['checkout', 'hello.bst', checkout])
    
    28
    +    result.assert_success()
    
    29
    +
    
    30
    +    assert_contains(checkout, ['/usr', '/usr/bin',
    
    31
    +                               '/usr/bin/hello'])
    
    32
    +
    
    33
    +
    
    34
    +# Test running an executable built with autotools.
    
    35
    +@pytest.mark.skipif(not IS_LINUX, reason='Only available on linux')
    
    36
    +@pytest.mark.datafiles(DATA_DIR)
    
    37
    +def test_autotools_run(cli, tmpdir, datafiles):
    
    38
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    39
    +
    
    40
    +    result = cli.run(project=project, args=['build', 'hello.bst'])
    
    41
    +    result.assert_success()
    
    42
    +
    
    43
    +    result = cli.run(project=project, args=['shell', 'hello.bst', '--', 'hello', 'bob'])
    
    44
    +    result.assert_success()
    
    45
    +    assert result.output == 'Hello bob\n'



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]