[packages] Expand tests for PM-specifics more

This commit is contained in:
Adriaan de Groot 2021-11-29 13:21:50 +01:00
parent 3e0c9ba056
commit 1260d3fcb9
4 changed files with 59 additions and 13 deletions

View File

@ -4,10 +4,21 @@
# We have tests to load (some) of the package-managers specifically, to
# test their configuration code and implementation. Those tests conventionally
# live in Python files here in the tests/ directory. Add them.
foreach(_pm pacman)
# Pacman (Arch) tests
set(_pm pacman)
add_test(
NAME configure-packages-${_pm}
COMMAND env PYTHONPATH=.: python3 ${CMAKE_CURRENT_LIST_DIR}/test-pm-${_pm}.py
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endforeach()
add_test(
NAME configure-packages-${_pm}-ops-1
COMMAND env PYTHONPATH=.: python3 ${CMAKE_CURRENT_LIST_DIR}/test-pm-${_pm}.py ${CMAKE_CURRENT_LIST_DIR}/pm-pacman-1.yaml 4 1 1
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_test(
NAME configure-packages-${_pm}-ops-2
COMMAND env PYTHONPATH=.: python3 ${CMAKE_CURRENT_LIST_DIR}/test-pm-${_pm}.py ${CMAKE_CURRENT_LIST_DIR}/pm-pacman-2.yaml 3 0 0
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)

View File

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
backend: pacman
rootMountPoint: /tmp/mount
operations: []
pacman:
num_retries: 4
disable_timeout: yes
needed_only: true

View File

@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: no
# SPDX-License-Identifier: CC0-1.0
backend: pacman
rootMountPoint: /tmp/mount
operations: []
# Leave some things unspecified
pacman:
num_retries: 3

View File

@ -11,12 +11,26 @@ from src.modules.packages import main
# .. we don't have a job in this test, so fake one
class Job(object):
def __init__(self):
self.configuration = libcalamares.utils.load_yaml("pm-pacman.yaml")
libcalamares.job = Job()
def __init__(self, filename):
self.configuration = libcalamares.utils.load_yaml(filename) if filename is not None else dict()
import sys
if len(sys.argv) > 4:
filename = sys.argv[1]
retry = int(sys.argv[2])
timeout = bool(int(sys.argv[3]))
needed = bool(int(sys.argv[4]))
else:
filename = None
retry = 0
timeout = False
needed = False
libcalamares.utils.warning("Expecting {!s} retry={!s} timeout={!s} needed={!s}".format(filename, retry, timeout, needed))
# Specific PM test
libcalamares.job = Job(filename)
p = main.PMPacman()
assert p.pacman_num_retries == 0
assert p.pacman_disable_timeout == False
assert p.pacman_needed_only == False
assert p.pacman_num_retries == retry, "{!r} vs {!r}".format(p.pacman_num_retries, retry)
assert p.pacman_disable_timeout == timeout
assert p.pacman_needed_only == needed