Jürg Billeter pushed to branch issue-638-validate-all-files at BuildStream / buildstream
Commits:
-
63b02f7c
by James Ennis at 2019-01-17T15:13:27Z
-
f64ee46f
by James Ennis at 2019-01-17T17:02:28Z
-
2cb37a7e
by James Ennis at 2019-01-18T09:31:24Z
-
56ec33cc
by Valentin David at 2019-01-18T11:14:41Z
-
ad2df651
by Javier Jardón at 2019-01-18T12:01:56Z
-
56a24daa
by Phillip Smyth at 2019-01-18T14:36:27Z
-
2749a7f7
by Phillip Smyth at 2019-01-18T14:37:53Z
-
5f524402
by Phillip Smyth at 2019-01-18T14:38:31Z
-
50a38067
by Jürg Billeter at 2019-01-18T14:56:19Z
-
ab397337
by Phillip Smyth at 2019-01-18T14:56:19Z
-
9d25b24e
by Phillip Smyth at 2019-01-18T14:56:19Z
26 changed files:
- .gitlab-ci.yml
- NEWS
- buildstream/_context.py
- buildstream/_frontend/cli.py
- buildstream/_profile.py
- buildstream/_project.py
- buildstream/data/projectconfig.yaml
- tests/frontend/buildcheckout.py
- + tests/frontend/project_default/elements/target.bst
- + tests/frontend/project_default/elements/target2.bst
- + tests/frontend/project_default/project.conf
- + 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/project_world/elements/checkout-deps.bst
- + tests/frontend/project_world/elements/compose-all.bst
- + tests/frontend/project_world/elements/compose-exclude-dev.bst
- + tests/frontend/project_world/elements/compose-include-bin.bst
- + tests/frontend/project_world/elements/import-bin.bst
- + tests/frontend/project_world/elements/import-dev.bst
- + tests/frontend/project_world/elements/rebuild-target.bst
- + tests/frontend/project_world/elements/target.bst
- + tests/frontend/project_world/project.conf
- tests/frontend/show.py
Changes:
| ... | ... | @@ -185,6 +185,9 @@ docs: |
| 185 | 185 |
- pip3 install --user -e ${BST_EXT_URL}@${BST_EXT_REF}#egg=bst_ext
|
| 186 | 186 |
- git clone https://gitlab.com/freedesktop-sdk/freedesktop-sdk.git
|
| 187 | 187 |
- git -C freedesktop-sdk checkout ${FD_SDK_REF}
|
| 188 |
+ artifacts:
|
|
| 189 |
+ paths:
|
|
| 190 |
+ - "${HOME}/.cache/buildstream/logs"
|
|
| 188 | 191 |
only:
|
| 189 | 192 |
- schedules
|
| 190 | 193 |
|
| ... | ... | @@ -20,6 +20,10 @@ buildstream 1.3.1 |
| 20 | 20 |
specific. Recommendation if you are building in Linux is to use the
|
| 21 | 21 |
ones being used in freedesktop-sdk project, for example
|
| 22 | 22 |
|
| 23 |
+ o Running commands without elements specified will now attempt to use
|
|
| 24 |
+ the default targets defined in the project configuration.
|
|
| 25 |
+ If no default target is defined, all elements in the project will be used.
|
|
| 26 |
+ |
|
| 23 | 27 |
o All elements must now be suffixed with `.bst`
|
| 24 | 28 |
Attempting to use an element that does not have the `.bst` extension,
|
| 25 | 29 |
will result in a warning.
|
| ... | ... | @@ -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 ._cas 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 |
from .sandbox import SandboxRemote
|
| 38 | 38 |
|
| ... | ... | @@ -657,20 +657,6 @@ class Context(): |
| 657 | 657 |
self._cascache = CASCache(self.artifactdir)
|
| 658 | 658 |
return self._cascache
|
| 659 | 659 |
|
| 660 |
- # guess_element()
|
|
| 661 |
- #
|
|
| 662 |
- # Attempts to interpret which element the user intended to run commands on
|
|
| 663 |
- #
|
|
| 664 |
- # Returns:
|
|
| 665 |
- # (str) The name of the element, or None if no element can be guessed
|
|
| 666 |
- def guess_element(self):
|
|
| 667 |
- workspace_project_dir, _ = utils._search_upward_for_files(self._directory, [WORKSPACE_PROJECT_FILE])
|
|
| 668 |
- if workspace_project_dir:
|
|
| 669 |
- workspace_project = self._workspace_project_cache.get(workspace_project_dir)
|
|
| 670 |
- return workspace_project.get_default_element()
|
|
| 671 |
- else:
|
|
| 672 |
- return None
|
|
| 673 |
- |
|
| 674 | 660 |
|
| 675 | 661 |
# _node_get_option_str()
|
| 676 | 662 |
#
|
| ... | ... | @@ -342,7 +342,11 @@ def init(app, project_name, format_version, element_path, force): |
| 342 | 342 |
type=click.Path(readable=False))
|
| 343 | 343 |
@click.pass_obj
|
| 344 | 344 |
def build(app, elements, all_, track_, track_save, track_all, track_except, track_cross_junctions):
|
| 345 |
- """Build elements in a pipeline"""
|
|
| 345 |
+ """Build elements in a pipeline
|
|
| 346 |
+ |
|
| 347 |
+ Declaring no elements with result in building a default element if one is declared in the project configuration.
|
|
| 348 |
+ |
|
| 349 |
+ If no default is declared, all elements in the project will be built"""
|
|
| 346 | 350 |
|
| 347 | 351 |
if (track_except or track_cross_junctions) and not (track_ or track_all):
|
| 348 | 352 |
click.echo("ERROR: The --track-except and --track-cross-junctions options "
|
| ... | ... | @@ -354,9 +358,7 @@ def build(app, elements, all_, track_, track_save, track_all, track_except, trac |
| 354 | 358 |
|
| 355 | 359 |
with app.initialized(session_name="Build"):
|
| 356 | 360 |
if not all_ and not elements:
|
| 357 |
- guessed_target = app.context.guess_element()
|
|
| 358 |
- if guessed_target:
|
|
| 359 |
- elements = (guessed_target,)
|
|
| 361 |
+ elements = app.project.get_default_targets()
|
|
| 360 | 362 |
|
| 361 | 363 |
if track_all:
|
| 362 | 364 |
track_ = elements
|
| ... | ... | @@ -383,6 +385,10 @@ def build(app, elements, all_, track_, track_save, track_all, track_except, trac |
| 383 | 385 |
def pull(app, elements, deps, remote):
|
| 384 | 386 |
"""Pull a built artifact from the configured remote artifact cache.
|
| 385 | 387 |
|
| 388 |
+ Declaring no elements with result in pulling a default element if one is declared in the project configuration.
|
|
| 389 |
+ |
|
| 390 |
+ If no default is declared, all elements in the project will be pulled
|
|
| 391 |
+ |
|
| 386 | 392 |
By default the artifact will be pulled one of the configured caches
|
| 387 | 393 |
if possible, following the usual priority order. If the `--remote` flag
|
| 388 | 394 |
is given, only the specified cache will be queried.
|
| ... | ... | @@ -396,9 +402,7 @@ def pull(app, elements, deps, remote): |
| 396 | 402 |
|
| 397 | 403 |
with app.initialized(session_name="Pull"):
|
| 398 | 404 |
if not elements:
|
| 399 |
- guessed_target = app.context.guess_element()
|
|
| 400 |
- if guessed_target:
|
|
| 401 |
- elements = (guessed_target,)
|
|
| 405 |
+ elements = app.project.get_default_targets()
|
|
| 402 | 406 |
|
| 403 | 407 |
app.stream.pull(elements, selection=deps, remote=remote)
|
| 404 | 408 |
|
| ... | ... | @@ -418,6 +422,10 @@ def pull(app, elements, deps, remote): |
| 418 | 422 |
def push(app, elements, deps, remote):
|
| 419 | 423 |
"""Push a built artifact to a remote artifact cache.
|
| 420 | 424 |
|
| 425 |
+ Declaring no elements with result in push a default element if one is declared in the project configuration.
|
|
| 426 |
+ |
|
| 427 |
+ If no default is declared, all elements in the project will be pushed
|
|
| 428 |
+ |
|
| 421 | 429 |
The default destination is the highest priority configured cache. You can
|
| 422 | 430 |
override this by passing a different cache URL with the `--remote` flag.
|
| 423 | 431 |
|
| ... | ... | @@ -433,9 +441,7 @@ def push(app, elements, deps, remote): |
| 433 | 441 |
"""
|
| 434 | 442 |
with app.initialized(session_name="Push"):
|
| 435 | 443 |
if not elements:
|
| 436 |
- guessed_target = app.context.guess_element()
|
|
| 437 |
- if guessed_target:
|
|
| 438 |
- elements = (guessed_target,)
|
|
| 444 |
+ elements = app.project.get_default_targets()
|
|
| 439 | 445 |
|
| 440 | 446 |
app.stream.push(elements, selection=deps, remote=remote)
|
| 441 | 447 |
|
| ... | ... | @@ -462,6 +468,10 @@ def push(app, elements, deps, remote): |
| 462 | 468 |
def show(app, elements, deps, except_, order, format_):
|
| 463 | 469 |
"""Show elements in the pipeline
|
| 464 | 470 |
|
| 471 |
+ Declaring no elements with result in showing a default element if one is declared in the project configuration.
|
|
| 472 |
+ |
|
| 473 |
+ If no default is declared, all elements in the project will be shown
|
|
| 474 |
+ |
|
| 465 | 475 |
By default this will show all of the dependencies of the
|
| 466 | 476 |
specified target element.
|
| 467 | 477 |
|
| ... | ... | @@ -506,11 +516,10 @@ def show(app, elements, deps, except_, order, format_): |
| 506 | 516 |
bst show target.bst --format \\
|
| 507 | 517 |
$'---------- %{name} ----------\\n%{vars}'
|
| 508 | 518 |
"""
|
| 519 |
+ |
|
| 509 | 520 |
with app.initialized():
|
| 510 | 521 |
if not elements:
|
| 511 |
- guessed_target = app.context.guess_element()
|
|
| 512 |
- if guessed_target:
|
|
| 513 |
- elements = (guessed_target,)
|
|
| 522 |
+ elements = app.project.get_default_targets()
|
|
| 514 | 523 |
|
| 515 | 524 |
dependencies = app.stream.load_selection(elements,
|
| 516 | 525 |
selection=deps,
|
| ... | ... | @@ -550,6 +559,8 @@ def show(app, elements, deps, except_, order, format_): |
| 550 | 559 |
def shell(app, element, sysroot, mount, isolate, build_, cli_buildtree, command):
|
| 551 | 560 |
"""Run a command in the target element's sandbox environment
|
| 552 | 561 |
|
| 562 |
+ Declaring no elements with result in opening a default element if one is declared in the project configuration.
|
|
| 563 |
+ |
|
| 553 | 564 |
This will stage a temporary sysroot for running the target
|
| 554 | 565 |
element, assuming it has already been built and all required
|
| 555 | 566 |
artifacts are in the local cache.
|
| ... | ... | @@ -577,7 +588,7 @@ def shell(app, element, sysroot, mount, isolate, build_, cli_buildtree, command) |
| 577 | 588 |
|
| 578 | 589 |
with app.initialized():
|
| 579 | 590 |
if not element:
|
| 580 |
- element = app.context.guess_element()
|
|
| 591 |
+ element = app.project.get_default_target()
|
|
| 581 | 592 |
if not element:
|
| 582 | 593 |
raise AppError('Missing argument "ELEMENT".')
|
| 583 | 594 |
|
| ... | ... | @@ -642,6 +653,9 @@ def shell(app, element, sysroot, mount, isolate, build_, cli_buildtree, command) |
| 642 | 653 |
@click.pass_obj
|
| 643 | 654 |
def checkout(app, element, location, force, deps, integrate, hardlinks, tar):
|
| 644 | 655 |
"""Checkout a built artifact to the specified location
|
| 656 |
+ |
|
| 657 |
+ Declaring no elements with result in checking out a default element
|
|
| 658 |
+ if one is declared in the project configuration.
|
|
| 645 | 659 |
"""
|
| 646 | 660 |
from ..element import Scope
|
| 647 | 661 |
|
| ... | ... | @@ -667,7 +681,7 @@ def checkout(app, element, location, force, deps, integrate, hardlinks, tar): |
| 667 | 681 |
|
| 668 | 682 |
with app.initialized():
|
| 669 | 683 |
if not element:
|
| 670 |
- element = app.context.guess_element()
|
|
| 684 |
+ element = app.project.get_default_target()
|
|
| 671 | 685 |
if not element:
|
| 672 | 686 |
raise AppError('Missing argument "ELEMENT".')
|
| 673 | 687 |
|
| ... | ... | @@ -708,6 +722,10 @@ def source(): |
| 708 | 722 |
def source_fetch(app, elements, deps, track_, except_, track_cross_junctions):
|
| 709 | 723 |
"""Fetch sources required to build the pipeline
|
| 710 | 724 |
|
| 725 |
+ declaring no elements with result in fetching a default element if one is declared in the project configuration.
|
|
| 726 |
+ |
|
| 727 |
+ if no default is declared, all elements in the project will be fetched
|
|
| 728 |
+ |
|
| 711 | 729 |
By default this will only try to fetch sources which are
|
| 712 | 730 |
required for the build plan of the specified target element,
|
| 713 | 731 |
omitting sources for any elements which are already built
|
| ... | ... | @@ -733,9 +751,7 @@ def source_fetch(app, elements, deps, track_, except_, track_cross_junctions): |
| 733 | 751 |
|
| 734 | 752 |
with app.initialized(session_name="Fetch"):
|
| 735 | 753 |
if not elements:
|
| 736 |
- guessed_target = app.context.guess_element()
|
|
| 737 |
- if guessed_target:
|
|
| 738 |
- elements = (guessed_target,)
|
|
| 754 |
+ elements = app.project.get_default_targets()
|
|
| 739 | 755 |
|
| 740 | 756 |
app.stream.fetch(elements,
|
| 741 | 757 |
selection=deps,
|
| ... | ... | @@ -763,6 +779,10 @@ def source_track(app, elements, deps, except_, cross_junctions): |
| 763 | 779 |
"""Consults the specified tracking branches for new versions available
|
| 764 | 780 |
to build and updates the project with any newly available references.
|
| 765 | 781 |
|
| 782 |
+ Declaring no elements with result in tracking a default element if one is declared in the project configuration.
|
|
| 783 |
+ |
|
| 784 |
+ If no default is declared, all elements in the project will be tracked
|
|
| 785 |
+ |
|
| 766 | 786 |
By default this will track just the specified element, but you can also
|
| 767 | 787 |
update a whole tree of dependencies in one go.
|
| 768 | 788 |
|
| ... | ... | @@ -774,9 +794,7 @@ def source_track(app, elements, deps, except_, cross_junctions): |
| 774 | 794 |
"""
|
| 775 | 795 |
with app.initialized(session_name="Track"):
|
| 776 | 796 |
if not elements:
|
| 777 |
- guessed_target = app.context.guess_element()
|
|
| 778 |
- if guessed_target:
|
|
| 779 |
- elements = (guessed_target,)
|
|
| 797 |
+ elements = app.project.get_default_targets()
|
|
| 780 | 798 |
|
| 781 | 799 |
# Substitute 'none' for 'redirect' so that element redirections
|
| 782 | 800 |
# will be done
|
| ... | ... | @@ -812,6 +830,9 @@ def source_track(app, elements, deps, except_, cross_junctions): |
| 812 | 830 |
def source_checkout(app, element, location, force, deps, fetch_, except_,
|
| 813 | 831 |
tar, build_scripts):
|
| 814 | 832 |
"""Checkout sources of an element to the specified location
|
| 833 |
+ |
|
| 834 |
+ Declaring no elements with result in checking out the source of
|
|
| 835 |
+ a default element if one is declared in the project configuration.
|
|
| 815 | 836 |
"""
|
| 816 | 837 |
if not element and not location:
|
| 817 | 838 |
click.echo("ERROR: LOCATION is not specified", err=True)
|
| ... | ... | @@ -824,7 +845,7 @@ def source_checkout(app, element, location, force, deps, fetch_, except_, |
| 824 | 845 |
|
| 825 | 846 |
with app.initialized():
|
| 826 | 847 |
if not element:
|
| 827 |
- element = app.context.guess_element()
|
|
| 848 |
+ element = app.project.get_default_target()
|
|
| 828 | 849 |
if not element:
|
| 829 | 850 |
raise AppError('Missing argument "ELEMENT".')
|
| 830 | 851 |
|
| ... | ... | @@ -890,7 +911,7 @@ def workspace_close(app, remove_dir, all_, elements): |
| 890 | 911 |
if not (all_ or elements):
|
| 891 | 912 |
# NOTE: I may need to revisit this when implementing multiple projects
|
| 892 | 913 |
# opening one workspace.
|
| 893 |
- element = app.context.guess_element()
|
|
| 914 |
+ element = app.project.get_default_target()
|
|
| 894 | 915 |
if element:
|
| 895 | 916 |
elements = (element,)
|
| 896 | 917 |
else:
|
| ... | ... | @@ -951,7 +972,7 @@ def workspace_reset(app, soft, track_, all_, elements): |
| 951 | 972 |
with app.initialized():
|
| 952 | 973 |
|
| 953 | 974 |
if not (all_ or elements):
|
| 954 |
- element = app.context.guess_element()
|
|
| 975 |
+ element = app.project.get_default_target()
|
|
| 955 | 976 |
if element:
|
| 956 | 977 |
elements = (element,)
|
| 957 | 978 |
else:
|
| ... | ... | @@ -62,15 +62,24 @@ class Profile(): |
| 62 | 62 |
def end(self):
|
| 63 | 63 |
self.profiler.disable()
|
| 64 | 64 |
|
| 65 |
+ dt = datetime.datetime.fromtimestamp(self.start)
|
|
| 66 |
+ timestamp = dt.strftime('%Y%m%dT%H%M%S')
|
|
| 67 |
+ |
|
| 65 | 68 |
filename = self.key.replace('/', '-')
|
| 66 | 69 |
filename = filename.replace('.', '-')
|
| 67 |
- filename = os.path.join(os.getcwd(), 'profile-' + filename + '.log')
|
|
| 70 |
+ filename = os.path.join(os.getcwd(), 'profile-' + timestamp + '-' + filename)
|
|
| 68 | 71 |
|
| 69 |
- with open(filename, "a", encoding="utf-8") as f:
|
|
| 72 |
+ time_ = dt.strftime('%Y-%m-%d %H:%M:%S') # Human friendly format
|
|
| 73 |
+ self.__write_log(filename + '.log', time_)
|
|
| 74 |
+ |
|
| 75 |
+ self.__write_binary(filename + '.cprofile')
|
|
| 70 | 76 |
|
| 71 |
- dt = datetime.datetime.fromtimestamp(self.start)
|
|
| 72 |
- time_ = dt.strftime('%Y-%m-%d %H:%M:%S')
|
|
| 77 |
+ ########################################
|
|
| 78 |
+ # Private Methods #
|
|
| 79 |
+ ########################################
|
|
| 73 | 80 |
|
| 81 |
+ def __write_log(self, filename, time_):
|
|
| 82 |
+ with open(filename, "a", encoding="utf-8") as f:
|
|
| 74 | 83 |
heading = '================================================================\n'
|
| 75 | 84 |
heading += 'Profile for key: {}\n'.format(self.key)
|
| 76 | 85 |
heading += 'Started at: {}\n'.format(time_)
|
| ... | ... | @@ -81,6 +90,9 @@ class Profile(): |
| 81 | 90 |
ps = pstats.Stats(self.profiler, stream=f).sort_stats('cumulative')
|
| 82 | 91 |
ps.print_stats()
|
| 83 | 92 |
|
| 93 |
+ def __write_binary(self, filename):
|
|
| 94 |
+ self.profiler.dump_stats(filename)
|
|
| 95 |
+ |
|
| 84 | 96 |
|
| 85 | 97 |
# profile_start()
|
| 86 | 98 |
#
|
| ... | ... | @@ -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,54 @@ class Project(): |
| 391 | 391 |
# Reset the element loader state
|
| 392 | 392 |
Element._reset_load_state()
|
| 393 | 393 |
|
| 394 |
+ # get_default_target()
|
|
| 395 |
+ #
|
|
| 396 |
+ # Attempts to interpret which element the user intended to run a command on.
|
|
| 397 |
+ #
|
|
| 398 |
+ def get_default_target(self):
|
|
| 399 |
+ |
|
| 400 |
+ # If _invoked_from_workspace_element has a value,
|
|
| 401 |
+ # a workspace element was found before a project config
|
|
| 402 |
+ # Therefore the workspace does not contain a project
|
|
| 403 |
+ return self._invoked_from_workspace_element
|
|
| 404 |
+ |
|
| 405 |
+ # get_default_targets()
|
|
| 406 |
+ #
|
|
| 407 |
+ # This function is used to gather either:
|
|
| 408 |
+ # The element the workspace was opened for if the workspace is not also a project
|
|
| 409 |
+ # The project default element (if defined in project.conf)
|
|
| 410 |
+ # or
|
|
| 411 |
+ # All elements in the project
|
|
| 412 |
+ #
|
|
| 413 |
+ def get_default_targets(self):
|
|
| 414 |
+ |
|
| 415 |
+ # If _invoked_from_workspace_element has a value,
|
|
| 416 |
+ # a workspace element was found before a project config
|
|
| 417 |
+ # Therefore the workspace does not contain a project
|
|
| 418 |
+ if self._invoked_from_workspace_element:
|
|
| 419 |
+ return (self._invoked_from_workspace_element,)
|
|
| 420 |
+ |
|
| 421 |
+ # The project is not required to have an element-path
|
|
| 422 |
+ element_directory = self._project_conf.get('element-path')
|
|
| 423 |
+ |
|
| 424 |
+ # The project may have a default element defined
|
|
| 425 |
+ default_element = self._project_conf.get("defaults", {}).get("targets", None)
|
|
| 426 |
+ |
|
| 427 |
+ if default_element:
|
|
| 428 |
+ return (default_element,)
|
|
| 429 |
+ |
|
| 430 |
+ output = []
|
|
| 431 |
+ |
|
| 432 |
+ directory = os.path.join(self.directory, element_directory)
|
|
| 433 |
+ for root, _, files in os.walk(directory):
|
|
| 434 |
+ for file in files:
|
|
| 435 |
+ if file.endswith(".bst"):
|
|
| 436 |
+ rel_dir = os.path.relpath(root, directory)
|
|
| 437 |
+ rel_file = os.path.join(rel_dir, file).lstrip("./")
|
|
| 438 |
+ output.append(rel_file)
|
|
| 439 |
+ |
|
| 440 |
+ return tuple(output)
|
|
| 441 |
+ |
|
| 394 | 442 |
# _load():
|
| 395 | 443 |
#
|
| 396 | 444 |
# Loads the project configuration file in the project
|
| ... | ... | @@ -167,3 +167,10 @@ shell: |
| 167 | 167 |
# Command to run when `bst shell` does not provide a command
|
| 168 | 168 |
#
|
| 169 | 169 |
command: [ 'sh', '-i' ]
|
| 170 |
+ |
|
| 171 |
+# Default Targets
|
|
| 172 |
+#
|
|
| 173 |
+defaults:
|
|
| 174 |
+ |
|
| 175 |
+ # Set a Default element to build when none are defined
|
|
| 176 |
+ targets: None
|
| ... | ... | @@ -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 |
from tests.testutils.site import IS_WINDOWS
|
| 7 | 8 |
|
| ... | ... | @@ -61,6 +62,35 @@ def test_build_checkout(datafiles, cli, strict, hardlinks): |
| 61 | 62 |
assert os.path.exists(filename)
|
| 62 | 63 |
|
| 63 | 64 |
|
| 65 |
+@pytest.mark.datafiles(DATA_DIR + "_world")
|
|
| 66 |
+def test_build_default_all(datafiles, cli):
|
|
| 67 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
| 68 |
+ result = cli.run(project=project, silent=True, args=['build'])
|
|
| 69 |
+ |
|
| 70 |
+ result.assert_success()
|
|
| 71 |
+ target_dir = os.path.join(cli.directory, DATA_DIR + "_world", "elements")
|
|
| 72 |
+ output_dir = os.path.join(cli.directory, "logs", "test")
|
|
| 73 |
+ |
|
| 74 |
+ expected = subprocess.Popen(('ls', target_dir), stdout=subprocess.PIPE)
|
|
| 75 |
+ expected = subprocess.check_output(("wc", "-w"), stdin=expected.stdout)
|
|
| 76 |
+ |
|
| 77 |
+ results = subprocess.Popen(('ls', output_dir), stdout=subprocess.PIPE)
|
|
| 78 |
+ results = subprocess.check_output(("wc", "-w"), stdin=results.stdout)
|
|
| 79 |
+ |
|
| 80 |
+ assert results == expected
|
|
| 81 |
+ |
|
| 82 |
+ |
|
| 83 |
+@pytest.mark.datafiles(DATA_DIR + "_default")
|
|
| 84 |
+def test_build_default(cli, datafiles):
|
|
| 85 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
| 86 |
+ result = cli.run(project=project, silent=True, args=['build'])
|
|
| 87 |
+ |
|
| 88 |
+ result.assert_success()
|
|
| 89 |
+ results = cli.get_element_state(project, "target2.bst")
|
|
| 90 |
+ expected = "cached"
|
|
| 91 |
+ assert results == expected
|
|
| 92 |
+ |
|
| 93 |
+ |
|
| 64 | 94 |
@pytest.mark.datafiles(DATA_DIR)
|
| 65 | 95 |
@pytest.mark.parametrize("strict,hardlinks", [
|
| 66 | 96 |
("non-strict", "hardlinks"),
|
| 1 |
+kind: stack
|
|
| 2 |
+description: |
|
|
| 3 |
+ |
|
| 4 |
+ Main stack target for the bst build test
|
| 1 |
+kind: stack
|
|
| 2 |
+description: |
|
|
| 3 |
+ |
|
| 4 |
+ Main stack target for the bst build test
|
| 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
|
| 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
|
| 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
|
| 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
|
| 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
|
| 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
|
| 1 |
+kind: stack
|
| 1 |
+kind: stack
|
| 1 |
+kind: compose
|
|
| 2 |
+ |
|
| 3 |
+build-depends:
|
|
| 4 |
+- 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
|
| 1 |
+# Project config for frontend build test
|
|
| 2 |
+name: test
|
|
| 3 |
+ |
|
| 4 |
+element-path: elements
|
|
| 5 |
+ |
|
| 6 |
+fatal-warnings:
|
|
| 7 |
+- bad-element-suffix
|
| ... | ... | @@ -45,6 +45,27 @@ def test_show_invalid_element_path(cli, datafiles): |
| 45 | 45 |
'show',
|
| 46 | 46 |
"foo.bst"])
|
| 47 | 47 |
|
| 48 |
+ |
|
| 49 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project_default'))
|
|
| 50 |
+def test_show_default(cli, datafiles):
|
|
| 51 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
| 52 |
+ result = cli.run(project=project, silent=True, args=[
|
|
| 53 |
+ 'show'])
|
|
| 54 |
+ |
|
| 55 |
+ result.assert_success()
|
|
| 56 |
+ |
|
| 57 |
+ # Get the result output of "[state sha element]" and turn into a list
|
|
| 58 |
+ results = result.output.strip().split(" ")
|
|
| 59 |
+ expected = 'target2.bst'
|
|
| 60 |
+ assert results[2] == expected
|
|
| 61 |
+ |
|
| 62 |
+ |
|
| 63 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'project_fail'))
|
|
| 64 |
+def test_show_fail(cli, datafiles):
|
|
| 65 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
| 66 |
+ result = cli.run(project=project, silent=True, args=[
|
|
| 67 |
+ 'show'])
|
|
| 68 |
+ |
|
| 48 | 69 |
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
|
| 49 | 70 |
|
| 50 | 71 |
|
