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

pytest framework: add checking the exit code of test commands #29

Merged
Merged
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
10 changes: 7 additions & 3 deletions tests/integration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@

from lxml import etree

# pyright: ignore[reportMissingImports]
if sys.version_info.major == 2:
from commands import getoutput # type:ignore[import-not-found] # pyright: ignore[reportMissingImports]
from commands import getstatusoutput # type:ignore[import-not-found]
else:
from subprocess import getoutput
from subprocess import getstatusoutput

BUGTOOL_OUTPUT_DIR = "/var/opt/xen/bug-report/"
BUGTOOL_DOM0_TEMPL = "tests/integration/dom0-template/"
Expand Down Expand Up @@ -97,7 +98,10 @@ def run_bugtool_entry(archive_type, test_entries):
# For case the default python interpreter of the user is python3, we must use python2(for now):
command = "python2 ./xen-bugtool -y --output=%s --entries=%s" % (archive_type, test_entries)
print("# " + command)
print(getoutput(command))
error_code, output = getstatusoutput(command)
print(output)
if error_code:
raise RuntimeError(output)
srcdir = os.getcwd()
os.chdir(BUGTOOL_OUTPUT_DIR)
output_file = test_entries + "." + archive_type
Expand Down