Skip to content

Commit

Permalink
more quiet system packages (#14924)
Browse files Browse the repository at this point in the history
* more quiet system packages

* fix tests
  • Loading branch information
memsharded authored Oct 16, 2023
1 parent 88b4671 commit c271142
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion conan/tools/gnu/pkgconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _parse_output(self, option):
with env.vars(self._conanfile).apply():
# This way we get the environment from ConanFile, from profile (default buildenv)
output = StringIO()
self._conanfile.run(command, stdout=output)
self._conanfile.run(command, stdout=output, quiet=True)
value = output.getvalue().strip()
return value

Expand Down Expand Up @@ -94,6 +94,7 @@ def fill_cpp_info(self, cpp_info, is_system=True, system_libs=None):
"""
if not self.provides:
raise ConanException("PkgConfig error, '{}' files not available".format(self._library))
self._conanfile.output.verbose(f"PkgConfig fill cpp_info for {self._library}")
if is_system:
cpp_info.system_libs = self.libs
else:
Expand Down
7 changes: 4 additions & 3 deletions conan/tools/system/package_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def get_default_tool(self):
if d in os_name:
return tool

def get_package_name(self, package, host_package=True):
def get_package_name(self, package, host_package=True):
# Only if the package is for building, for example a library,
# we should add the host arch when cross building.
# If the package is a tool that should be installed on the current build
# If the package is a tool that should be installed on the current build
# machine we should not add the arch.
if self._arch in self._arch_names and cross_building(self._conanfile) and host_package:
return "{}{}{}".format(package, self._arch_separator,
Expand All @@ -83,7 +83,8 @@ def run(self, method, *args, **kwargs):
return method(*args, **kwargs)

def _conanfile_run(self, command, accepted_returns):
ret = self._conanfile.run(command, ignore_errors=True)
# When checking multiple packages, this is too noisy
ret = self._conanfile.run(command, ignore_errors=True, quiet=True)
if ret not in accepted_returns:
raise ConanException("Command '%s' failed" % command)
return ret
Expand Down
3 changes: 2 additions & 1 deletion conans/model/conan_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ def run(self, command, stdout=None, cwd=None, ignore_errors=False, env="", quiet
if not quiet:
ConanOutput().writeln(f"{self.display_name}: RUN: {command}", fg=Color.BRIGHT_BLUE)
retcode = conan_run(wrapped_cmd, cwd=cwd, stdout=stdout, shell=shell)
ConanOutput().writeln("")
if not quiet:
ConanOutput().writeln("")

if not ignore_errors and retcode != 0:
raise ConanException("Error %d while executing" % retcode)
Expand Down
10 changes: 6 additions & 4 deletions conans/test/integration/tools/system/package_manager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def test_dnf_yum_return_code_100(tool_class, result):
context_mock.return_value = "host"
tool = tool_class(conanfile)

def fake_run(command, win_bash=False, subsystem=None, env=None, ignore_errors=False):
def fake_run(command, win_bash=False, subsystem=None, env=None, ignore_errors=False,
quiet=False):
assert command == result
return 100 if "check-update" in command else 0

Expand All @@ -183,7 +184,8 @@ def fake_run(command, win_bash=False, subsystem=None, env=None, ignore_errors=Fa
context_mock.return_value = "host"
tool = tool_class(conanfile)

def fake_run(command, win_bash=False, subsystem=None, env=None, ignore_errors=False):
def fake_run(command, win_bash=False, subsystem=None, env=None, ignore_errors=False,
quiet=False):
return 55 if "check-update" in command else 0

conanfile.run = fake_run
Expand Down Expand Up @@ -273,7 +275,7 @@ def fake_check(*args, **kwargs):
tool.install(["package1", "package2"], host_package=False)

assert tool._conanfile.command == result

@pytest.mark.parametrize("tool_class, result", [
# cross-compile but arch_names=None -> do not add host architecture
# https://github.com/conan-io/conan/issues/12320 because the package is archless
Expand Down Expand Up @@ -322,4 +324,4 @@ def test_tools_check(tool_class, result):
tool = tool_class(conanfile)
tool.check(["package"])

assert tool._conanfile.command == result
assert tool._conanfile.command == result

0 comments on commit c271142

Please sign in to comment.