diff --git a/CHANGELOG.md b/CHANGELOG.md index 609c3aea06..0f09ab3089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ - Update python:3.12-slim Docker digest to f11725a ([#3071](https://github.com/nf-core/tools/pull/3071)) - Fix number of arguments for pipelines_create within the command_create function ([#3074](https://github.com/nf-core/tools/pull/3074)) - Update python:3.12-slim Docker digest to 740d94a ([#3079](https://github.com/nf-core/tools/pull/3079)) +- Add `--migrate_pytest` option to `nf-core test` command ([#3085](https://github.com/nf-core/tools/pull/3085)) - Update pre-commit hook pre-commit/mirrors-mypy to v1.11.1 ([#3091](https://github.com/nf-core/tools/pull/3091)) - Pipelines: allow numbers in custom pipeline name ([#3094](https://github.com/nf-core/tools/pull/3094)) - Add bot action to update textual snapshots and write bot documentation ([#3102](https://github.com/nf-core/tools/pull/3102)) diff --git a/nf_core/__main__.py b/nf_core/__main__.py index 3da153ee1f..00ae8e2a1f 100644 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -1154,11 +1154,17 @@ def command_modules_create( default=None, help="Run tests with a specific profile", ) -def command_modules_test(ctx, tool, dir, no_prompts, update, once, profile): +@click.option( + "--migrate-pytest", + is_flag=True, + default=False, + help="Migrate a module with pytest tests to nf-test", +) +def command_modules_test(ctx, tool, dir, no_prompts, update, once, profile, migrate_pytest): """ Run nf-test for a module. """ - modules_test(ctx, tool, dir, no_prompts, update, once, profile) + modules_test(ctx, tool, dir, no_prompts, update, once, profile, migrate_pytest) # nf-core modules lint @@ -1352,11 +1358,17 @@ def command_subworkflows_create(ctx, subworkflow, dir, author, force, migrate_py default=None, help="Run tests with a specific profile", ) -def command_subworkflows_test(ctx, subworkflow, dir, no_prompts, update, once, profile): +@click.option( + "--migrate-pytest", + is_flag=True, + default=False, + help="Migrate a subworkflow with pytest tests to nf-test", +) +def command_subworkflows_test(ctx, subworkflow, dir, no_prompts, update, once, profile, migrate_pytest): """ Run nf-test for a subworkflow. """ - subworkflows_test(ctx, subworkflow, dir, no_prompts, update, once, profile) + subworkflows_test(ctx, subworkflow, dir, no_prompts, update, once, profile, migrate_pytest) # nf-core subworkflows list subcommands diff --git a/nf_core/commands_modules.py b/nf_core/commands_modules.py index 3d96d332b0..a34e9a519e 100644 --- a/nf_core/commands_modules.py +++ b/nf_core/commands_modules.py @@ -219,7 +219,7 @@ def modules_create( sys.exit(1) -def modules_test(ctx, tool, dir, no_prompts, update, once, profile): +def modules_test(ctx, tool, dir, no_prompts, update, once, profile, migrate_pytest): """ Run nf-test for a module. @@ -227,6 +227,21 @@ def modules_test(ctx, tool, dir, no_prompts, update, once, profile): """ from nf_core.components.components_test import ComponentsTest + if migrate_pytest: + modules_create( + ctx, + tool, + dir, + author="", + label="", + meta=True, + no_meta=False, + force=False, + conda_name=None, + conda_package_version=None, + empty_template=False, + migrate_pytest=migrate_pytest, + ) try: module_tester = ComponentsTest( component_type="modules", diff --git a/nf_core/commands_subworkflows.py b/nf_core/commands_subworkflows.py index a3abce3f85..8b2db3578a 100644 --- a/nf_core/commands_subworkflows.py +++ b/nf_core/commands_subworkflows.py @@ -34,7 +34,7 @@ def subworkflows_create(ctx, subworkflow, dir, author, force, migrate_pytest): sys.exit(1) -def subworkflows_test(ctx, subworkflow, dir, no_prompts, update, once, profile): +def subworkflows_test(ctx, subworkflow, dir, no_prompts, update, once, profile, migrate_pytest): """ Run nf-test for a subworkflow. @@ -42,6 +42,8 @@ def subworkflows_test(ctx, subworkflow, dir, no_prompts, update, once, profile): """ from nf_core.components.components_test import ComponentsTest + if migrate_pytest: + subworkflows_create(ctx, subworkflow, dir, None, False, True) try: sw_tester = ComponentsTest( component_type="subworkflows",