[Notes] [Git][BuildStream/buildstream][chandan/fix-source-bundle] _stream.py: Ensure source-bundle's source directory exists



Title: GitLab

Chandan Singh pushed to branch chandan/fix-source-bundle at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • buildstream/_stream.py
    ... ... @@ -703,6 +703,7 @@ class Stream():
    703 703
     
    
    704 704
             # Create a temporary directory to build the source tree in
    
    705 705
             builddir = self._context.builddir
    
    706
    +        os.makedirs(builddir, exist_ok=True)
    
    706 707
             prefix = "{}-".format(target.normal_name)
    
    707 708
     
    
    708 709
             with TemporaryDirectory(prefix=prefix, dir=builddir) as tempdir:
    
    ... ... @@ -1088,6 +1089,7 @@ class Stream():
    1088 1089
             for element in elements:
    
    1089 1090
                 source_dir = os.path.join(directory, "source")
    
    1090 1091
                 element_source_dir = os.path.join(source_dir, element.normal_name)
    
    1092
    +            os.makedirs(element_source_dir)
    
    1091 1093
     
    
    1092 1094
                 element._stage_sources_at(element_source_dir)
    
    1093 1095
     
    

  • tests/frontend/project/elements/source-bundle/source-bundle-hello.bst
    1
    +kind: import
    
    2
    +description: the kind of this element must implement generate_script() method
    
    3
    +
    
    4
    +sources:
    
    5
    +- kind: local
    
    6
    +  path: files/source-bundle

  • tests/frontend/project/files/source-bundle/llamas.txt
    1
    +llamas

  • tests/frontend/source_bundle.py
    1
    +#
    
    2
    +#  Copyright (C) 2018 Bloomberg Finance LP
    
    3
    +#
    
    4
    +#  This program is free software; you can redistribute it and/or
    
    5
    +#  modify it under the terms of the GNU Lesser General Public
    
    6
    +#  License as published by the Free Software Foundation; either
    
    7
    +#  version 2 of the License, or (at your option) any later version.
    
    8
    +#
    
    9
    +#  This library is distributed in the hope that it will be useful,
    
    10
    +#  but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    11
    +#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    
    12
    +#  Lesser General Public License for more details.
    
    13
    +#
    
    14
    +#  You should have received a copy of the GNU Lesser General Public
    
    15
    +#  License along with this library. If not, see <http://www.gnu.org/licenses/>.
    
    16
    +#
    
    17
    +#  Authors: Chandan Singh <csingh43 bloomberg net>
    
    18
    +#
    
    19
    +
    
    20
    +import os
    
    21
    +import tarfile
    
    22
    +
    
    23
    +import pytest
    
    24
    +
    
    25
    +from tests.testutils import cli
    
    26
    +
    
    27
    +# Project directory
    
    28
    +DATA_DIR = os.path.join(
    
    29
    +    os.path.dirname(os.path.realpath(__file__)),
    
    30
    +    "project",
    
    31
    +)
    
    32
    +
    
    33
    +
    
    34
    +@pytest.mark.datafiles(DATA_DIR)
    
    35
    +def test_source_bundle(cli, tmpdir, datafiles):
    
    36
    +    project_path = os.path.join(datafiles.dirname, datafiles.basename)
    
    37
    +    element_name = 'source-bundle/source-bundle-hello.bst'
    
    38
    +    normal_name = 'source-bundle-source-bundle-hello'
    
    39
    +
    
    40
    +    # Verify that we can correctly produce a source-bundle
    
    41
    +    args = ['source-bundle', element_name, '--directory', str(tmpdir)]
    
    42
    +    result = cli.run(project=project_path, args=args)
    
    43
    +    result.assert_success()
    
    44
    +
    
    45
    +    # Verify that the source-bundle contains our sources and a build script
    
    46
    +    with tarfile.open(os.path.join(str(tmpdir), '{}.tar.gz'.format(normal_name))) as bundle:
    
    47
    +        assert os.path.join(normal_name, 'source', normal_name, 'llamas.txt') in bundle.getnames()
    
    48
    +        assert os.path.join(normal_name, 'build.sh') in bundle.getnames()



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