Phillip Smyth pushed to branch issue-638-validate-all-files at BuildStream / buildstream
Commits:
7 changed files:
- buildstream/_frontend/cli.py
- + tests/frontend/project_fail/elements/compose-all.bst
- + tests/frontend/project_fail/elements/import-dev.bst
- + tests/frontend/project_fail/elements/target.bst
- + tests/frontend/project_fail/files/dev-files/usr/include/pony.h
- + tests/frontend/project_fail/project.conf
- tests/frontend/show.py
Changes:
... | ... | @@ -166,6 +166,19 @@ original_main = click.BaseCommand.main |
166 | 166 |
click.BaseCommand.main = override_main
|
167 | 167 |
|
168 | 168 |
|
169 |
+def get_files(directory):
|
|
170 |
+ output = tuple()
|
|
171 |
+ directory = os.path.abspath(directory)
|
|
172 |
+ for root, _, files in os.walk(directory):
|
|
173 |
+ for file in files:
|
|
174 |
+ if file.endswith(".bst"):
|
|
175 |
+ relDir = os.path.relpath(root, directory)
|
|
176 |
+ relFile = os.path.join(relDir, file).strip("./")
|
|
177 |
+ relFile = relFile.replace('elements/', '')
|
|
178 |
+ output = output + (relFile,)
|
|
179 |
+ return output
|
|
180 |
+ |
|
181 |
+ |
|
169 | 182 |
##################################################################
|
170 | 183 |
# Main Options #
|
171 | 184 |
##################################################################
|
... | ... | @@ -489,6 +502,8 @@ def push(app, elements, deps, remote): |
489 | 502 |
@click.option('--deps', '-d', default='all',
|
490 | 503 |
type=click.Choice(['none', 'plan', 'run', 'build', 'all']),
|
491 | 504 |
help='The dependencies to show (default: all)')
|
505 |
+@click.option('--all', 'all_', default=False, is_flag=True,
|
|
506 |
+ help="Validate all files in project")
|
|
492 | 507 |
@click.option('--order', default="stage",
|
493 | 508 |
type=click.Choice(['stage', 'alpha']),
|
494 | 509 |
help='Staging or alphabetic ordering of dependencies')
|
... | ... | @@ -498,7 +513,7 @@ def push(app, elements, deps, remote): |
498 | 513 |
@click.argument('elements', nargs=-1,
|
499 | 514 |
type=click.Path(readable=False))
|
500 | 515 |
@click.pass_obj
|
501 |
-def show(app, elements, deps, except_, order, format_):
|
|
516 |
+def show(app, elements, deps, except_, order, format_, all_):
|
|
502 | 517 |
"""Show elements in the pipeline
|
503 | 518 |
|
504 | 519 |
By default this will show all of the dependencies of the
|
... | ... | @@ -545,6 +560,13 @@ def show(app, elements, deps, except_, order, format_): |
545 | 560 |
bst show target.bst --format \\
|
546 | 561 |
$'---------- %{name} ----------\\n%{vars}'
|
547 | 562 |
"""
|
563 |
+ if all_ and elements:
|
|
564 |
+ click.echo("ERROR: You can not use --all if you have defined an element", err=True)
|
|
565 |
+ sys.exit(-1)
|
|
566 |
+ |
|
567 |
+ if all_:
|
|
568 |
+ elements = get_files(app._main_options.get("directory"))
|
|
569 |
+ |
|
548 | 570 |
with app.initialized():
|
549 | 571 |
dependencies = app.stream.load_selection(elements,
|
550 | 572 |
selection=deps,
|
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
|
1 |
+kind: import
|
|
2 |
+sources:
|
|
3 |
+- kind: local
|
|
4 |
+ path: files/dev-files
|
1 |
+kind: stack
|
|
2 |
+description: |
|
|
3 |
+ |
|
4 |
+ Main stack target for the bst build test
|
|
5 |
+ |
|
6 |
+depends:
|
|
7 |
+- compose-all.bst
|
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__ */
|
1 |
+# Project config for frontend build test
|
|
2 |
+name: test
|
|
3 |
+ |
|
4 |
+element-path: elements
|
... | ... | @@ -46,6 +46,17 @@ def test_show_invalid_element_path(cli, datafiles): |
46 | 46 |
'show',
|
47 | 47 |
"foo.bst"])
|
48 | 48 |
|
49 |
+ |
|
50 |
+@pytest.mark.datafiles(DATA_DIR + "_fail")
|
|
51 |
+def test_show_fail(cli, datafiles):
|
|
52 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
53 |
+ prev_dir = os.getcwd()
|
|
54 |
+ os.chdir(project)
|
|
55 |
+ result = cli.run(project=project, silent=True, args=[
|
|
56 |
+ 'show',
|
|
57 |
+ '--all'])
|
|
58 |
+ os.chdir(prev_dir)
|
|
59 |
+ |
|
49 | 60 |
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
|
50 | 61 |
|
51 | 62 |
|