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



Title: GitLab

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

Commits:

4 changed files:

Changes:

  • buildstream/buildelement.py
    ... ... @@ -23,6 +23,42 @@ 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 over ridden 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 ``%{source-directory}/%{source-subdir}/`` and is the location that
    
    43
    + specific build element can use to look for build configuration files, currently autotools and cmake use this.
    
    44
    + 
    
    45
    + ``%{source-directory}`` and ``%{source-subdir}`` are by default set to ``.`` so that by default the location that
    
    46
    + the build tool will look for your configuration is in ``././``.
    
    47
    +
    
    48
    + The configuration commands are run in ``command-subdir`` and by default ``conf-root`` is ``././`` so if
    
    49
    + ``conf-root`` is not set the configuration files in ``command-subdir`` will be used.
    
    50
    +
    
    51
    + By setting ``source-directory`` to ``"%{build-root}/Source"`` and your source elements ``directory`` variable to
    
    52
    + ``Source`` then the configuration files in the directory ``source-subdir`` with-in your Source will be used.
    
    53
    + However the location were your configuration command will be run will still be were ever you set your
    
    54
    + ``command-subdir`` to be.
    
    55
    +
    
    56
    +* Install Location
    
    57
    +
    
    58
    +  You should not change the ``install-root`` variable as it is a special writeable location in the sandbox but it is
    
    59
    +  useful when writing custom install instructions as it may need to be supplied as the ``DESTDIR``, please see the
    
    60
    +  cmake build element for example.
    
    61
    +  
    
    26 62
     
    
    27 63
     Abstract method implementations
    
    28 64
     -------------------------------
    

  • buildstream/source.py
    ... ... @@ -20,6 +20,20 @@
    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 over ridden by the
    
    27
    +individual plugins.
    
    28
    +
    
    29
    +
    
    30
    +* Directory
    
    31
    +
    
    32
    +  The ``directory`` variable can be set for all sources of a type in project.conf
    
    33
    +  or per source within a element.
    
    34
    +  
    
    35
    +  This sets the location with in the build root that the content of the source will be 
    
    36
    +  loaded in to. If the location dose not exist it will be created.
    
    23 37
     
    
    24 38
     .. _core_source_abstract_methods:
    
    25 39
     
    

  • 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 of the autotools amhello project on a 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 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_buildstream'])
    
    44
    +    result.assert_success()
    
    45
    +    assert result.output == 'Hello, World!\n'



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