|
5 | 5 | import importlib |
6 | 6 | import sys |
7 | 7 |
|
8 | | -from typing import TYPE_CHECKING |
9 | | - |
10 | | -from tests.install_smoke.runtime import base_send_message |
11 | | - |
12 | | - |
13 | | -if TYPE_CHECKING: |
14 | | - from collections.abc import Callable |
15 | | - |
16 | 8 |
|
17 | 9 | # Modules under each list MUST be importable with only that profile's |
18 | 10 | # extras installed -- no leakage from other extras (grpc, http-server, |
|
84 | 76 | } |
85 | 77 |
|
86 | 78 |
|
87 | | -RUNTIME_CHECKS: dict[str, list[tuple[str, Callable[[], None]]]] = { |
88 | | - 'base': [ |
89 | | - (base_send_message.NAME, base_send_message.check), |
90 | | - ], |
| 79 | +# Imported lazily in `main()` so a check that needs one profile's |
| 80 | +# extras can't break the harness when running a different profile. |
| 81 | +RUNTIME_CHECKS: dict[str, list[str]] = { |
| 82 | + 'base': ['tests.install_smoke.runtime.base_send_message'], |
91 | 83 | } |
92 | 84 |
|
93 | 85 |
|
@@ -124,14 +116,17 @@ def main(argv: list[str]) -> int: |
124 | 116 |
|
125 | 117 | print(f'\nRunning {len(runtime_checks)} runtime check(s):') |
126 | 118 | runtime_failures: list[str] = [] |
127 | | - for name, check in runtime_checks: |
| 119 | + for module_path in runtime_checks: |
| 120 | + label = module_path |
128 | 121 | try: |
129 | | - check() |
| 122 | + module = importlib.import_module(module_path) |
| 123 | + label = module.NAME |
| 124 | + module.check() |
130 | 125 | except Exception as e: # noqa: BLE001, PERF203 |
131 | | - runtime_failures.append(f'{name}: {type(e).__name__}: {e}') |
132 | | - print(f' - FAIL: {name}') |
| 126 | + runtime_failures.append(f'{label}: {type(e).__name__}: {e}') |
| 127 | + print(f' - FAIL: {label}') |
133 | 128 | else: |
134 | | - print(f' - OK: {name}') |
| 129 | + print(f' - OK: {label}') |
135 | 130 |
|
136 | 131 | if runtime_failures: |
137 | 132 | print('\nFAILED runtime checks:') |
|
0 commit comments