[Notes] [Git][BuildStream/buildstream][mablanch/448-autocompletion-broken-defaults] complete.py: Ensure paths get completed from 'element-path'



Title: GitLab

Martin Blanchard pushed to branch mablanch/448-autocompletion-broken-defaults at BuildStream / buildstream

Commits:

7 changed files:

Changes:

  • buildstream/_frontend/complete.py
    ... ... @@ -68,9 +68,10 @@ def complete_path(path_type, incomplete, base_directory='.'):
    68 68
             # If there was nothing on the left of the last separator,
    
    69 69
             # we are completing files in the filesystem root
    
    70 70
             base_path = os.path.join(base_directory, base_path)
    
    71
    -
    
    72
    -    elif os.path.isdir(incomplete):
    
    73
    -        base_path = incomplete
    
    71
    +    else:
    
    72
    +        incomplete_base_path = os.path.join(base_directory, incomplete)
    
    73
    +        if os.path.isdir(incomplete_base_path):
    
    74
    +            base_path = incomplete_base_path
    
    74 75
     
    
    75 76
         try:
    
    76 77
             if base_path:
    

  • tests/completions/completions.py
    ... ... @@ -212,6 +212,10 @@ def test_option_directory(datafiles, cli, cmd, word_idx, expected, subdir):
    212 212
         # Also try multi arguments together
    
    213 213
         ('no-element-path', 'bst --directory ../ checkout t ', 4, ['target.bst '], 'files'),
    
    214 214
         ('no-element-path', 'bst --directory ../ checkout target.bst ', 5, ['bin-files/', 'dev-files/'], 'files'),
    
    215
    +
    
    216
    +    # When element-path have sub-folders
    
    217
    +    ('sub-folders', 'bst show base', 2, ['base/wanted.bst '], None),
    
    218
    +    ('sub-folders', 'bst show base/', 2, ['base/wanted.bst '], None),
    
    215 219
     ])
    
    216 220
     def test_argument_element(datafiles, cli, project, cmd, word_idx, expected, subdir):
    
    217 221
         cwd = os.path.join(str(datafiles), project)
    

  • tests/completions/sub-folders/base/unwanted.bst
    1
    +kind: autotools
    
    2
    +description: |
    
    3
    +
    
    4
    +    Not auto-completed element

  • tests/completions/sub-folders/elements/base.bst
    1
    +kind: stack
    
    2
    +description: Base stack
    
    3
    +
    
    4
    +depends:
    
    5
    +- base/wanted.bst

  • tests/completions/sub-folders/elements/base/wanted.bst
    1
    +kind: autotools
    
    2
    +description: |
    
    3
    +
    
    4
    +    Auto-completed element

  • tests/completions/sub-folders/elements/hello.bst
    1
    +kind: autotools
    
    2
    +description: |
    
    3
    +
    
    4
    +    Hello world

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



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