From b8b40314740c118398641a3b86655a8b0434631d Mon Sep 17 00:00:00 2001 From: Chandan Singh Date: Thu, 14 May 2020 18:45:53 +0000 Subject: Ensure there are no duplicates in Elements.dependencies() When we are not recursing, `Element.dependencies()` uses a much more light weight codepath since it just needs to print the direct dependencies. However, this simple codepath was not accounting for duplicates, in case something is both a build time and run time dependency. One way this manifested itself was in `bst show --format %{deps}`, but it would also affect anything that was using this method to iterate on the dependencies. Fixes #1308. --- tests/frontend/project/elements/format-deps.bst | 17 +++++++++++++++++ tests/frontend/show.py | 8 ++++---- 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/frontend/project/elements/format-deps.bst (limited to 'tests/frontend') diff --git a/tests/frontend/project/elements/format-deps.bst b/tests/frontend/project/elements/format-deps.bst new file mode 100644 index 000000000..58a46891b --- /dev/null +++ b/tests/frontend/project/elements/format-deps.bst @@ -0,0 +1,17 @@ +kind: import + +description: > + It is important that this element has both and build and runtime dependencies. + It is also important that it has a dependency that is needed at both build + time and runtime. + +sources: +- kind: local + path: files/etc-files + +depends: +- import-links.bst +build-depends: +- import-dev.bst +runtime-depends: +- import-bin.bst diff --git a/tests/frontend/show.py b/tests/frontend/show.py index 17931ffe3..4be4b72e9 100644 --- a/tests/frontend/show.py +++ b/tests/frontend/show.py @@ -399,14 +399,14 @@ def test_exceed_max_recursion_depth(cli, tmpdir, dependency_depth): @pytest.mark.parametrize( "dep_kind, expected_deps", [ - ("%{deps}", "[import-dev.bst, import-bin.bst]"), - ("%{build-deps}", "[import-dev.bst]"), - ("%{runtime-deps}", "[import-bin.bst]"), + ("%{deps}", "[import-dev.bst, import-links.bst, import-bin.bst]"), + ("%{build-deps}", "[import-dev.bst, import-links.bst]"), + ("%{runtime-deps}", "[import-links.bst, import-bin.bst]"), ], ) def test_format_deps(cli, datafiles, dep_kind, expected_deps): project = str(datafiles) - target = "checkout-deps.bst" + target = "format-deps.bst" result = cli.run( project=project, silent=True, args=["show", "--deps", "none", "--format", "%{name}: " + dep_kind, target] ) -- cgit v1.2.1