diff --git a/CHANGELOG.md b/CHANGELOG.md index 08c0ea6ae4..ad646d22a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ ### Linting +- fix test for linting for version.yml ([#3947](https://github.com/nf-core/tools/pull/3947)) + ### Modules ### Subworkflows diff --git a/nf_core/subworkflows/lint/main_nf.py b/nf_core/subworkflows/lint/main_nf.py index 2167cd20da..cb2177ed5d 100644 --- a/nf_core/subworkflows/lint/main_nf.py +++ b/nf_core/subworkflows/lint/main_nf.py @@ -169,7 +169,7 @@ def check_main_section(self, lines, included_components): ( "main_nf", "main_nf_include_versions", - f"Included component '{component}' versions are not added in main.nf Can be ignored if the module is using topic channels", + f"Included component '{component}' versions are not added in main.nf. Can be ignored if the module is using topic channels", self.main_nf, ) ) diff --git a/tests/modules/lint/test_main_nf.py b/tests/modules/lint/test_main_nf.py index 31b54b9466..a68c42619f 100644 --- a/tests/modules/lint/test_main_nf.py +++ b/tests/modules/lint/test_main_nf.py @@ -137,9 +137,10 @@ def test_main_nf_lint_with_alternative_registry(self): def test_topics_and_emits_version_check(self): """Test that main_nf version emit and topics check works correctly""" + self.mods_install.install("bioawk") # Lint a module known to have versions YAML in main.nf (for now) module_lint = nf_core.modules.lint.ModuleLint(directory=self.pipeline_dir) - module_lint.lint(print_results=False, module="samtools/sort") + module_lint.lint(print_results=False, module="bioawk") assert len(module_lint.failed) == 0, f"Linting failed with {[x.__dict__ for x in module_lint.failed]}" assert len(module_lint.warned) == 2, ( f"Linting warned with {[x.__dict__ for x in module_lint.warned]}, expected 2 warnings" diff --git a/tests/subworkflows/test_lint.py b/tests/subworkflows/test_lint.py index 54ad7e7fc7..a092cd3c37 100644 --- a/tests/subworkflows/test_lint.py +++ b/tests/subworkflows/test_lint.py @@ -228,19 +228,19 @@ def test_subworkflows_lint_include_multiple_alias(self): subworkflow_lint.lint(print_results=False, subworkflow="bam_stats_samtools") assert len(subworkflow_lint.failed) >= 0, f"Linting failed with {[x.__dict__ for x in subworkflow_lint.failed]}" assert len(subworkflow_lint.passed) > 0 - assert len(subworkflow_lint.warned) == 2 - assert any( - [ - x.message == "Included component 'SAMTOOLS_STATS_1' versions are added in main.nf" - for x in subworkflow_lint.passed - ] - ) + assert len(subworkflow_lint.warned) == 3 assert any( [x.message == "Included component 'SAMTOOLS_STATS_1' used in main.nf" for x in subworkflow_lint.passed] ) assert any( [x.message == "Included component 'SAMTOOLS_STATS_2' not used in main.nf" for x in subworkflow_lint.warned] ) + assert any( + [ + x.message.endswith("Can be ignored if the module is using topic channels") + for x in subworkflow_lint.warned + ] + ) # cleanup self.subworkflow_remove.remove("bam_stats_samtools", force=True) @@ -469,7 +469,13 @@ def test_lint_clean_patch(self): assert len(subworkflow_lint.failed) == 0, f"Linting failed with {[x.__dict__ for x in subworkflow_lint.failed]}" assert len(subworkflow_lint.passed) > 0 - assert len(subworkflow_lint.warned) == 0, f"Linting warned with {[x.__dict__ for x in subworkflow_lint.warned]}" + assert len(subworkflow_lint.warned) == 1, f"Linting warned with {[x.__dict__ for x in subworkflow_lint.warned]}" + assert any( + [ + x.message.endswith("Can be ignored if the module is using topic channels") + for x in subworkflow_lint.warned + ] + ) def test_lint_broken_patch(self): """Test linting a patched subworkflow when the patch is broken""" @@ -487,4 +493,10 @@ def test_lint_broken_patch(self): errors = [x.message for x in subworkflow_lint.failed] assert "Subworkflow patch cannot be cleanly applied" in errors assert len(subworkflow_lint.passed) > 0 - assert len(subworkflow_lint.warned) == 0, f"Linting warned with {[x.__dict__ for x in subworkflow_lint.warned]}" + assert len(subworkflow_lint.warned) == 1, f"Linting warned with {[x.__dict__ for x in subworkflow_lint.warned]}" + assert any( + [ + x.message.endswith("Can be ignored if the module is using topic channels") + for x in subworkflow_lint.warned + ] + )