[packages] Expand tests for PM-specifics more
This commit is contained in:
parent
3e0c9ba056
commit
1260d3fcb9
@ -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)
|
||||
add_test(
|
||||
NAME configure-packages-${_pm}
|
||||
COMMAND env PYTHONPATH=.: python3 ${CMAKE_CURRENT_LIST_DIR}/test-pm-${_pm}.py
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
)
|
||||
endforeach()
|
||||
|
||||
# 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}
|
||||
)
|
||||
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}
|
||||
)
|
||||
|
11
src/modules/packages/tests/pm-pacman-1.yaml
Normal file
11
src/modules/packages/tests/pm-pacman-1.yaml
Normal 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
|
||||
|
10
src/modules/packages/tests/pm-pacman-2.yaml
Normal file
10
src/modules/packages/tests/pm-pacman-2.yaml
Normal 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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user