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

fix --build=missing:& pattern #16344

Merged
merged 1 commit into from
May 27, 2024
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
2 changes: 1 addition & 1 deletion conans/client/graph/build_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ def allowed(self, conan_file):

def should_build_missing(self, conanfile):
for pattern in self.build_missing_patterns:
if ref_matches(conanfile.ref, pattern, is_consumer=False):
if ref_matches(conanfile.ref, pattern, is_consumer=conanfile._conan_is_consumer):
return True
6 changes: 3 additions & 3 deletions conans/model/recipe_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def validate_ref(self, allow_uppercase=False):
if self.channel and validation_pattern.match(self.channel) is None:
raise ConanException(f"Invalid package channel '{self.channel}'")

# Warn if they use .+ in the name/user/channel, as it can be problematic for generators
# Warn if they use .+ in the name/user/channel, as it can be problematic for generators
pattern = re.compile(r'[.+]')
if pattern.search(self.name):
ConanOutput().warning(f"Name containing special chars is discouraged '{self.name}'")
Expand All @@ -179,8 +179,8 @@ def matches(self, pattern, is_consumer):
no_user_channel = True

condition = ((pattern == "&" and is_consumer) or
fnmatch.fnmatchcase(str(self), pattern) or
fnmatch.fnmatchcase(self.repr_notime(), pattern))
fnmatch.fnmatchcase(str(self), pattern) or
fnmatch.fnmatchcase(self.repr_notime(), pattern))
if no_user_channel:
condition = condition and not self.user and not self.channel
if negate:
Expand Down
26 changes: 16 additions & 10 deletions test/integration/command/create_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ def test_create_build_missing():
c.assert_listed_binary({"dep/1.0": ("9a4eb3c8701508aa9458b1a73d0633783ecc2270", "Missing")})
assert "ERROR: Missing prebuilt package for 'dep/1.0'" in c.out

# The & placeholder also works
c.run("create pkg -s os=Linux --build=missing:&", assert_error=True)
c.assert_listed_binary({"pkg/1.0": ("4c0c198b627f9af3e038af4da5e6b3ae205c2435", "Build")})
c.assert_listed_binary({"dep/1.0": ("9a4eb3c8701508aa9458b1a73d0633783ecc2270", "Missing")})
assert "ERROR: Missing prebuilt package for 'dep/1.0'" in c.out


def test_create_no_user_channel():
""" test the --build=pattern and --build=missing:pattern syntax to build missing packages
Expand Down Expand Up @@ -711,22 +717,22 @@ def generate(self):

# The paths are absolute and the components have defaults
# ".+" Check that there is a path, not only "lib"
assert re.search(r"BINDIRS: \['.+bin'\]", str(client.out))
assert re.search(r"LIBDIRS: \['.+lib'\]", str(client.out))
assert re.search(r"INCLUDEDIRS: \['.+include'\]", str(client.out))
assert re.search(r"BINDIRS: \['.+bin']", client.out)
Copy link
Member Author

Choose a reason for hiding this comment

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

Just some cleaning of warnings and other legacy stuff

assert re.search(r"LIBDIRS: \['.+lib']", client.out)
assert re.search(r"INCLUDEDIRS: \['.+include']", client.out)
assert "WARN: RES DIRS: []"
assert re.search(r"WARN: FOO LIBDIRS: \['.+lib'\]", str(client.out))
assert re.search(r"WARN: FOO INCLUDEDIRS: \['.+include'\]", str(client.out))
assert re.search(r"WARN: FOO LIBDIRS: \['.+lib']", client.out)
assert re.search(r"WARN: FOO INCLUDEDIRS: \['.+include']", client.out)
assert "WARN: FOO RESDIRS: []" in client.out

# The paths are absolute and the components have defaults
# ".+" Check that there is a path, not only "lib"
assert re.search("BINDIRS: \['.+bin'\]", str(client.out))
assert re.search("LIBDIRS: \['.+lib'\]", str(client.out))
assert re.search("INCLUDEDIRS: \['.+include'\]", str(client.out))
assert re.search(r"BINDIRS: \['.+bin']", client.out)
assert re.search(r"LIBDIRS: \['.+lib']", client.out)
assert re.search(r"INCLUDEDIRS: \['.+include']", client.out)
assert "WARN: RES DIRS: []"
assert bool(re.search("WARN: FOO LIBDIRS: \['.+lib'\]", str(client.out)))
assert bool(re.search("WARN: FOO INCLUDEDIRS: \['.+include'\]", str(client.out)))
assert bool(re.search(r"WARN: FOO LIBDIRS: \['.+lib']", client.out))
assert bool(re.search(r"WARN: FOO INCLUDEDIRS: \['.+include']", client.out))
assert "WARN: FOO RESDIRS: []" in client.out


Expand Down