Skip to content

Commit

Permalink
Tests that dnf prints hints on failing resolvment
Browse files Browse the repository at this point in the history
  • Loading branch information
m-blaha committed Mar 20, 2024
1 parent 35d9eeb commit d0263f3
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 0 deletions.
157 changes: 157 additions & 0 deletions dnf-behave-tests/dnf/resolve-hints.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
@dnf5
Feature: Test that proper hints are printed after resolving failure

Background: Set dnf for strict behavior
Given I use repository "resolve-hints"
And I configure dnf with
| key | value |
| best | True |
| skip_unavailable | False |
| skip_broken | False |
| optional_metadata_types | comps,updateinfo |


# To print the hints we need a failing transaction - thus adding
# non-existing DoesNotExist package to all install commands.

Scenario: --use-host-config is hinted if no repos are loaded from installroot
Given I drop repository "resolve-hints"
When I execute dnf with args "install DoesNotExist"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
No match for argument: DoesNotExist
No repositories were loaded from the installroot. To use the configuration and repositories of the host system, pass --use-host-config.
"""

Scenario: --skip-unavailable is hinted on non-existent package installation attempt
When I execute dnf with args "install DoesNotExist"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
No match for argument: DoesNotExist
You can try to add to command line:
--skip-unavailable to skip unavailable packages
"""

Scenario: --skip-unavailable is not printed if the option is already present
When I execute dnf with args "install DoesNotExist --skip-unavailable"
Then the exit code is 0
And transaction is empty
And stderr is
"""
No match for argument: DoesNotExist
"""

Scenario: --no-best is hinted if the best candidate cannot be installed
When I execute dnf with args "install DoesNotExist NoBest"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
No match for argument: DoesNotExist
Problem: cannot install the best candidate for the job
- nothing provides DoesNotExist needed by NoBest-2.0-1.noarch
You can try to add to command line:
--skip-unavailable to skip unavailable packages
--no-best to not limit the transaction to the best candidates
--skip-broken to skip uninstallable packages
"""

Scenario: --no-best is not printed if the option is already present
When I execute dnf with args "install DoesNotExist NoBest --no-best"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
No match for argument: DoesNotExist
Problem: cannot install the best candidate for the job
- nothing provides DoesNotExist needed by NoBest-2.0-1.noarch
You can try to add to command line:
--skip-unavailable to skip unavailable packages
"""

Scenario: --allowerasing is hinted on attempt to install conflicting packages
Given I successfully execute dnf with args "install ConflictingOne"
When I execute dnf with args "install DoesNotExist ConflictingTwo"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
No match for argument: DoesNotExist
Problem: problem with installed package
- package ConflictingOne-1.0-1.noarch conflicts with ConflictingTwo provided by ConflictingTwo-1.0-1.noarch
- package ConflictingTwo-1.0-1.noarch conflicts with ConflictingOne provided by ConflictingOne-1.0-1.noarch
- conflicting requests
You can try to add to command line:
--skip-unavailable to skip unavailable packages
--allowerasing to allow erasing of installed packages to resolve problems
--skip-broken to skip uninstallable packages
"""

Scenario: --allowerasing is not printed if the option is already present
Given I successfully execute dnf with args "install ConflictingOne"
When I execute dnf with args "install DoesNotExist ConflictingTwo --allowerasing"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
No match for argument: DoesNotExist
You can try to add to command line:
--skip-unavailable to skip unavailable packages
"""

Scenario: filelists metadata is hinted on missing file dependency
When I execute dnf with args "install DoesNotExist RequiresFileDep"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
No match for argument: DoesNotExist
Problem: conflicting requests
- nothing provides /var/ProvidesFileDep needed by RequiresFileDep-1.0-1.noarch
You can try to add to command line:
--skip-unavailable to skip unavailable packages
--setopt=optional_metadata_types=filelists to load additional filelists metadata
--skip-broken to skip uninstallable packages
"""

Scenario: filelists metadata is not printed if the option is already present
When I execute dnf with args "install DoesNotExist RequiresFileDep --setopt=optional_metadata_types=filelists"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
No match for argument: DoesNotExist
You can try to add to command line:
--skip-unavailable to skip unavailable packages
"""

Scenario: --skip-broken is hinted on non-installable package
When I execute dnf with args "install DoesNotExist RequirementsUnmet"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
No match for argument: DoesNotExist
Problem: conflicting requests
- nothing provides DoesNotExist needed by RequirementsUnmet-1.0-1.noarch
You can try to add to command line:
--skip-unavailable to skip unavailable packages
--skip-broken to skip uninstallable packages
"""

Scenario: --skip-broken is not printed if the option is already present
When I execute dnf with args "install DoesNotExist RequirementsUnmet --skip-broken"
Then the exit code is 1
And stderr is
"""
Failed to resolve the transaction:
No match for argument: DoesNotExist
Problem: conflicting requests
- nothing provides DoesNotExist needed by RequirementsUnmet-1.0-1.noarch
You can try to add to command line:
--skip-unavailable to skip unavailable packages
"""
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Name: ConflictingOne
Version: 1.0
Release: 1
Summary: Made up package
BuildArch: noarch
Conflicts: ConflictingTwo

License: GPLv3+
Url: None

%description
ConflictingOne description

%files

%changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Name: ConflictingTwo
Version: 1.0
Release: 1
Summary: Made up package
BuildArch: noarch
Conflicts: ConflictingOne

License: GPLv3+
Url: None

%description
ConflictingTwo description

%files

%changelog
15 changes: 15 additions & 0 deletions dnf-behave-tests/fixtures/specs/resolve-hints/NoBest-1.0-1.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Name: NoBest
Version: 1.0
Release: 1
Summary: Made up package
BuildArch: noarch

License: GPLv3+
Url: None

%description
NoBest description

%files

%changelog
16 changes: 16 additions & 0 deletions dnf-behave-tests/fixtures/specs/resolve-hints/NoBest-2.0-1.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Name: NoBest
Version: 2.0
Release: 1
Summary: Made up package
BuildArch: noarch
Requires: DoesNotExist

License: GPLv3+
Url: None

%description
NoBest description

%files

%changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Name: ProvidesFileDep
Version: 1.0
Release: 1
Summary: Made up package
BuildArch: noarch

License: GPLv3+
Url: None

%description
ProvidesFileDep description

%files
%ghost /var/ProvidesFileDep

%changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Name: RequirementsUnmet
Version: 1.0
Release: 1
Summary: Made up package
BuildArch: noarch
Requires: DoesNotExist

License: GPLv3+
Url: None

%description
RequirementsUnmet description

%files

%changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Name: RequiresFileDep
Version: 1.0
Release: 1
Summary: Made up package
BuildArch: noarch
Requires: /var/ProvidesFileDep

License: GPLv3+
Url: None

%description
RequiresFileDep description

%files

%changelog

0 comments on commit d0263f3

Please sign in to comment.