Skip to content

Commit

Permalink
Merge pull request #3085 from mashehu/tool-fairy
Browse files Browse the repository at this point in the history
Add `--migrate_pytest` option to `nf-core test` command
  • Loading branch information
mashehu authored Aug 8, 2024
2 parents e4d6b21 + 4247c87 commit 6a54a32
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <modules|subworkflows> 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))
Expand Down
20 changes: 16 additions & 4 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion nf_core/commands_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,29 @@ 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.
Given the name of a module, runs the nf-test command to test the module and generate snapshots.
"""
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",
Expand Down
4 changes: 3 additions & 1 deletion nf_core/commands_subworkflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ 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.
Given the name of a subworkflow, runs the nf-test command to test the subworkflow and generate snapshots.
"""
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",
Expand Down

0 comments on commit 6a54a32

Please sign in to comment.