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 faulty cmd tokenization #178

Merged
merged 1 commit into from
Nov 4, 2023
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: 1 addition & 2 deletions poethepoet/helpers/command/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ def finalize_token(token_parts):

for word in line:
# For each token part indicate whether it is a glob
token_parts: List[Tuple[str, bool]] = []
for segment in word:
token_parts: List[Tuple[str, bool]] = []

for element in segment:
if isinstance(element, ParamExpansion):
param_value = env.get(element.param_name, "")
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/cmds_project/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
tool.poe.tasks.show_env = "poe_test_env"

tool.poe.tasks.ls_color = "poe_test_echo --color='always' \"a\"' b 'c"

[tool.poe.tasks.echo]
cmd = "poe_test_echo POE_ROOT:$POE_ROOT ${BEST_PASSWORD}, task_args:"
help = "It says what you say"
Expand Down
7 changes: 7 additions & 0 deletions tests/test_cmd_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ def test_cmd_task_with_cwd_option_arg(run_poe_subproc, poe_project_path):
assert result.stderr == ""


def test_cmd_with_complex_token(run_poe_subproc):
result = run_poe_subproc("ls_color", project="cmds")
assert result.capture == "Poe => poe_test_echo --color=always 'a b c'\n"
assert result.stdout == "--color=always a b c\n"
assert result.stderr == ""


def test_cmd_task_with_with_glob_arg_and_cwd(
run_poe_subproc, poe_project_path, is_windows
):
Expand Down