Skip to content

Commit b824736

Browse files
authored
Merge branch 'main' into feat/stderr-color
2 parents 94417db + dbbb043 commit b824736

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

docs/changelog/3450.bugfix.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Log exception name when subprocess execution produces one.
2+
3+
- by :user:`ssbarnea`

src/tox/execute/local_sub_process/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ def __enter__(self) -> ExecuteStatus:
214214
env=self.request.env,
215215
)
216216
except OSError as exception:
217+
# We log a nice error message to avout returning opaque error codes,
218+
# like exit code 2 (filenotfound).
219+
logging.error("Exception running subprocess %s", str(exception)) # noqa: TRY400
217220
return LocalSubprocessExecuteFailedStatus(self.options, self._out, self._err, exception.errno)
218221

219222
status = LocalSubprocessExecuteStatus(self.options, self._out, self._err, process)

tests/execute/local_subprocess/test_local_subprocess.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import locale
55
import logging
66
import os
7+
import re
78
import shutil
89
import stat
910
import subprocess
@@ -276,7 +277,11 @@ def test_command_does_not_exist(caplog: LogCaptureFixture, os_env: dict[str, str
276277
assert outcome.exit_code != Outcome.OK
277278
assert not outcome.out
278279
assert not outcome.err
279-
assert not caplog.records
280+
assert len(caplog.records) == 1
281+
assert caplog.records[0].levelname == "ERROR"
282+
assert re.match(
283+
r".*(No such file or directory|The system cannot find the file specified).*", caplog.records[0].message
284+
)
280285

281286

282287
@pytest.mark.skipif(sys.platform == "win32", reason="You need a conhost shell for keyboard interrupt")

0 commit comments

Comments
 (0)