Skip to content

Conversation

memsharded
Copy link
Member

@memsharded memsharded commented Apr 12, 2021

Changelog: Feature: Implement test_build_require in test_package/conanfile.py recipes, so build_requires can be tested as such.
Docs: conan-io/docs#2081

Comes from #8627, but isolating only the test_package functionality, which is way more necessary, for example for ConanCenter.

@memsharded memsharded added this to the 1.36 milestone Apr 12, 2021
@memsharded memsharded requested a review from czoido April 12, 2021 08:39
@memsharded memsharded requested review from danimtb, jgsogo and lasote April 21, 2021 10:31
Copy link
Contributor

@jgsogo jgsogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just some comment with ConanCenter in mind:

  • Right now we are only using one profile. I see the test works the same, but the cmake_find_package file is generated... is it a problem in this context?
  • The test suite needs a test case using conan test command to execute this functionality with a package that already exists (in the cache and/or in the remote), it should be exactly the same.
  • We need a test (additional feature?) where the package being tested is used as a requirement and also as a build_requirement. Recipes for packages like protobuf are already doing it.

@memsharded
Copy link
Member Author

We need a test (additional feature?) where the package being tested is used as a requirement and also as a build_requirement. Recipes for packages like protobuf are already doing it.

I see. Then, this might need some changes, I'll try to come up with a proposal for this.

@jgsogo
Copy link
Contributor

jgsogo commented Apr 21, 2021

If we go with the explicit attribute approach, maybe it is enough to write explicitly:

        class Pkg(ConanFile):

            test_build_require = True
            test_require = True

@memsharded
Copy link
Member Author

Proposed:

test_type = "build_requires", "requires"

To have something that scales a bit better if we have other kind of requires in the future, and also changed the name, to avoid confusion with so many "xxx-requires" things.

I have also added conan test command checks.

@memsharded memsharded requested a review from jgsogo April 21, 2021 15:30
Copy link
Contributor

@jgsogo jgsogo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm testing it locally and indeed the conan test command is not adding the build_requires when using only one profile... 😞 is this something that can be fixed?

In different scenarios in ConanCenter the packages are already built and we want to run only the tests: a commit in a PR that modifies only the test_package files, a PR that is modifying only test_package/***,...

If this is not something we can fix, we need to be really confident that the same packageID will be computed if using one profile or two (which, btw, is something we need to start checking sooner than later)...

@memsharded
Copy link
Member Author

I'm testing it locally and indeed the conan test command is not adding the build_requires when using only one profile... 😞 is this something that can be fixed?

This is not related to this feature. When using only 1 profile, there is only 1 context, and both requirements are the same node in host context, because they are compatible and do not conflict. Is kind of diamond with only 1 vertex. This cannot be fixed when using only 1 profile.

@memsharded memsharded merged commit 42a560d into conan-io:develop Apr 26, 2021
@memsharded memsharded deleted the feature/test_package_br branch April 26, 2021 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants