Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Official way to get name and version of package in test_package #6695

Closed
1 task done
madebr opened this issue Mar 17, 2020 · 2 comments · Fixed by #6723
Closed
1 task done

[feature] Official way to get name and version of package in test_package #6695

madebr opened this issue Mar 17, 2020 · 2 comments · Fixed by #6723
Assignees
Labels
Milestone

Comments

@madebr
Copy link
Contributor

madebr commented Mar 17, 2020

Sometimes it is useful to know the (name and) version of the package that a test_package is supposed to test.
Currently there is no supported way of doing this.

This is e.g. useful to ensure that the --version output of a packaged executable is the same as the version it is supposed to package.

Currently, I'm fetching the version using self.requires["package_name"].ref.version,
but I've been told that this is not a supported way.
That's why I am asking for clemency an official way to do this.

@memsharded memsharded self-assigned this Mar 18, 2020
@memsharded
Copy link
Member

This is e.g. useful to ensure that the --version output of a packaged executable is the same as the version it is supposed to package.

Not sure if this is a good example. This is a "functional" test of the executable, and as such, should probably be run in the build() method of the main recipe, not the test_package. The test_package feature in Conan is intended to check that things were packaged correctly, the headers are there, the library is there, the runtime is there and it can be used. Not that the behavior is one or other. In other words, this is a failure you want to detect even before packaging, not after packaging. If for some reason the pipeline continues after this test_package you are trying to do fails, and uploads the packages, you will have a broken package in the server. Failures in test_package do not remove the created packages, they are still there, sitting in the cache.

Another possible (undocumented way) to do this

If it works, I would suggest to document this version field at the moment, but probably to think a more structured way to get information from dependencies.

@memsharded memsharded added this to the 1.24 milestone Mar 18, 2020
@jgsogo
Copy link
Contributor

jgsogo commented Mar 18, 2020

I'm testing it and the field self.deps_cpp_info["package_name"].version is not populated in the test package conanfile.py. It was a good alternative, but it requires some development

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants