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

Fix bug to allow ref tasks to pass arguments again #97

Merged
merged 1 commit into from Oct 9, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions poethepoet/task/ref.py
Expand Up @@ -49,11 +49,12 @@ def _validate_task_def(
return a message describing the first encountered issue if any.
"""
task_ref = task_def["ref"]
task_name_ref = shlex.split(task_ref)[0]

if shlex.split(task_ref)[0] not in config.tasks:
return f"Task {task_name!r} contains reference to unkown task {task_ref!r}"
if task_name_ref not in config.tasks:
return f"Task {task_name!r} contains reference to unkown task {task_name_ref!r}"

referenced_task = config.tasks[task_ref]
referenced_task = config.tasks[task_name_ref]
if isinstance(referenced_task, dict) and referenced_task.get("use_exec"):
return (
f"Invalid task: {task_name!r}. contains illegal reference to task with "
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Expand Up @@ -91,7 +91,6 @@ poethepoet = "poethepoet.plugin:PoetryPlugin"
help = "Execute poe from this repo (useful for testing)"
script = "poethepoet:main"


[tool.coverage.report]
omit = ["**/site-packages/**", "poethepoet/completion/*", "poethepoet/plugin.py"]

Expand Down
10 changes: 9 additions & 1 deletion tests/fixtures/sequences_project/pyproject.toml
Expand Up @@ -24,8 +24,14 @@ travel = [
{ script = "my_package:print_var('DEST')" }
]


[tool.poe.tasks.say]
cmd = "poe_test_echo ${thing}"
args = ["thing"]

[tool.poe.tasks.multiple-value-arg]
sequence = [{ cmd = "poe_test_echo first: ${first}" }, { cmd = " poe_test_echo second: ${second}" }]
sequence = [{ cmd = "poe_test_echo first: ${first}" }, { cmd = " poe_test_echo second: ${second}" }, { ref = "say --thing ${thing}" }]
env = {thing = "Done."}

[[tool.poe.tasks.multiple-value-arg.args]]
name = "first"
Expand All @@ -36,3 +42,5 @@ sequence = [{ cmd = "poe_test_echo first: ${first}" }, { cmd = " poe_test_echo s
positional = true
multiple = true
type = "integer"


4 changes: 2 additions & 2 deletions tests/test_sequence_tasks.py
Expand Up @@ -52,7 +52,7 @@ def test_sequence_task_with_multiple_value_arg(run_poe_subproc):
)
assert (
result.capture
== "Poe => poe_test_echo first: hey\nPoe => poe_test_echo second: 1 2 3\n"
== "Poe => poe_test_echo first: hey\nPoe => poe_test_echo second: 1 2 3\nPoe => poe_test_echo Done.\n"
)
assert result.stdout == "first: hey\nsecond: 1 2 3\n"
assert result.stdout == "first: hey\nsecond: 1 2 3\nDone.\n"
assert result.stderr == ""