From 3e0c9ba0569eef55af35437cae9712a9030f4006 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 29 Nov 2021 13:04:44 +0100 Subject: [PATCH] [packages] Expand tests with PM-specific bits --- src/modules/packages/tests/1.global | 3 +++ .../packages/{test.yaml => tests/2.job} | 0 src/modules/packages/tests/CMakeTests.txt | 13 +++++++++++ src/modules/packages/tests/test-pm-pacman.py | 22 +++++++++++++++++++ 4 files changed, 38 insertions(+) create mode 100644 src/modules/packages/tests/1.global rename src/modules/packages/{test.yaml => tests/2.job} (100%) create mode 100644 src/modules/packages/tests/CMakeTests.txt create mode 100644 src/modules/packages/tests/test-pm-pacman.py diff --git a/src/modules/packages/tests/1.global b/src/modules/packages/tests/1.global new file mode 100644 index 000000000..ee06ccfe1 --- /dev/null +++ b/src/modules/packages/tests/1.global @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +rootMountPoint: /tmp diff --git a/src/modules/packages/test.yaml b/src/modules/packages/tests/2.job similarity index 100% rename from src/modules/packages/test.yaml rename to src/modules/packages/tests/2.job diff --git a/src/modules/packages/tests/CMakeTests.txt b/src/modules/packages/tests/CMakeTests.txt new file mode 100644 index 000000000..6e343533c --- /dev/null +++ b/src/modules/packages/tests/CMakeTests.txt @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# +# 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() diff --git a/src/modules/packages/tests/test-pm-pacman.py b/src/modules/packages/tests/test-pm-pacman.py new file mode 100644 index 000000000..aa0df2f7e --- /dev/null +++ b/src/modules/packages/tests/test-pm-pacman.py @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# +# Calamares Boilerplate +import libcalamares +libcalamares.globalstorage = libcalamares.GlobalStorage(None) +libcalamares.globalstorage.insert("testing", True) + +# Module prep-work +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() + +# Specific PM test +p = main.PMPacman() +assert p.pacman_num_retries == 0 +assert p.pacman_disable_timeout == False +assert p.pacman_needed_only == False