Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail linting if md5sum for empty files are found in a stub test #2571

Merged
merged 4 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Correctly pass subworkflow linting test if `COMPONENT.out.versions` is used in the script ([#2448](https://github.com/nf-core/tools/pull/2448))
- Check for spaces in modules container URLs ([#2452](https://github.com/nf-core/tools/issues/2452))
- Correctly ignore `timeline.enabled`, `report.enabled`, `trace.enabled`, `dag.enabled` variables when linting a pipeline. ([#2507](https://github.com/nf-core/tools/pull/2507))
- Don't fail linting if md5sum for empty files are found in a stub test ([#2571](https://github.com/nf-core/tools/pull/2571))

### Modules

Expand Down
82 changes: 51 additions & 31 deletions nf_core/modules/lint/module_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Lint the tests of a module in nf-core/modules
"""
import json
import logging
from pathlib import Path

Expand Down Expand Up @@ -52,39 +53,58 @@ def module_tests(_, module: NFCoreComponent):
)
# Validate no empty files
with open(snap_file, "r") as snap_fh:
snap_content = snap_fh.read()
if "d41d8cd98f00b204e9800998ecf8427e" in snap_content:
module.failed.append(
(
"test_snap_md5sum",
"md5sum for empty file found: d41d8cd98f00b204e9800998ecf8427e",
snap_file,
snap_content = json.load(snap_fh)
for test_name in snap_content.keys():
if "d41d8cd98f00b204e9800998ecf8427e" in str(snap_content[test_name]):
if "stub" not in test_name:
module.failed.append(
(
"test_snap_md5sum",
"md5sum for empty file found: d41d8cd98f00b204e9800998ecf8427e",
snap_file,
)
)
else:
module.passed.append(
(
"test_snap_md5sum",
"md5sum for empty file found, but it is a stub test",
snap_file,
)
)
else:
module.passed.append(
(
"test_snap_md5sum",
"no md5sum for empty file found",
snap_file,
)
)
)
else:
module.passed.append(
(
"test_snap_md5sum",
"no md5sum for empty file found",
snap_file,
if "7029066c27ac6f5ef18d660d5741979a" in str(snap_content[test_name]):
if "stub" not in test_name:
module.failed.append(
(
"test_snap_md5sum",
"md5sum for compressed empty file found: 7029066c27ac6f5ef18d660d5741979a",
snap_file,
)
)
else:
module.passed.append(
(
"test_snap_md5sum",
"md5sum for compressed empty file found, but it is a stub test",
snap_file,
)
)
else:
module.passed.append(
(
"test_snap_md5sum",
"no md5sum for compressed empty file found",
snap_file,
)
)
)
if "7029066c27ac6f5ef18d660d5741979a" in snap_content:
module.failed.append(
(
"test_snap_md5sum",
"md5sum for compressed empty file found: 7029066c27ac6f5ef18d660d5741979a",
snap_file,
)
)
else:
module.passed.append(
(
"test_snap_md5sum",
"no md5sum for compressed empty file found",
snap_file,
)
)
else:
module.failed.append(
("test_snapshot_exists", "snapshot file `main.nf.test.snap` does not exist", snap_file)
Expand Down
82 changes: 51 additions & 31 deletions nf_core/subworkflows/lint/subworkflow_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Lint the tests of a subworkflow in nf-core/modules
"""
import json
import logging
from pathlib import Path

Expand Down Expand Up @@ -59,39 +60,58 @@ def subworkflow_tests(_, subworkflow: NFCoreComponent):
subworkflow.passed.append(("test_snapshot_exists", "test `main.nf.test.snap` exists", snap_file))
# Validate no empty files
with open(snap_file, "r") as snap_fh:
snap_content = snap_fh.read()
if "d41d8cd98f00b204e9800998ecf8427e" in snap_content:
subworkflow.failed.append(
(
"test_snap_md5sum",
"md5sum for empty file found: d41d8cd98f00b204e9800998ecf8427e",
snap_file,
snap_content = json.load(snap_fh)
for test_name in snap_content.keys():
if "d41d8cd98f00b204e9800998ecf8427e" in str(snap_content[test_name]):
if "stub" not in test_name:
subworkflow.failed.append(
(
"test_snap_md5sum",
"md5sum for empty file found: d41d8cd98f00b204e9800998ecf8427e",
snap_file,
)
)
else:
subworkflow.passed.append(
(
"test_snap_md5sum",
"md5sum for empty file found, but it is a stub test",
snap_file,
)
)
else:
subworkflow.passed.append(
(
"test_snap_md5sum",
"no md5sum for empty file found",
snap_file,
)
)
)
else:
subworkflow.passed.append(
(
"test_snap_md5sum",
"no md5sum for empty file found",
snap_file,
if "7029066c27ac6f5ef18d660d5741979a" in str(snap_content[test_name]):
if "stub" not in test_name:
subworkflow.failed.append(
(
"test_snap_md5sum",
"md5sum for compressed empty file found: 7029066c27ac6f5ef18d660d5741979a",
snap_file,
)
)
else:
subworkflow.failed.append(
(
"test_snap_md5sum",
"md5sum for compressed empty file found, but it is a stub test",
snap_file,
)
)
else:
subworkflow.passed.append(
(
"test_snap_md5sum",
"no md5sum for compressed empty file found",
snap_file,
)
)
)
if "7029066c27ac6f5ef18d660d5741979a" in snap_content:
subworkflow.failed.append(
(
"test_snap_md5sum",
"md5sum for compressed empty file found: 7029066c27ac6f5ef18d660d5741979a",
snap_file,
)
)
else:
subworkflow.passed.append(
(
"test_snap_md5sum",
"no md5sum for compressed empty file found",
snap_file,
)
)
else:
subworkflow.failed.append(
("test_snapshot_exists", "test `main.nf.test.snap` does not exist", snap_file)
Expand Down
Loading