[Notes] [Git][BuildStream/buildstream][issue-638-validate-all-files] 4 commits: _project.py: Added `get_default_elements()`



Title: GitLab

Phillip Smyth pushed to branch issue-638-validate-all-files at BuildStream / buildstream

Commits:

23 changed files:

Changes:

  • NEWS
    ... ... @@ -12,6 +12,10 @@ buildstream 1.3.1
    12 12
         specific. Recommendation if you are building in Linux is to use the
    
    13 13
         ones being used in freedesktop-sdk project, for example
    
    14 14
     
    
    15
    +  o Running commands without elements specified will now attempt to use
    
    16
    +    the default element defined in the projcet configuration.
    
    17
    +    If no default element is defined, all elements in the project will be used
    
    18
    +
    
    15 19
       o All elements must now be suffixed with `.bst`
    
    16 20
         Attempting to use an element that does not have the `.bst` extension,
    
    17 21
         will result in a warning.
    

  • buildstream/_context.py
    ... ... @@ -32,7 +32,7 @@ from ._message import Message, MessageType
    32 32
     from ._profile import Topics, profile_start, profile_end
    
    33 33
     from ._artifactcache import ArtifactCache
    
    34 34
     from ._artifactcache.cascache import CASCache
    
    35
    -from ._workspaces import Workspaces, WorkspaceProjectCache, WORKSPACE_PROJECT_FILE
    
    35
    +from ._workspaces import Workspaces, WorkspaceProjectCache
    
    36 36
     from .plugin import _plugin_lookup
    
    37 37
     
    
    38 38
     
    
    ... ... @@ -649,20 +649,6 @@ class Context():
    649 649
                 self._cascache = CASCache(self.artifactdir)
    
    650 650
             return self._cascache
    
    651 651
     
    
    652
    -    # guess_element()
    
    653
    -    #
    
    654
    -    # Attempts to interpret which element the user intended to run commands on
    
    655
    -    #
    
    656
    -    # Returns:
    
    657
    -    #    (str) The name of the element, or None if no element can be guessed
    
    658
    -    def guess_element(self):
    
    659
    -        workspace_project_dir, _ = utils._search_upward_for_files(self._directory, [WORKSPACE_PROJECT_FILE])
    
    660
    -        if workspace_project_dir:
    
    661
    -            workspace_project = self._workspace_project_cache.get(workspace_project_dir)
    
    662
    -            return workspace_project.get_default_element()
    
    663
    -        else:
    
    664
    -            return None
    
    665
    -
    
    666 652
     
    
    667 653
     # _node_get_option_str()
    
    668 654
     #
    

  • buildstream/_frontend/cli.py
    ... ... @@ -306,7 +306,11 @@ def init(app, project_name, format_version, element_path, force):
    306 306
                     type=click.Path(readable=False))
    
    307 307
     @click.pass_obj
    
    308 308
     def build(app, elements, all_, track_, track_save, track_all, track_except, track_cross_junctions):
    
    309
    -    """Build elements in a pipeline"""
    
    309
    +    """Build elements in a pipeline
    
    310
    +
    
    311
    +       Declaring no elements with result in building a default element if one is declared in the project configuration.
    
    312
    +
    
    313
    +       If no default is declared, all elements in the project will be built"""
    
    310 314
     
    
    311 315
         if (track_except or track_cross_junctions) and not (track_ or track_all):
    
    312 316
             click.echo("ERROR: The --track-except and --track-cross-junctions options "
    
    ... ... @@ -318,9 +322,7 @@ def build(app, elements, all_, track_, track_save, track_all, track_except, trac
    318 322
     
    
    319 323
         with app.initialized(session_name="Build"):
    
    320 324
             if not all_ and not elements:
    
    321
    -            guessed_target = app.context.guess_element()
    
    322
    -            if guessed_target:
    
    323
    -                elements = (guessed_target,)
    
    325
    +            elements = app.project.get_default_elements()
    
    324 326
     
    
    325 327
             if track_all:
    
    326 328
                 track_ = elements
    
    ... ... @@ -352,6 +354,10 @@ def build(app, elements, all_, track_, track_save, track_all, track_except, trac
    352 354
     def fetch(app, elements, deps, track_, except_, track_cross_junctions):
    
    353 355
         """Fetch sources required to build the pipeline
    
    354 356
     
    
    357
    +       declaring no elements with result in fetching a default element if one is declared in the project configuration.
    
    358
    +
    
    359
    +       if no default is declared, all elements in the project will be fetched
    
    360
    +
    
    355 361
         By default this will only try to fetch sources which are
    
    356 362
         required for the build plan of the specified target element,
    
    357 363
         omitting sources for any elements which are already built
    
    ... ... @@ -377,9 +383,7 @@ def fetch(app, elements, deps, track_, except_, track_cross_junctions):
    377 383
     
    
    378 384
         with app.initialized(session_name="Fetch"):
    
    379 385
             if not elements:
    
    380
    -            guessed_target = app.context.guess_element()
    
    381
    -            if guessed_target:
    
    382
    -                elements = (guessed_target,)
    
    386
    +            elements = app.project.get_default_elements()
    
    383 387
     
    
    384 388
             app.stream.fetch(elements,
    
    385 389
                              selection=deps,
    
    ... ... @@ -407,6 +411,10 @@ def track(app, elements, deps, except_, cross_junctions):
    407 411
         """Consults the specified tracking branches for new versions available
    
    408 412
         to build and updates the project with any newly available references.
    
    409 413
     
    
    414
    +    Declaring no elements with result in tracking a default element if one is declared in the project configuration.
    
    415
    +
    
    416
    +    If no default is declared, all elements in the project will be tracked
    
    417
    +
    
    410 418
         By default this will track just the specified element, but you can also
    
    411 419
         update a whole tree of dependencies in one go.
    
    412 420
     
    
    ... ... @@ -418,9 +426,7 @@ def track(app, elements, deps, except_, cross_junctions):
    418 426
         """
    
    419 427
         with app.initialized(session_name="Track"):
    
    420 428
             if not elements:
    
    421
    -            guessed_target = app.context.guess_element()
    
    422
    -            if guessed_target:
    
    423
    -                elements = (guessed_target,)
    
    429
    +            elements = app.project.get_default_elements()
    
    424 430
     
    
    425 431
             # Substitute 'none' for 'redirect' so that element redirections
    
    426 432
             # will be done
    
    ... ... @@ -447,6 +453,10 @@ def track(app, elements, deps, except_, cross_junctions):
    447 453
     def pull(app, elements, deps, remote):
    
    448 454
         """Pull a built artifact from the configured remote artifact cache.
    
    449 455
     
    
    456
    +       Declaring no elements with result in pulling a default element if one is declared in the project configuration.
    
    457
    +
    
    458
    +       If no default is declared, all elements in the project will be pulled
    
    459
    +
    
    450 460
         By default the artifact will be pulled one of the configured caches
    
    451 461
         if possible, following the usual priority order. If the `--remote` flag
    
    452 462
         is given, only the specified cache will be queried.
    
    ... ... @@ -460,9 +470,7 @@ def pull(app, elements, deps, remote):
    460 470
     
    
    461 471
         with app.initialized(session_name="Pull"):
    
    462 472
             if not elements:
    
    463
    -            guessed_target = app.context.guess_element()
    
    464
    -            if guessed_target:
    
    465
    -                elements = (guessed_target,)
    
    473
    +            elements = app.project.get_default_elements()
    
    466 474
     
    
    467 475
             app.stream.pull(elements, selection=deps, remote=remote)
    
    468 476
     
    
    ... ... @@ -482,6 +490,10 @@ def pull(app, elements, deps, remote):
    482 490
     def push(app, elements, deps, remote):
    
    483 491
         """Push a built artifact to a remote artifact cache.
    
    484 492
     
    
    493
    +       Declaring no elements with result in push a default element if one is declared in the project configuration.
    
    494
    +
    
    495
    +       If no default is declared, all elements in the project will be pushed
    
    496
    +
    
    485 497
         The default destination is the highest priority configured cache. You can
    
    486 498
         override this by passing a different cache URL with the `--remote` flag.
    
    487 499
     
    
    ... ... @@ -497,9 +509,7 @@ def push(app, elements, deps, remote):
    497 509
         """
    
    498 510
         with app.initialized(session_name="Push"):
    
    499 511
             if not elements:
    
    500
    -            guessed_target = app.context.guess_element()
    
    501
    -            if guessed_target:
    
    502
    -                elements = (guessed_target,)
    
    512
    +            elements = app.project.get_default_elements()
    
    503 513
     
    
    504 514
             app.stream.push(elements, selection=deps, remote=remote)
    
    505 515
     
    
    ... ... @@ -526,6 +536,10 @@ def push(app, elements, deps, remote):
    526 536
     def show(app, elements, deps, except_, order, format_):
    
    527 537
         """Show elements in the pipeline
    
    528 538
     
    
    539
    +    Declaring no elements with result in showing a default element if one is declared in the project configuration.
    
    540
    +
    
    541
    +    If no default is declared, all elements in the project will be shown
    
    542
    +
    
    529 543
         By default this will show all of the dependencies of the
    
    530 544
         specified target element.
    
    531 545
     
    
    ... ... @@ -570,11 +584,10 @@ def show(app, elements, deps, except_, order, format_):
    570 584
             bst show target.bst --format \\
    
    571 585
                 $'---------- %{name} ----------\\n%{vars}'
    
    572 586
         """
    
    587
    +
    
    573 588
         with app.initialized():
    
    574 589
             if not elements:
    
    575
    -            guessed_target = app.context.guess_element()
    
    576
    -            if guessed_target:
    
    577
    -                elements = (guessed_target,)
    
    590
    +            elements = app.project.get_default_elements()
    
    578 591
     
    
    579 592
             dependencies = app.stream.load_selection(elements,
    
    580 593
                                                      selection=deps,
    
    ... ... @@ -611,6 +624,8 @@ def show(app, elements, deps, except_, order, format_):
    611 624
     def shell(app, element, sysroot, mount, isolate, build_, command):
    
    612 625
         """Run a command in the target element's sandbox environment
    
    613 626
     
    
    627
    +       Declaring no elements with result in opening a default element if one is declared in the project configuration.
    
    628
    +
    
    614 629
         This will stage a temporary sysroot for running the target
    
    615 630
         element, assuming it has already been built and all required
    
    616 631
         artifacts are in the local cache.
    
    ... ... @@ -636,9 +651,10 @@ def shell(app, element, sysroot, mount, isolate, build_, command):
    636 651
     
    
    637 652
         with app.initialized():
    
    638 653
             if not element:
    
    639
    -            element = app.context.guess_element()
    
    640
    -            if not element:
    
    654
    +            elements = app.project.get_default_elements(search_project=False)
    
    655
    +            if not elements:
    
    641 656
                     raise AppError('Missing argument "ELEMENT".')
    
    657
    +            element = elements[0]
    
    642 658
     
    
    643 659
             dependencies = app.stream.load_selection((element,), selection=PipelineSelection.NONE)
    
    644 660
             element = dependencies[0]
    
    ... ... @@ -683,6 +699,9 @@ def shell(app, element, sysroot, mount, isolate, build_, command):
    683 699
     @click.pass_obj
    
    684 700
     def checkout(app, element, location, force, deps, integrate, hardlinks, tar):
    
    685 701
         """Checkout a built artifact to the specified location
    
    702
    +
    
    703
    +       Declaring no elements with result in checking out a default element
    
    704
    +       if one is declared in the project configuration.
    
    686 705
         """
    
    687 706
         from ..element import Scope
    
    688 707
     
    
    ... ... @@ -708,9 +727,10 @@ def checkout(app, element, location, force, deps, integrate, hardlinks, tar):
    708 727
     
    
    709 728
         with app.initialized():
    
    710 729
             if not element:
    
    711
    -            element = app.context.guess_element()
    
    712
    -            if not element:
    
    730
    +            elements = app.project.get_default_elements(search_project=False)
    
    731
    +            if not elements:
    
    713 732
                     raise AppError('Missing argument "ELEMENT".')
    
    733
    +            element = elements[0]
    
    714 734
     
    
    715 735
             app.stream.checkout(element,
    
    716 736
                                 location=location,
    
    ... ... @@ -745,6 +765,9 @@ def checkout(app, element, location, force, deps, integrate, hardlinks, tar):
    745 765
     def source_checkout(app, element, location, force, deps, fetch_, except_,
    
    746 766
                         tar, build_scripts):
    
    747 767
         """Checkout sources of an element to the specified location
    
    768
    +
    
    769
    +       Declaring no elements with result in checking out the source of
    
    770
    +       a default element if one is declared in the project configuration.
    
    748 771
         """
    
    749 772
         if not element and not location:
    
    750 773
             click.echo("ERROR: LOCATION is not specified", err=True)
    
    ... ... @@ -757,9 +780,10 @@ def source_checkout(app, element, location, force, deps, fetch_, except_,
    757 780
     
    
    758 781
         with app.initialized():
    
    759 782
             if not element:
    
    760
    -            element = app.context.guess_element()
    
    761
    -            if not element:
    
    783
    +            elements = app.project.get_default_elements(search_project=False)
    
    784
    +            if not elements:
    
    762 785
                     raise AppError('Missing argument "ELEMENT".')
    
    786
    +            element = elements[0]
    
    763 787
     
    
    764 788
             app.stream.source_checkout(element,
    
    765 789
                                        location=location,
    
    ... ... @@ -824,10 +848,11 @@ def workspace_close(app, remove_dir, all_, elements):
    824 848
             if not (all_ or elements):
    
    825 849
                 # NOTE: I may need to revisit this when implementing multiple projects
    
    826 850
                 # opening one workspace.
    
    827
    -            element = app.context.guess_element()
    
    828
    -            if element:
    
    829
    -                elements = (element,)
    
    830
    -            else:
    
    851
    +            elements = app.project.get_default_elements(
    
    852
    +                search_project=False, use_project_defaults=False
    
    853
    +            )
    
    854
    +
    
    855
    +            if not elements:
    
    831 856
                     raise AppError('No elements specified')
    
    832 857
     
    
    833 858
             # Early exit if we specified `all` and there are no workspaces
    
    ... ... @@ -885,10 +910,11 @@ def workspace_reset(app, soft, track_, all_, elements):
    885 910
         with app.initialized():
    
    886 911
     
    
    887 912
             if not (all_ or elements):
    
    888
    -            element = app.context.guess_element()
    
    889
    -            if element:
    
    890
    -                elements = (element,)
    
    891
    -            else:
    
    913
    +            elements = app.project.get_default_elements(
    
    914
    +                search_project=False, use_project_defaults=False
    
    915
    +            )
    
    916
    +
    
    917
    +            if not elements:
    
    892 918
                     raise AppError('No elements specified to reset')
    
    893 919
     
    
    894 920
             if all_ and not app.stream.workspace_exists():
    

  • buildstream/_project.py
    ... ... @@ -228,7 +228,7 @@ class Project():
    228 228
                 'element-path', 'variables',
    
    229 229
                 'environment', 'environment-nocache',
    
    230 230
                 'split-rules', 'elements', 'plugins',
    
    231
    -            'aliases', 'name',
    
    231
    +            'aliases', 'name', 'defaults',
    
    232 232
                 'artifacts', 'options',
    
    233 233
                 'fail-on-overlap', 'shell', 'fatal-warnings',
    
    234 234
                 'ref-storage', 'sandbox', 'mirrors', 'remote-execution',
    
    ... ... @@ -391,6 +391,46 @@ class Project():
    391 391
             # Reset the element loader state
    
    392 392
             Element._reset_load_state()
    
    393 393
     
    
    394
    +    # get_default_elements()
    
    395
    +    #
    
    396
    +    # This function is used to gather either:
    
    397
    +    # The element the workspace was opened for if the workspace is not also a project
    
    398
    +    # The project default element (if defined in project.conf)
    
    399
    +    # or
    
    400
    +    # All elements in the project
    
    401
    +    #
    
    402
    +    def get_default_elements(self, *, search_project=True, use_project_defaults=True):
    
    403
    +
    
    404
    +        output = []
    
    405
    +
    
    406
    +        # If _invoked_from_workspace_element has a value,
    
    407
    +        # a workspace element was found before a project config
    
    408
    +        # Therefore the workspace does not contain a project
    
    409
    +        if self._invoked_from_workspace_element:
    
    410
    +            return (self._invoked_from_workspace_element,)
    
    411
    +
    
    412
    +        if use_project_defaults:
    
    413
    +            # The project is not required to have an element-path
    
    414
    +            element_directory = self._project_conf.get('element-path')
    
    415
    +
    
    416
    +            # The project may have a default element defined
    
    417
    +            default_element = self._project_conf.get("defaults", {}).get("targets", None)
    
    418
    +
    
    419
    +            if default_element:
    
    420
    +                return (default_element,)
    
    421
    +
    
    422
    +        if search_project:
    
    423
    +            directory = os.path.join(self.directory, element_directory)
    
    424
    +            for root, _, files in os.walk(directory):
    
    425
    +                for file in files:
    
    426
    +                    if file.endswith(".bst"):
    
    427
    +                        rel_dir = os.path.relpath(root, directory)
    
    428
    +                        rel_file = os.path.join(rel_dir, file).lstrip("./")
    
    429
    +                        output.append(rel_file)
    
    430
    +            return tuple(output)
    
    431
    +
    
    432
    +        return None
    
    433
    +
    
    394 434
         # _load():
    
    395 435
         #
    
    396 436
         # Loads the project configuration file in the project
    

  • tests/frontend/buildcheckout.py
    ... ... @@ -2,6 +2,7 @@ import os
    2 2
     import tarfile
    
    3 3
     import hashlib
    
    4 4
     import pytest
    
    5
    +import subprocess
    
    5 6
     from tests.testutils import cli, create_repo, ALL_REPO_KINDS, generate_junction
    
    6 7
     
    
    7 8
     from buildstream import _yaml
    
    ... ... @@ -60,6 +61,35 @@ def test_build_checkout(datafiles, cli, strict, hardlinks):
    60 61
         assert os.path.exists(filename)
    
    61 62
     
    
    62 63
     
    
    64
    +@pytest.mark.datafiles(DATA_DIR + "_world")
    
    65
    +def test_build_default_all(datafiles, cli):
    
    66
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    67
    +    result = cli.run(project=project, silent=True, args=['build'])
    
    68
    +
    
    69
    +    result.assert_success()
    
    70
    +    target_dir = os.path.join(cli.directory, DATA_DIR + "_world", "elements")
    
    71
    +    output_dir = os.path.join(cli.directory, "logs", "test")
    
    72
    +
    
    73
    +    expected = subprocess.Popen(('ls', target_dir), stdout=subprocess.PIPE)
    
    74
    +    expected = subprocess.check_output(("wc", "-w"), stdin=expected.stdout)
    
    75
    +
    
    76
    +    results = subprocess.Popen(('ls', output_dir), stdout=subprocess.PIPE)
    
    77
    +    results = subprocess.check_output(("wc", "-w"), stdin=results.stdout)
    
    78
    +
    
    79
    +    assert results == expected
    
    80
    +
    
    81
    +
    
    82
    +@pytest.mark.datafiles(DATA_DIR + "_default")
    
    83
    +def test_build_default(cli, datafiles):
    
    84
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    85
    +    result = cli.run(project=project, silent=True, args=['build'])
    
    86
    +
    
    87
    +    result.assert_success()
    
    88
    +    results = cli.get_element_state(project, "target2.bst")
    
    89
    +    expected = "cached"
    
    90
    +    assert results == expected
    
    91
    +
    
    92
    +
    
    63 93
     @pytest.mark.datafiles(DATA_DIR)
    
    64 94
     @pytest.mark.parametrize("strict,hardlinks", [
    
    65 95
         ("non-strict", "hardlinks"),
    

  • tests/frontend/project_default/elements/target.bst
    1
    +kind: stack
    
    2
    +description: |
    
    3
    +
    
    4
    +  Main stack target for the bst build test

  • tests/frontend/project_default/elements/target2.bst
    1
    +kind: stack
    
    2
    +description: |
    
    3
    +
    
    4
    +  Main stack target for the bst build test

  • tests/frontend/project_default/project.conf
    1
    +# Project config for frontend build test
    
    2
    +name: test
    
    3
    +
    
    4
    +element-path: elements
    
    5
    +
    
    6
    +fatal-warnings:
    
    7
    +- bad-element-suffix
    
    8
    +
    
    9
    +defaults:
    
    10
    + targets: target2.bst

  • tests/frontend/project_fail/elements/compose-all.bst
    1
    +kind: compose
    
    2
    +
    
    3
    +depends:
    
    4
    +- fileNAME: import-dev.bst
    
    5
    +  type: build
    
    6
    +
    
    7
    +config:
    
    8
    +  # Dont try running the sandbox, we dont have a
    
    9
    +  # runtime to run anything in this context.
    
    10
    +  integrate: False

  • tests/frontend/project_fail/elements/import-dev.bst
    1
    +kind: import
    
    2
    +sources:
    
    3
    +- kind: local
    
    4
    +  path: files/dev-files

  • tests/frontend/project_fail/elements/target.bst
    1
    +kind: stack
    
    2
    +description: |
    
    3
    +
    
    4
    +  Main stack target for the bst build test
    
    5
    +
    
    6
    +depends:
    
    7
    +- compose-all.bst

  • tests/frontend/project_fail/files/dev-files/usr/include/pony.h
    1
    +#ifndef __PONY_H__
    
    2
    +#define __PONY_H__
    
    3
    +
    
    4
    +#define PONY_BEGIN "Once upon a time, there was a pony."
    
    5
    +#define PONY_END "And they lived happily ever after, the end."
    
    6
    +
    
    7
    +#define MAKE_PONY(story)  \
    
    8
    +  PONY_BEGIN \
    
    9
    +  story \
    
    10
    +  PONY_END
    
    11
    +
    
    12
    +#endif /* __PONY_H__ */

  • tests/frontend/project_fail/project.conf
    1
    +# Project config for frontend build test
    
    2
    +name: test
    
    3
    +
    
    4
    +element-path: elements

  • tests/frontend/project_world/elements/checkout-deps.bst
    1
    +kind: stack
    
    2
    +description: It is important for this element to have both build and runtime dependencies
    
    3
    +depends:
    
    4
    +- filename: import-dev.bst
    
    5
    +  type: build
    
    6
    +- filename: import-bin.bst
    
    7
    +  type: runtime

  • tests/frontend/project_world/elements/compose-all.bst
    1
    +kind: compose
    
    2
    +
    
    3
    +depends:
    
    4
    +- filename: import-bin.bst
    
    5
    +  type: build
    
    6
    +- filename: import-dev.bst
    
    7
    +  type: build
    
    8
    +
    
    9
    +config:
    
    10
    +  # Dont try running the sandbox, we dont have a
    
    11
    +  # runtime to run anything in this context.
    
    12
    +  integrate: False

  • tests/frontend/project_world/elements/compose-exclude-dev.bst
    1
    +kind: compose
    
    2
    +
    
    3
    +depends:
    
    4
    +- filename: import-bin.bst
    
    5
    +  type: build
    
    6
    +- filename: import-dev.bst
    
    7
    +  type: build
    
    8
    +
    
    9
    +config:
    
    10
    +  # Dont try running the sandbox, we dont have a
    
    11
    +  # runtime to run anything in this context.
    
    12
    +  integrate: False
    
    13
    +
    
    14
    +  # Exclude the dev domain
    
    15
    +  exclude:
    
    16
    +  - devel

  • tests/frontend/project_world/elements/compose-include-bin.bst
    1
    +kind: compose
    
    2
    +
    
    3
    +depends:
    
    4
    +- filename: import-bin.bst
    
    5
    +  type: build
    
    6
    +- filename: import-dev.bst
    
    7
    +  type: build
    
    8
    +
    
    9
    +config:
    
    10
    +  # Dont try running the sandbox, we dont have a
    
    11
    +  # runtime to run anything in this context.
    
    12
    +  integrate: False
    
    13
    +
    
    14
    +  # Only include the runtim
    
    15
    +  include:
    
    16
    +  - runtime

  • tests/frontend/project_world/elements/import-bin.bst
    1
    +kind: stack

  • tests/frontend/project_world/elements/import-dev.bst
    1
    +kind: stack

  • tests/frontend/project_world/elements/rebuild-target.bst
    1
    +kind: compose
    
    2
    +
    
    3
    +build-depends:
    
    4
    +- target.bst

  • tests/frontend/project_world/elements/target.bst
    1
    +kind: stack
    
    2
    +description: |
    
    3
    +
    
    4
    +  Main stack target for the bst build test
    
    5
    +
    
    6
    +depends:
    
    7
    +- import-bin.bst
    
    8
    +- compose-all.bst

  • tests/frontend/project_world/project.conf
    1
    +# Project config for frontend build test
    
    2
    +name: test
    
    3
    +
    
    4
    +element-path: elements
    
    5
    +
    
    6
    +fatal-warnings:
    
    7
    +- bad-element-suffix

  • tests/frontend/show.py
    ... ... @@ -46,6 +46,27 @@ def test_show_invalid_element_path(cli, datafiles):
    46 46
             'show',
    
    47 47
             "foo.bst"])
    
    48 48
     
    
    49
    +
    
    50
    +@pytest.mark.datafiles(DATA_DIR + "_default")
    
    51
    +def test_show_default(cli, datafiles):
    
    52
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    53
    +    result = cli.run(project=project, silent=True, args=[
    
    54
    +        'show'])
    
    55
    +
    
    56
    +    result.assert_success()
    
    57
    +
    
    58
    +    # Get the result output of "[state sha element]" and turn into a list
    
    59
    +    results = result.output.strip().split(" ")
    
    60
    +    expected = 'target2.bst'
    
    61
    +    assert results[2] == expected
    
    62
    +
    
    63
    +
    
    64
    +@pytest.mark.datafiles(DATA_DIR + "_fail")
    
    65
    +def test_show_fail(cli, datafiles):
    
    66
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    67
    +    result = cli.run(project=project, silent=True, args=[
    
    68
    +        'show'])
    
    69
    +
    
    49 70
         result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
    
    50 71
     
    
    51 72
     
    



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