diff --git a/src/modules/packages/tests/CMakeTests.txt b/src/modules/packages/tests/CMakeTests.txt index 6e343533c..9ee9c6682 100644 --- a/src/modules/packages/tests/CMakeTests.txt +++ b/src/modules/packages/tests/CMakeTests.txt @@ -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} +) diff --git a/src/modules/packages/tests/pm-pacman-1.yaml b/src/modules/packages/tests/pm-pacman-1.yaml new file mode 100644 index 000000000..1ad048b61 --- /dev/null +++ b/src/modules/packages/tests/pm-pacman-1.yaml @@ -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 + diff --git a/src/modules/packages/tests/pm-pacman-2.yaml b/src/modules/packages/tests/pm-pacman-2.yaml new file mode 100644 index 000000000..2bbf70758 --- /dev/null +++ b/src/modules/packages/tests/pm-pacman-2.yaml @@ -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 + diff --git a/src/modules/packages/tests/test-pm-pacman.py b/src/modules/packages/tests/test-pm-pacman.py index aa0df2f7e..f57e2a761 100644 --- a/src/modules/packages/tests/test-pm-pacman.py +++ b/src/modules/packages/tests/test-pm-pacman.py @@ -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