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

Always indicate when patches are applied (#14165) #14177

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions conan/tools/files/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def patch(conanfile, base_path=None, patch_file=None, patch_string=None, strip=0
:param kwargs: Extra parameters that can be added and will contribute to output information
"""

patch_type = kwargs.get('patch_type')
patch_type = kwargs.get('patch_type') or ("file" if patch_file else "string")
Copy link
Member

Choose a reason for hiding this comment

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

It seems this could be breaking the tests, other types like "backport" are being ovewrritten?
https://ci.conan.io/blue/organizations/jenkins/ConanTestSuitev2/detail/PR-14177/1/pipeline/9

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should respect any non-empty value of patch_type that gets passed in. I'm not familiar with the test output conventions, but isn't it complaining about the new/modified "Apply patch (file)" lines?

Remember, the old behavior was that patch_file without (patch_type or patch_description) printed nothing, and patch_type could be left unset and e.g. "(file)" would not be printed.

patch_description = kwargs.get('patch_description')

if patch_type or patch_description:
Expand Down Expand Up @@ -96,8 +96,11 @@ def apply_conandata_patches(conanfile):
if "patch_file" in it:
# The patch files are located in the root src
entry = it.copy()
patch_file = os.path.join(conanfile.export_sources_folder, entry.pop("patch_file"))
patch(conanfile, patch_file=patch_file, **entry)
patch_file = entry.pop("patch_file")
patch_file_path = os.path.join(conanfile.export_sources_folder, patch_file)
if not "patch_description" in entry:
entry["patch_description"] = patch_file
patch(conanfile, patch_file=patch_file_path, **entry)
elif "patch_string" in it:
patch(conanfile, **it)
else:
Expand Down
10 changes: 7 additions & 3 deletions conans/test/unittests/tools/files/test_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_single_patch_description(mock_patch_ng):
conanfile = ConanFileMock()
conanfile.display_name = 'mocked/ref'
patch(conanfile, patch_file='patch-file', patch_description='patch_description')
assert 'mocked/ref: Apply patch: patch_description\n' == output.getvalue()
assert 'mocked/ref: Apply patch (file): patch_description\n' == output.getvalue()


def test_single_patch_extra_fields(mock_patch_ng):
Expand Down Expand Up @@ -173,8 +173,10 @@ def test_multiple_no_version(mock_patch_ng):
'patch_description': 'Needed to build with modern clang compilers.'}
]}
apply_conandata_patches(conanfile)
assert 'mocked/ref: Apply patch (file): patches/0001-buildflatbuffers-cmake.patch\n' \
in output.getvalue()
assert 'mocked/ref: Apply patch (backport): Needed to build with modern clang compilers.\n' \
== output.getvalue()
in output.getvalue()


def test_multiple_with_version(mock_patch_ng):
Expand Down Expand Up @@ -210,8 +212,10 @@ def test_multiple_with_version(mock_patch_ng):

conanfile.version = "1.11.0"
apply_conandata_patches(conanfile)
assert 'mocked/ref: Apply patch (file): patches/0001-buildflatbuffers-cmake.patch\n' \
in output.getvalue()
assert 'mocked/ref: Apply patch (backport): Needed to build with modern clang compilers.\n' \
== output.getvalue()
in output.getvalue()

# Ensure the function is not mutating the `conan_data` structure
assert conanfile.conan_data == conandata_contents