Skip to content
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
1 change: 1 addition & 0 deletions docs/changelog/2561.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Support in INI files for ignore exit code marker the ``-`` without a subsequent space too - by :user:`gaborbernat`.
3 changes: 3 additions & 0 deletions src/tox/config/loader/str_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def to_command(value: str) -> Command:
pos = splitter.instream.tell()
except ValueError:
args.append(value[pos:])
if args[0] != "-" and args[0].startswith("-"):
args[0] = args[0][1:]
args = ["-"] + args
return Command(args)

@staticmethod
Expand Down
5 changes: 3 additions & 2 deletions tests/session/cmd/test_sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
from tox.tox_env.info import Info


def test_run_ignore_cmd_exit_code(tox_project: ToxProjectCreator) -> None:
@pytest.mark.parametrize("prefix", ["-", "- "])
def test_run_ignore_cmd_exit_code(tox_project: ToxProjectCreator, prefix: str) -> None:
cmd = [
"- python -c 'import sys; print(\"magic fail\", file=sys.stderr); sys.exit(1)'",
f"{prefix}python -c 'import sys; print(\"magic fail\", file=sys.stderr); sys.exit(1)'",
"python -c 'import sys; print(\"magic pass\", file=sys.stdout); sys.exit(0)'",
]
project = tox_project({"tox.ini": f"[tox]\nno_package=true\n[testenv]\ncommands={cmd[0]}\n {cmd[1]}"})
Expand Down