Skip to content

Relative profile path should be valid for creation commands - #8685

Merged
memsharded merged 18 commits into
conan-io:developfrom
uilianries:hotfix/relative-profile-path
Apr 7, 2021
Merged

memsharded merged 18 commits into
conan-io:developfrom
uilianries:hotfix/relative-profile-path

Conversation

@uilianries

@uilianries uilianries commented Mar 22, 2021

Copy link
Copy Markdown
Member

Conan accepts absolute and relative paths for profiles, that's well documented.

We know the main recommendation is absolute, but relative path is not working well when is associated to same tree level, and profile names is same from default profile folder. If a default profile doesn't exist, it works well, but when duplicated, Conan prefers default profiles folder instead.

fixes #8678

Changelog: Fix: Accept relative profile path when folder is on same tree level.
Docs: conan-io/docs#2049

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries
uilianries marked this pull request as ready for review March 22, 2021 21:36
@uilianries uilianries changed the title [WIP] Relative profile path should be valid for creation commands Relative profile path should be valid for creation commands Mar 22, 2021
Comment thread conans/client/profile_loader.py Outdated
Comment thread conans/test/functional/configuration/profile_test.py Outdated
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Comment thread conans/test/unittests/client/profile_loader/profile_loader_test.py
@uilianries
uilianries requested review from SSE4 and memsharded March 23, 2021 14:02
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>

@memsharded memsharded left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is great the modernizing of tests to pytest, thanks for taking the time!,

But on the other hand it is practically impossible to see if something might be breaking. Could you please split this into 2 PRs, one pure-refactor of tests, nothing else changing, and then the new fix with the new tests covering it?

Thanks!

@uilianries

Copy link
Copy Markdown
Member Author

Yes, totally. Indeed is terrify for review.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries

Copy link
Copy Markdown
Member Author

@memsharded Done

@uilianries

Copy link
Copy Markdown
Member Author

Second PR: #8729

@memsharded memsharded left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is quite risky:

  • I have reverted the changes to profile_loader.py, and the new tests are green! This means the tests are not testing this change, but just the previous existing functionality.
  • It is likely that we are breaking something, the condition might change for paths like relative/path/to/profile.txt that do not start with .
  • It is clear that the different paths functionality is not sufficiently covered by tests, we would need more thorough testing to make sure we are not breaking.

So I think we cannot merge these changes as-is.

@memsharded memsharded added this to the 1.36 milestone Mar 29, 2021
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries

Copy link
Copy Markdown
Member Author

I have reverted the changes to profile_loader.py, and the new tests are green! This means the tests are not testing this change, but just the previous existing functionality.

Indeed is tricky, I needed to add profiles folder to reproduce same behavior. The commit 6b8de0d35d2 should reproduce that error.

It is likely that we are breaking something, the condition might change for paths like relative/path/to/profile.txt that do not start with .

The fragility is because we need to follow not equal profile names, but also profiles folder.

@uilianries

Copy link
Copy Markdown
Member Author

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
os=Windows"""), self.client.out)


def test_profile_from_cache_path():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@uilianries please check this new test that I have provided. This would be proving that the previous fix was breaking, very likely massively breaking many users (all of them that manages profiles in subfolders in the cache).

The new proposed fix is more conservative and passes your new tests, please check if there is some other case to take into account.

@uilianries uilianries Apr 5, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would love adding a functional test to validate relative paths too. I know those unit tests cover very well get_profile_path(), but I would like having and end-to-end, because we have a considerable stack before calling it.

stacktrace

For regression it can help us. WDYT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually this should go to integration, not functional (as they don't depend on external tools), but until this is fixed, yes, it can co here.

Yes, it makes sense to have a few more tests here to cover better this functionality, please add some. Try to keep them simple, as the proposed one. Thanks!

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries
uilianries requested a review from memsharded April 6, 2021 17:33

@memsharded memsharded left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please try the proposed simplification to tests.

Comment thread conans/test/functional/configuration/profile_test.py Outdated
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries
uilianries requested a review from memsharded April 6, 2021 18:48
@memsharded

Copy link
Copy Markdown
Member

I have fixed the broken test in 8295aef. It was incorrectly managing paths, and it was creating folders in the code folder repo, making it dirty (and with risk to commit them accidentally)

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.

[question] profile search order

3 participants