GitHubのミラーです
https://github.com/FascodeNet/alterlinux-calamares
Revisión | 719548213f00a504f383ca67f8cc5f051586f3f3 (tree) |
---|---|
Tiempo | 2021-09-28 04:02:18 |
Autor | Adriaan de Groot <groot@kde....> |
Commiter | Adriaan de Groot |
CMake: if pylint is available, run it as part of the test-suite
This introduces a stub-implementation (fake) that mimics the
API offered by libcalamares (the library is actually exposed
to Python via Boost::Python, so it doesn't act like a C-extension).
Using that stub-implementation, we can check Python modules for
validity as part of the test-suite.
The stub-implementation is needed, because otherwise every
Python module already fails at import libcalamares.
- stub-implement the API that is actually used by the Python modules
- in globalstorage, be slightly smart about what keys are being
@@ -42,6 +42,18 @@ include( CalamaresCheckModuleSelection ) | ||
42 | 42 | |
43 | 43 | set( MODULE_DATA_DESTINATION share/calamares/modules ) |
44 | 44 | |
45 | +# We look for Pylint (just once) so that unittests can be added that | |
46 | +# check the syntax / variables of Python modules. This should help | |
47 | +# avoid more typo's-in-releases. | |
48 | +if(BUILD_TESTING AND NOT PYLINT_COMMAND_SEARCHED) | |
49 | + set(PYLINT_COMMAND_SEARCHED TRUE) | |
50 | + find_program( | |
51 | + PYLINT_COMMAND | |
52 | + NAMES pylint3 pylint | |
53 | + PATHS $ENV{HOME}/.local/bin | |
54 | + ) | |
55 | +endif() | |
56 | + | |
45 | 57 | function( _calamares_add_module_subdirectory_impl ) |
46 | 58 | set( SUBDIRECTORY ${ARGV0} ) |
47 | 59 |
@@ -241,6 +253,19 @@ function( _calamares_add_module_subdirectory_impl ) | ||
241 | 253 | if ( EXISTS ${_testdir}/CMakeTests.txt AND NOT EXISTS ${_mod_dir}/CMakeLists.txt ) |
242 | 254 | include( ${_testdir}/CMakeTests.txt ) |
243 | 255 | endif() |
256 | + if ( PYLINT_COMMAND AND MODULE_INTERFACE MATCHES "python" ) | |
257 | + # Python modules get an additional test via pylint; this | |
258 | + # needs to run at top-level because the ci/libcalamares directory | |
259 | + # contains API stubs. | |
260 | + # | |
261 | + # TODO: the entry point is assumed to be `main.py`, but that is | |
262 | + # configurable through module.desc | |
263 | + add_test( | |
264 | + NAME lint-${SUBDIRECTORY} | |
265 | + COMMAND env PYTHONPATH=ci: ${PYLINT_COMMAND} -E ${_mod_dir}/main.py | |
266 | + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | |
267 | + ) | |
268 | + endif() | |
244 | 269 | endif() |
245 | 270 | endfunction() |
246 | 271 |
@@ -6,4 +6,4 @@ | ||
6 | 6 | # Boost::Python, not as a bare C-extension) so that |
7 | 7 | # pylint doesn't complain about libcalamares internals. |
8 | 8 | |
9 | -pass | |
9 | +VERSION_SHORT="1.0" |
@@ -6,4 +6,19 @@ | ||
6 | 6 | # Boost::Python, not as a bare C-extension) so that |
7 | 7 | # pylint doesn't complain about libcalamares internals. |
8 | 8 | |
9 | -def value(_): return 1 | |
9 | +def count(): return 1 | |
10 | + | |
11 | +def keys(): return [] | |
12 | + | |
13 | +def contains(_): return True | |
14 | + | |
15 | +def value(key): | |
16 | + if key in ("branding",): | |
17 | + return dict() | |
18 | + if key in ("partitions",): | |
19 | + return list() | |
20 | + return "" | |
21 | + | |
22 | +def insert(key, value): pass | |
23 | + | |
24 | +def remove(_): pass |
@@ -10,6 +10,14 @@ def debug(_): pass | ||
10 | 10 | |
11 | 11 | def warning(_): pass |
12 | 12 | |
13 | +def error(_): pass | |
14 | + | |
13 | 15 | def gettext_path(): pass |
14 | 16 | |
15 | 17 | def gettext_languages(): pass |
18 | + | |
19 | +def target_env_call(_): return 0 | |
20 | + | |
21 | +def check_target_env_call(_): pass | |
22 | + | |
23 | +def mount(device, mountpoint, fstype, options): return 0 |