Skip to content

Commit

Permalink
Fix graph build-order --order=configuration text format output (con…
Browse files Browse the repository at this point in the history
…an-io#15538)

Fix graph build-order --order=configuration text format output
  • Loading branch information
AbrilRBS authored Jan 26, 2024
1 parent ba78f3f commit 5c6d36a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
10 changes: 7 additions & 3 deletions conan/cli/commands/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ def cli_build_order(build_order):
# TODO: Very simple cli output, probably needs to be improved
for level in build_order:
for item in level:
for package_level in item['packages']:
for package in package_level:
cli_out_write(f"{item['ref']}:{package['package_id']} - {package['binary']}")
# If this is a configuration order, it has no packages entry, each item is a package
if 'packages' in item:
for package_level in item['packages']:
for package in package_level:
cli_out_write(f"{item['ref']}:{package['package_id']} - {package['binary']}")
else:
cli_out_write(f"{item['ref']}:{item['package_id']} - {item['binary']}")


def json_build_order(build_order):
Expand Down
15 changes: 15 additions & 0 deletions conans/test/integration/command_v2/test_info_build_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ def test_info_build_order_configuration():
assert bo_json == result


def test_info_build_order_configuration_text_formatter():
c = TestClient()
c.save({"dep/conanfile.py": GenConanfile(),
"pkg/conanfile.py": GenConanfile().with_requires("dep/0.1"),
"consumer/conanfile.txt": "[requires]\npkg/0.1"})
c.run("export dep --name=dep --version=0.1")
c.run("export pkg --name=pkg --version=0.1")
c.run("graph build-order consumer --build=missing --order=configuration --format=text")
assert textwrap.dedent("""\
======== Computing the build order ========
dep/0.1#4d670581ccb765839f2239cc8dff8fbd:da39a3ee5e6b4b0d3255bfef95601890afd80709 - Build
pkg/0.1#1ac8dd17c0f9f420935abd3b6a8fa032:59205ba5b14b8f4ebc216a6c51a89553021e82c1 - Build
""") in c.out


def test_info_build_order_build_require():
c = TestClient()
c.save({"dep/conanfile.py": GenConanfile(),
Expand Down

0 comments on commit 5c6d36a

Please sign in to comment.