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 4ee3314
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
7 changes: 4 additions & 3 deletions poethepoet/task/ref.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
4 changes: 2 additions & 2 deletions tests/fixtures/sequences_project/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[tool.poe.tasks]

part1 = "poe_test_echo 'Hello'"
_part2.cmd = "poe_test_echo '${SUBJECT}!'"
_part2.cmd = "poe_test_echo '${SUBJECT}'"
_part2.env = { SUBJECT = "World" }
composite_task.sequence = [
["part1", "_part2"],
["part1", "_part2 !!"],
# wrapping in arrays means we can have different types of task in the sequence
[{cmd = "poe_test_echo '${SMILEY}!'"}]
]
Expand Down
16 changes: 8 additions & 8 deletions tests/test_sequence_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ def test_sequence_task(run_poe_subproc, esc_prefix, is_windows):
# On windows shlex works in non-POSIX mode which results in quotes
assert (
result.capture
== f"Poe => poe_test_echo 'Hello'\nPoe => poe_test_echo 'World!'\nPoe => poe_test_echo ':)!'\n"
== f"Poe => poe_test_echo 'Hello'\nPoe => poe_test_echo 'World'\nPoe => poe_test_echo ':) !!'\n"
)
assert result.stdout == f"'Hello'\n'World!'\n':)!'\n"
assert result.stdout == f"'Hello'\n'World'\n':)!'\n"
else:
assert (
result.capture
== f"Poe => poe_test_echo Hello\nPoe => poe_test_echo World!\nPoe => poe_test_echo :)!\n"
== f"Poe => poe_test_echo Hello\nPoe => poe_test_echo World\nPoe => poe_test_echo :)!\n"
)
assert result.stdout == f"Hello\nWorld!\n:)!\n"
assert result.stdout == f"Hello\nWorld\n:)!\n"
assert result.stderr == ""


Expand All @@ -23,15 +23,15 @@ def test_another_sequence_task(run_poe_subproc, esc_prefix, is_windows):
# On windows shlex works in non-POSIX mode which results in quotes
assert (
result.capture
== f"Poe => poe_test_echo 'Hello'\nPoe => poe_test_echo 'World!'\nPoe => poe_test_echo ':)!'\n"
== f"Poe => poe_test_echo 'Hello'\nPoe => poe_test_echo 'World'\nPoe => poe_test_echo ':) !!'\n"
)
assert result.stdout == f"'Hello'\n'World!'\n':)!'\n"
assert result.stdout == f"'Hello'\n'World'\n':)!'\n"
else:
assert (
result.capture
== f"Poe => poe_test_echo Hello\nPoe => poe_test_echo World!\nPoe => poe_test_echo :)!\n"
== f"Poe => poe_test_echo Hello\nPoe => poe_test_echo World\nPoe => poe_test_echo :)!\n"
)
assert result.stdout == f"Hello\nWorld!\n:)!\n"
assert result.stdout == f"Hello\nWorld\n:)!\n"
assert result.stderr == ""


Expand Down

0 comments on commit 4ee3314

Please sign in to comment.