Run a test in a CI container. Examples: * Run a specific test: tools ts container-test run salt-test-debian-11 \\ tests/pytests/functional/test_version.py::test_salt_extensions_in_versions_report \\ --args --run-slow -x -v * Run all tests in
(
ctx: Context,
container_name: str,
test_path: str,
args: list[str] = None,
)
| 229 | }, |
| 230 | ) |
| 231 | def run_test( |
| 232 | ctx: Context, |
| 233 | container_name: str, |
| 234 | test_path: str, |
| 235 | args: list[str] = None, |
| 236 | ): |
| 237 | """ |
| 238 | Run a test in a CI container. |
| 239 | |
| 240 | Examples: |
| 241 | |
| 242 | * Run a specific test: |
| 243 | |
| 244 | tools ts container-test run salt-test-debian-11 \\ |
| 245 | tests/pytests/functional/test_version.py::test_salt_extensions_in_versions_report \\ |
| 246 | --args --run-slow -x -v |
| 247 | |
| 248 | * Run all tests in a file: |
| 249 | |
| 250 | tools ts container-test run salt-test-debian-11 \\ |
| 251 | tests/pytests/functional/test_version.py \\ |
| 252 | --args --run-slow -x |
| 253 | |
| 254 | * Run tests in a directory: |
| 255 | |
| 256 | tools ts container-test run salt-test-debian-11 \\ |
| 257 | tests/pytests/unit/ \\ |
| 258 | --args -v |
| 259 | """ |
| 260 | if TYPE_CHECKING: |
| 261 | assert container_name is not None |
| 262 | assert test_path is not None |
| 263 | |
| 264 | if not check_docker(ctx): |
| 265 | ctx.exit(1) |
| 266 | |
| 267 | ctx.info(f"Running test in container: {container_name}") |
| 268 | ctx.info(f"Test path: {test_path}") |
| 269 | |
| 270 | # Build command |
| 271 | cmd = [ |
| 272 | "docker", |
| 273 | "exec", |
| 274 | container_name, |
| 275 | "python3", |
| 276 | "-m", |
| 277 | "nox", |
| 278 | "--force-color", |
| 279 | "-e", |
| 280 | "ci-test-onedir", |
| 281 | "--", |
| 282 | test_path, |
| 283 | ] |
| 284 | |
| 285 | if args: |
| 286 | cmd.extend(args) |
| 287 | |
| 288 | ctx.info(f"Running: {' '.join(cmd)}\n") |
nothing calls this directly
no test coverage detected