diff --git a/docs/changelog/2561.bugfix.rst b/docs/changelog/2561.bugfix.rst new file mode 100644 index 000000000..54c1ef350 --- /dev/null +++ b/docs/changelog/2561.bugfix.rst @@ -0,0 +1 @@ +Support in INI files for ignore exit code marker the ``-`` without a subsequent space too - by :user:`gaborbernat`. diff --git a/src/tox/config/loader/str_convert.py b/src/tox/config/loader/str_convert.py index 260f864d4..dd518e5e3 100644 --- a/src/tox/config/loader/str_convert.py +++ b/src/tox/config/loader/str_convert.py @@ -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 diff --git a/tests/session/cmd/test_sequential.py b/tests/session/cmd/test_sequential.py index 66d6d7937..2aa683a37 100644 --- a/tests/session/cmd/test_sequential.py +++ b/tests/session/cmd/test_sequential.py @@ -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]}"})