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

stop cylc validate swallowing useful errors #4936

Merged
merged 5 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Fourth Release Candidate for Cylc 8 suitable for acceptance testing.

### Enhancements

[#4936](https://github.com/cylc/cylc-flow/pull/4936) - Fix incorrect
error messages when workflow CLI commands fail.

[#4877](https://github.com/cylc/cylc-flow/pull/4877) - Upgrade the version of
Jinja2 used by Cylc from 2.11 to 3.0.

Expand Down
7 changes: 1 addition & 6 deletions cylc/flow/id_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from cylc.flow import LOG
from cylc.flow.exceptions import (
InputError,
WorkflowFilesError,
)
from cylc.flow.hostuserutil import get_user
from cylc.flow.id import (
Expand All @@ -38,7 +37,6 @@
scan,
)
from cylc.flow.workflow_files import (
NO_FLOW_FILE_MSG,
check_flow_file,
detect_both_flow_and_suite,
get_flow_file,
Expand Down Expand Up @@ -534,9 +532,6 @@ def _parse_src_path(id_):
if not src_dir_path.is_dir():
raise InputError(f'Path is not a source directory: {src_dir_path}')

try:
src_file_path = check_flow_file(src_dir_path)
except WorkflowFilesError:
raise WorkflowFilesError(NO_FLOW_FILE_MSG.format(id_))
src_file_path = check_flow_file(src_dir_path)

return src_dir_path.name, src_dir_path, src_file_path
10 changes: 8 additions & 2 deletions tests/unit/test_id_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def test_parse_src_path(src_dir, monkeypatch):
# relative '.' dir (invalid)
with pytest.raises(WorkflowFilesError) as exc_ctx:
workflow_id, src_path, src_file_path = _parse_src_path('.')
assert 'No flow.cylc or suite.rc in .' in str(exc_ctx.value)
assert 'No flow.cylc or suite.rc in' in str(exc_ctx.value)

# relative 'invalid/<flow-file>' (invalid)
with pytest.raises(InputError) as exc_ctx:
Expand All @@ -368,7 +368,7 @@ def test_parse_src_path(src_dir, monkeypatch):
# Not a src directory (dir)
with pytest.raises(WorkflowFilesError) as exc_ctx:
_parse_src_path('./blargh')
assert 'No flow.cylc or suite.rc in .' in str(exc_ctx.value)
assert 'No flow.cylc or suite.rc in' in str(exc_ctx.value)

# Not a src directory (file)
wxtim marked this conversation as resolved.
Show resolved Hide resolved
with pytest.raises(InputError) as exc_ctx:
Expand All @@ -389,6 +389,12 @@ def test_parse_src_path(src_dir, monkeypatch):
_parse_src_path('./flow.cylc')
assert 'Not a valid workflow ID or source directory' in str(exc_ctx.value)

# suite.rc & flow.cylc both present:
(src_dir / 'suite.rc').touch()
with pytest.raises(WorkflowFilesError) as exc_ctx:
_parse_src_path(str(src_dir))
assert 'Both flow.cylc and suite.rc files' in str(exc_ctx.value)


async def test_parse_ids_src_path(src_dir):
workflows, src_path = await parse_ids_async(
Expand Down