|
2 | 2 | from pathlib import Path |
3 | 3 | from typing import Union, List |
4 | 4 | from typing_extensions import Annotated |
| 5 | +import commit0.harness.batch_run_pytest_ids |
5 | 6 | import commit0.harness.run_pytest_ids |
6 | 7 | import commit0.harness.get_pytest_ids |
7 | 8 | import commit0.harness.build |
@@ -300,6 +301,49 @@ def test( |
300 | 301 | ) |
301 | 302 |
|
302 | 303 |
|
| 304 | +@commit0_app.command() |
| 305 | +def batch_test( |
| 306 | + test_ids: str = typer.Argument( |
| 307 | + None, |
| 308 | + help='All ways pytest supports to run and select tests. Please provide a single string. Example: "test_mod.py", "testing/", "test_mod.py::test_func", "-k \'MyClass and not method\'"', |
| 309 | + ), |
| 310 | + backend: str = typer.Option("modal", help="Backend to use for testing"), |
| 311 | + timeout: int = typer.Option(1800, help="Timeout for tests in seconds"), |
| 312 | + num_cpus: int = typer.Option(1, help="Number of CPUs to use"), |
| 313 | + reference: Annotated[ |
| 314 | + bool, typer.Option("--reference", help="Test the reference commit") |
| 315 | + ] = False, |
| 316 | + coverage: Annotated[ |
| 317 | + bool, typer.Option("--coverage", help="Whether to get coverage information") |
| 318 | + ] = False, |
| 319 | + rebuild: bool = typer.Option( |
| 320 | + False, "--rebuild", help="Whether to rebuild an image" |
| 321 | + ), |
| 322 | + commit0_config_file: str = typer.Option( |
| 323 | + ".commit0.yaml", |
| 324 | + help="Path to the commit0 dot file, where the setup config is stored", |
| 325 | + ), |
| 326 | + verbose: int = typer.Option( |
| 327 | + 1, |
| 328 | + "--verbose", |
| 329 | + "-v", |
| 330 | + help="Set this to 2 for more logging information", |
| 331 | + count=True, |
| 332 | + ), |
| 333 | +) -> None: |
| 334 | + """Run tests on a Commit0 repository.""" |
| 335 | + commit0.harness.batch_run_pytest_ids.main( |
| 336 | + test_ids, |
| 337 | + reference, |
| 338 | + coverage, |
| 339 | + backend, |
| 340 | + timeout, |
| 341 | + num_cpus, |
| 342 | + rebuild, |
| 343 | + verbose, |
| 344 | + ) |
| 345 | + |
| 346 | + |
303 | 347 | @commit0_app.command() |
304 | 348 | def evaluate( |
305 | 349 | branch: Union[str, None] = typer.Option( |
|
0 commit comments