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

Check for diagnostic messages on stderr, not stdout #1540

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
43 changes: 38 additions & 5 deletions dnf-behave-tests/common/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,55 @@ def then_stderr_is_empty(context):

@behave.then("stderr is")
def then_stderr_is(context):
"""
Checks for the exact match of the test's stderr. Supports the <REPOSYNC>
placeholder on the first line, which will match against the repository
synchronization lines (i.e. the "Last metadata expiration check:" line as
well as the individual repo download lines) in the test's output.
"""
expected = context.text.format(context=context).strip().split('\n')
found = context.cmd_stderr.strip().split('\n')

if expected == found:
if found == [""]:
found = []

dnf5_mode = hasattr(context, "dnf5_mode") and context.dnf5_mode
clean_expected, clean_found = handle_reposync(expected, found, dnf5_mode)

if clean_expected == clean_found:
return

print_lines_diff(expected, found)
rs_offset = 0
if len(clean_expected) < len(expected):
if len(clean_found) == len(found):
rs_offset = 1
# reposync was not in found, prepend a single line to pad for the
# <REPOSYNC> line in expected
found = [""] + found
else:
rs_offset = len(found) - len(clean_found)
# prepend empty lines to expected to pad for multiple reposync
# lines in found
expected = [""] * (rs_offset - 1) + expected

print_lines_diff(expected, found, num_lines_equal=rs_offset)

raise AssertionError("Stderr is not: %s" % context.text)


@behave.then("stderr matches line by line")
def then_stderr_matches_line_by_line(context):
out_lines = context.cmd_stderr.split('\n')
regexp_lines = context.text.split('\n')
lines_match_to_regexps_line_by_line(out_lines, regexp_lines)
"""
Checks that each line of stderr matches respective line in regular expressions.
Supports the <REPOSYNC> in the same way as the step "stderr is"
"""
found = context.cmd_stderr.split('\n')
expected = context.text.split('\n')

dnf5_mode = hasattr(context, "dnf5_mode") and context.dnf5_mode
clean_expected, clean_found = handle_reposync(expected, found, dnf5_mode)

lines_match_to_regexps_line_by_line(clean_found, clean_expected)


@behave.then("{dnf_version:dnf_version} exit code is {exitcode}")
Expand Down
243 changes: 144 additions & 99 deletions dnf-behave-tests/dnf/append_options.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,191 +14,236 @@ Background: Enable repository and set excludes in configuration
Scenario: Test that excludes from config file are applied
When I execute dnf with args "repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
wget-0:1.19.6-5.fc29.src
wget-0:1.19.6-5.fc29.x86_64
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
wget-0:1.19.6-5.fc29.src
wget-0:1.19.6-5.fc29.x86_64
"""


Scenario: Test adding of excludes
When I execute dnf with args "--exclude=lz4 --exclude=wget repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""


Scenario: Test adding of excludes using --setopt
When I execute dnf with args "--setopt=excludepkgs=lz4 --setopt=excludepkgs=wget repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""


Scenario: Test adding of excludes short notation
When I execute dnf with args "--exclude=lz4,wget repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""


Scenario: Test adding of excludes short notation using --setopt
When I execute dnf with args "--setopt=excludepkgs=lz4,wget repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""


Scenario: Test removing of existing excludes
When I execute dnf with args "--exclude= repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
lz4-0:1.8.2-2.fc29.i686
lz4-0:1.8.2-2.fc29.src
lz4-0:1.8.2-2.fc29.x86_64
wget-0:1.19.6-5.fc29.src
wget-0:1.19.6-5.fc29.x86_64
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
lz4-0:1.8.2-2.fc29.i686
lz4-0:1.8.2-2.fc29.src
lz4-0:1.8.2-2.fc29.x86_64
wget-0:1.19.6-5.fc29.src
wget-0:1.19.6-5.fc29.x86_64
"""


Scenario: Test removing of existing excludes using --setopt
When I execute dnf with args "--setopt=excludepkgs= repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
lz4-0:1.8.2-2.fc29.i686
lz4-0:1.8.2-2.fc29.src
lz4-0:1.8.2-2.fc29.x86_64
wget-0:1.19.6-5.fc29.src
wget-0:1.19.6-5.fc29.x86_64
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
lz4-0:1.8.2-2.fc29.i686
lz4-0:1.8.2-2.fc29.src
lz4-0:1.8.2-2.fc29.x86_64
wget-0:1.19.6-5.fc29.src
wget-0:1.19.6-5.fc29.x86_64
"""


Scenario: Test replacing of existing excludes
When I execute dnf with args "--exclude= --exclude=lz4 --exclude=wget repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
"""


Scenario: Test replacing of existing excludes using --setopt
When I execute dnf with args "--setopt=excludepkgs= --setopt=excludepkgs=lz4 --setopt=excludepkgs=wget repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
"""


Scenario: Test replacing of existing excludes short notation
When I execute dnf with args "--exclude=,lz4,wget repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
"""


Scenario: Test replacing of existing excludes short notation using --setopt
When I execute dnf with args "--setopt=excludepkgs=,lz4,wget repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
lame-0:3.100-5.fc29.src
lame-0:3.100-5.fc29.x86_64
"""


@bz1788154
Scenario: Test adding excludes (empty values in the middle of short notation are ignored)
When I execute dnf with args "--exclude=lz4,,wget repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""


@bz1788154
Scenario: Test adding excludes (empty values in the middle of short notation are ignored) using --setopt
When I execute dnf with args "--setopt=excludepkgs=lz4,,wget repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""


@bz1788154
Scenario: Test adding excludes (empty value at the end of short notation is ignored)
When I execute dnf with args "--exclude=lz4,wget, repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""


@bz1788154
Scenario: Test adding excludes (empty value at the end of short notation is ignored) using --setopt
When I execute dnf with args "--setopt=excludepkgs=lz4,wget, repoquery abcde lame lz4 wget"
Then the exit code is 0
And stderr is
"""
<REPOSYNC>
"""
And stdout is
"""
<REPOSYNC>
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""
"""
abcde-0:2.9.3-1.fc29.noarch
abcde-0:2.9.3-1.fc29.src
"""
Loading
Loading