[Notes] [Git][BuildStream/buildstream][richardmaw/shell-multi-stage] 2 commits: tests: Test multiple-element runtime and workspace shells



Title: GitLab

richardmaw-codethink pushed to branch richardmaw/shell-multi-stage at BuildStream / buildstream

Commits:

4 changed files:

Changes:

  • NEWS
    ... ... @@ -2,6 +2,9 @@
    2 2
     buildstream 1.3.1
    
    3 3
     =================
    
    4 4
     
    
    5
    +  o `bst shell` learned the `-e` option for staging multiple elements
    
    6
    +    provided the element's kind implements `BST_GRANULAR_STAGE`.
    
    7
    +
    
    5 8
       o BREAKING CHANGE: The 'manual' element lost its default 'MAKEFLAGS' and 'V'
    
    6 9
         environment variables. There is already a 'make' element with the same
    
    7 10
         variables. Note that this is a breaking change, it will require users to
    

  • tests/integration/project/elements/shell/adds-bar.bst
    1
    +kind: manual
    
    2
    +depends:
    
    3
    +- base.bst
    
    4
    +
    
    5
    +config:
    
    6
    +  install-commands:
    
    7
    +  - |
    
    8
    +    install -D -m775 /proc/self/fd/0 %{install-root}%{bindir}/bar <<\EOF
    
    9
    +    #!/bin/sh
    
    10
    +    echo bar
    
    11
    +    EOF

  • tests/integration/project/elements/shell/adds-foo.bst
    1
    +kind: manual
    
    2
    +depends:
    
    3
    +- base.bst
    
    4
    +
    
    5
    +config:
    
    6
    +  install-commands:
    
    7
    +  - |
    
    8
    +    install -D -m775 /proc/self/fd/0 %{install-root}%{bindir}/foo <<\EOF
    
    9
    +    #!/bin/sh
    
    10
    +    echo foo
    
    11
    +    EOF

  • tests/integration/shell.py
    ... ... @@ -28,11 +28,22 @@ DATA_DIR = os.path.join(
    28 28
     #    config (dict): A project.conf dictionary to composite over the default
    
    29 29
     #    mount (tuple): A (host, target) tuple for the `--mount` option
    
    30 30
     #    element (str): The element to build and run a shell with
    
    31
    +#    elements (list): Other elements to build and run a shell with
    
    31 32
     #    isolate (bool): Whether to pass --isolate to `bst shell`
    
    32 33
     #
    
    33
    -def execute_shell(cli, project, command, *, config=None, mount=None, element='base.bst', isolate=False):
    
    34
    +def execute_shell(cli, project, command, *, config=None, mount=None, element=None, elements=None, isolate=False):
    
    35
    +    assert element is None or elements is None, "Cannot mix single element and multi-element list options"
    
    34 36
         # Ensure the element is built
    
    35
    -    result = cli.run(project=project, project_config=config, args=['build', element])
    
    37
    +    if element is None and elements is None:
    
    38
    +        element = 'base.bst'
    
    39
    +    if elements is None:
    
    40
    +        elements = []
    
    41
    +
    
    42
    +    args = ['build']
    
    43
    +    args.extend(elements)
    
    44
    +    if element is not None:
    
    45
    +        args.append(element)
    
    46
    +    result = cli.run(project=project, project_config=config, args=args)
    
    36 47
         assert result.exit_code == 0
    
    37 48
     
    
    38 49
         args = ['shell']
    
    ... ... @@ -41,7 +52,10 @@ def execute_shell(cli, project, command, *, config=None, mount=None, element='ba
    41 52
         if mount is not None:
    
    42 53
             host_path, target_path = mount
    
    43 54
             args += ['--mount', host_path, target_path]
    
    44
    -    args += [element, '--'] + command
    
    55
    +    args += ["-e" + e for e in elements]
    
    56
    +    if element is not None:
    
    57
    +        args.append(element)
    
    58
    +    args += ['--'] + command
    
    45 59
     
    
    46 60
         return cli.run(project=project, project_config=config, args=args)
    
    47 61
     
    
    ... ... @@ -354,3 +368,43 @@ def test_integration_devices(cli, tmpdir, datafiles):
    354 368
     
    
    355 369
         result = execute_shell(cli, project, ["true"], element=element_name)
    
    356 370
         assert result.exit_code == 0
    
    371
    +
    
    372
    +
    
    373
    +# Test multiple element shell
    
    374
    +@pytest.mark.integration
    
    375
    +@pytest.mark.datafiles(DATA_DIR)
    
    376
    +def test_shell_multiple_elements(cli, tmpdir, datafiles):
    
    377
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    378
    +
    
    379
    +    result = execute_shell(cli, project, ["sh", "-c", "foo && bar"],
    
    380
    +                           elements=["shell/adds-foo.bst", "shell/adds-bar.bst"])
    
    381
    +    assert result.exit_code == 0
    
    382
    +
    
    383
    +
    
    384
    +# Test multiple element build shell
    
    385
    +@pytest.mark.integration
    
    386
    +@pytest.mark.datafiles(DATA_DIR)
    
    387
    +def test_shell_multiple_workspace(cli, tmpdir, datafiles):
    
    388
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    389
    +    elements = {'workspace/workspace-mount.bst': os.path.join(cli.directory, 'workspace-mount'),
    
    390
    +                'make/makehello.bst': os.path.join(cli.directory, 'makehello')}
    
    391
    +
    
    392
    +    for element, workspace in elements.items():
    
    393
    +        res = cli.run(project=project, args=['workspace', 'open', element, '--directory', workspace])
    
    394
    +        assert res.exit_code == 0
    
    395
    +
    
    396
    +    for workspace in elements.values():
    
    397
    +        with open(os.path.join(workspace, "workspace-exists"), "w") as f:
    
    398
    +            pass
    
    399
    +
    
    400
    +    # Ensure the dependencies of our build failing element are built
    
    401
    +    result = cli.run(project=project, args=['build', 'base.bst'])
    
    402
    +    assert result.exit_code == 0
    
    403
    +
    
    404
    +    args = ['shell', '--build'] + ['-e' + e for e in elements]
    
    405
    +    args += ['--', 'sh', '-c',
    
    406
    +             'test -e /buildstream/test/workspace/workspace-mount.bst/workspace-exists && \
    
    407
    +              test -e /buildstream/test/make/makehello.bst/workspace-exists']
    
    408
    +    result = cli.run(project=project, args=args)
    
    409
    +    assert result.exit_code == 0
    
    410
    +    assert result.output == ''



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