Skip to content

Commit

Permalink
Fix bug to allow ref tasks to pass arguments again
Browse files Browse the repository at this point in the history
  • Loading branch information
nat-n committed Oct 9, 2022
1 parent 9ea3718 commit 69e828c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
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 == ""

0 comments on commit 69e828c

Please sign in to comment.