Skip to content

Commit 53923c7

Browse files
authored
Merge pull request #1760 from python-cmd2/windows-dev-issues
Remove Windows development papercuts
2 parents c33a7ed + 492228c commit 53923c7

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎.prettierrc‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"endOfLine": "lf",
23
"printWidth": 100,
34
"proseWrap": "always",
45
"overrides": [

‎tests/test_utils.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,19 @@ def pr_none():
191191
# Put the new process into a separate group so its signal are isolated from ours
192192
kwargs = {}
193193
if sys.platform.startswith("win"):
194-
command = "timeout -t 5 /nobreak"
195194
kwargs["creationflags"] = subprocess.CREATE_NEW_PROCESS_GROUP
196195
else:
197-
command = "sleep 5"
198196
kwargs["start_new_session"] = True
199197

200-
proc = subprocess.Popen(command, shell=True, **kwargs)
201-
return cu.ProcReader(proc, None, None)
198+
# The child restores the default SIGINT action so that, like `sleep`, it dies with -SIGINT on POSIX
199+
child_code = "import signal, time; signal.signal(signal.SIGINT, signal.SIG_DFL); print('ready', flush=True); time.sleep(5)"
200+
proc = subprocess.Popen([sys.executable, "-c", child_code], stdout=subprocess.PIPE, **kwargs)
201+
202+
# Wait for the child to report that it is running before returning it to a test. Signaling a Windows console
203+
# process before it has finished initializing makes it fail with STATUS_DLL_INIT_FAILED (0xc0000142) and pop up
204+
# an "Application Error" dialog that blocks the test run until someone clicks OK.
205+
assert proc.stdout.readline().strip() == b"ready"
206+
return cu.ProcReader(proc, sys.stdout, sys.stderr)
202207

203208

204209
def test_proc_reader_send_sigint(pr_none) -> None:

‎ty.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[environment]
22
python-version = "3.11"
3+
# Check every platform's branches (rather than the host's) so ty behaves identically on Linux, macOS, and Windows.
4+
python-platform = "all"
35

46
[src]
57
include = ["cmd2"]

0 commit comments

Comments
 (0)