mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
Fix #1884: Use sys.platform over platform.system()
This commit is contained in:
parent
ca8e6a137b
commit
36485c02c6
16 changed files with 40 additions and 46 deletions
|
|
@ -1,5 +1,5 @@
|
|||
[pytest]
|
||||
testpaths=tests
|
||||
timeout=30
|
||||
timeout=20
|
||||
timeout_method=thread
|
||||
addopts=-n8
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
import ptvsd
|
||||
|
|
@ -206,7 +205,7 @@ class IDE(components.Component, sockets.ClientConnection):
|
|||
elif {"UnixClient", "UNIX"} & debug_options:
|
||||
client_os_type = "UNIX"
|
||||
else:
|
||||
client_os_type = "WINDOWS" if platform.system() == "Windows" else "UNIX"
|
||||
client_os_type = "WINDOWS" if sys.platform == "win32" else "UNIX"
|
||||
self.server.channel.request(
|
||||
"setDebuggerProperty",
|
||||
{
|
||||
|
|
@ -231,7 +230,7 @@ class IDE(components.Component, sockets.ClientConnection):
|
|||
|
||||
sudo = request("sudo", json.default("Sudo" in self.session.debug_options))
|
||||
if sudo:
|
||||
if platform.system() == "Windows":
|
||||
if sys.platform == "win32":
|
||||
raise request.cant_handle('"sudo":true is not supported on Windows.')
|
||||
else:
|
||||
if "Sudo" in self.session.debug_options:
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ import contextlib
|
|||
import functools
|
||||
import inspect
|
||||
import io
|
||||
import platform
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
import threading
|
||||
import traceback
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import platform
|
||||
import socket
|
||||
import sys
|
||||
import threading
|
||||
|
||||
from ptvsd.common import log
|
||||
|
|
@ -37,7 +37,7 @@ def create_client():
|
|||
|
||||
def _new_sock():
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
|
||||
if platform.system() == "Windows":
|
||||
if sys.platform == "win32":
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1)
|
||||
else:
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
|||
|
||||
import functools
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
import ptvsd
|
||||
|
|
@ -51,7 +50,7 @@ class Handlers(object):
|
|||
|
||||
cmdline = []
|
||||
if property_or_debug_option("sudo", "Sudo"):
|
||||
if platform.system() == "Windows":
|
||||
if sys.platform == "win32":
|
||||
raise request.cant_handle('"sudo":true is not supported on Windows.')
|
||||
else:
|
||||
cmdline += ["sudo"]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
|||
import atexit
|
||||
import locale
|
||||
import os
|
||||
import platform
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
|
|
@ -114,7 +113,7 @@ def wait_for_exit():
|
|||
|
||||
try:
|
||||
code = process.wait()
|
||||
if platform.system() != "Windows" and code < 0:
|
||||
if sys.platform != "win32" and code < 0:
|
||||
# On POSIX, if the process was terminated by a signal, Popen will use
|
||||
# a negative returncode to indicate that - but the actual exit code of
|
||||
# the process is always an unsigned number, and can be determined by
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ If there is no configuration phase, the runner returns directly::
|
|||
"""
|
||||
|
||||
import os
|
||||
import platform
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
|
|
@ -159,7 +158,7 @@ def _attach_common_config(session, target, cwd):
|
|||
|
||||
@_runner
|
||||
def attach_by_pid(session, target, cwd=None, wait=True):
|
||||
if sys.version_info < (3,) and platform.system() == "Windows":
|
||||
if sys.version_info < (3,) and sys.platform == "win32":
|
||||
pytest.skip("https://github.com/microsoft/ptvsd/issues/1811")
|
||||
|
||||
log.info("Attaching {0} to {1} by PID.", session, target)
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ Usage::
|
|||
assert "abbc" != some.str.matching(r"ab")
|
||||
assert "abbc" != some.str.matching(r"bc")
|
||||
|
||||
if platform.system() == "Windows":
|
||||
if sys.platform == "win32":
|
||||
assert "\\Foo\\Bar" == some.path("/foo/bar")
|
||||
else:
|
||||
assert "/Foo/Bar" != some.path("/foo/bar")
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import platform
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
from ptvsd.common import sockets
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ class TestSocketServerReuse(object):
|
|||
# NOTE: Windows allows loopback range 127/8. Some flavors of Linux support
|
||||
# 127/8 range. Mac by default supports only 127/0. Configuring /etc/network/interface
|
||||
# for this one test is overkill so use '0.0.0.0' on Mac instead.
|
||||
HOST2 = "127.0.0.2" if platform.system() in ["Windows", "Linux"] else "0.0.0.0"
|
||||
HOST2 = "127.0.0.2" if sys.platform != "darwin" else "0.0.0.0"
|
||||
|
||||
def test_reuse_same_address_port(self):
|
||||
# NOTE: This test should ensure that same address port can be used by two
|
||||
|
|
|
|||
|
|
@ -134,18 +134,27 @@ def test_attach_by_pid(pyfile, target):
|
|||
|
||||
def do_something(i):
|
||||
time.sleep(0.1)
|
||||
proceed = True
|
||||
print(i) # @bp
|
||||
return proceed
|
||||
|
||||
for i in range(100):
|
||||
do_something(i)
|
||||
if not do_something(i):
|
||||
break
|
||||
|
||||
with debug.Session() as session:
|
||||
with session.attach_by_pid(target(code_to_debug), wait=False):
|
||||
session.set_breakpoints(code_to_debug, all)
|
||||
|
||||
session.wait_for_stop(expected_frames=[some.dap.frame(code_to_debug, "bp")])
|
||||
stop = session.wait_for_stop(
|
||||
expected_frames=[some.dap.frame(code_to_debug, "bp")]
|
||||
)
|
||||
|
||||
# Remove breakpoint and continue.
|
||||
session.request(
|
||||
"setExpression",
|
||||
{"frameId": stop.frame_id, "expression": "proceed", "value": "False"},
|
||||
)
|
||||
session.set_breakpoints(code_to_debug, [])
|
||||
session.request_continue()
|
||||
session.wait_for_next(
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import platform
|
||||
import pytest
|
||||
import re
|
||||
import sys
|
||||
|
|
@ -41,7 +40,7 @@ def test_path_with_ampersand(target, run):
|
|||
sys.version_info < (3, 0), reason="Paths are not Unicode in Python 2.7"
|
||||
)
|
||||
@pytest.mark.skipif(
|
||||
platform.system() == "Windows" and sys.version_info < (3, 6),
|
||||
sys.platform == "win32" and sys.version_info < (3, 6),
|
||||
reason="https://github.com/Microsoft/ptvsd/issues/1124#issuecomment-459506802",
|
||||
)
|
||||
@pytest.mark.parametrize("target", targets.all_named)
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import platform
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
from ptvsd.common import compat
|
||||
from tests import code, debug, log, net, test_data
|
||||
|
|
@ -43,8 +43,8 @@ def start_flask(run):
|
|||
"FLASK_DEBUG": "1" if multiprocess else "0",
|
||||
}
|
||||
)
|
||||
if platform.system() != "Windows":
|
||||
locale = "en_US.utf8" if platform.system() == "Linux" else "en_US.UTF-8"
|
||||
if sys.platform != "win32":
|
||||
locale = "en_US.utf8" if sys.platform.startswith("linux") else "en_US.UTF-8"
|
||||
session.config.env.update({"LC_ALL": locale, "LANG": locale})
|
||||
|
||||
session.config.update({"jinja": True, "subProcess": multiprocess})
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import platform
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
|
|
@ -14,6 +13,8 @@ from tests import debug
|
|||
from tests.debug import runners
|
||||
from tests.patterns import some
|
||||
|
||||
pytestmark = pytest.mark.timeout(30)
|
||||
|
||||
|
||||
@pytest.fixture(params=[runners.launch, runners.attach_by_socket["api"]])
|
||||
def run(request):
|
||||
|
|
@ -25,11 +26,11 @@ def run(request):
|
|||
[""]
|
||||
if sys.version_info < (3,)
|
||||
else ["spawn"]
|
||||
if platform.system() == "Windows"
|
||||
if sys.platform == "win32"
|
||||
else ["spawn", "fork"],
|
||||
)
|
||||
def test_multiprocessing(pyfile, target, run, start_method):
|
||||
if start_method == "spawn" and platform.system() != "Windows":
|
||||
if start_method == "spawn" and sys.platform != "win32":
|
||||
pytest.skip("https://github.com/microsoft/ptvsd/issues/1887")
|
||||
|
||||
@pyfile
|
||||
|
|
@ -204,7 +205,6 @@ def test_subprocess(pyfile, target, run):
|
|||
assert child_argv == [child, "--arg1", "--arg2", "--arg3"]
|
||||
|
||||
|
||||
@pytest.mark.timeout(30)
|
||||
@pytest.mark.skip("Needs refactoring to use the new debug.Session API")
|
||||
@pytest.mark.parametrize(
|
||||
"start_method", [runners.launch, runners.attach_by_socket["cli"]]
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import platform
|
||||
import pytest
|
||||
import sys
|
||||
import time
|
||||
|
||||
from tests import debug
|
||||
|
|
@ -129,14 +129,14 @@ def test_step_multi_threads(pyfile, target, run, resume):
|
|||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
platform.system() not in ["Windows", "Linux", "Darwin"],
|
||||
reason="Test not implemented on " + platform.system(),
|
||||
sys.platform not in ["win32", "darwin"] and not sys.platform.startswith("linux"),
|
||||
reason="Test not implemented for sys.platform=" + repr(sys.platform),
|
||||
)
|
||||
def test_debug_this_thread(pyfile, target, run):
|
||||
@pyfile
|
||||
def code_to_debug():
|
||||
from debug_me import ptvsd
|
||||
import platform
|
||||
import sys
|
||||
import threading
|
||||
|
||||
def foo(x):
|
||||
|
|
@ -146,7 +146,7 @@ def test_debug_this_thread(pyfile, target, run):
|
|||
|
||||
event = threading.Event()
|
||||
|
||||
if platform.system() == "Windows":
|
||||
if sys.platform == "win32":
|
||||
from ctypes import CFUNCTYPE, c_void_p, c_size_t, c_uint32, windll
|
||||
|
||||
thread_func_p = CFUNCTYPE(c_uint32, c_void_p)
|
||||
|
|
@ -161,7 +161,7 @@ def test_debug_this_thread(pyfile, target, run):
|
|||
c_uint32(0),
|
||||
c_void_p(0),
|
||||
)
|
||||
elif platform.system() == "Linux" or platform.system() == "Darwin":
|
||||
elif sys.platform == "darwin" or sys.platform.startswith("linux"):
|
||||
from ctypes import CDLL, CFUNCTYPE, byref, c_void_p, c_ulong
|
||||
from ctypes.util import find_library
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ def test_debug_this_thread(pyfile, target, run):
|
|||
byref(c_ulong(0)), c_void_p(0), thread_func, c_void_p(0)
|
||||
)
|
||||
else:
|
||||
assert False
|
||||
pytest.fail(sys.platform)
|
||||
|
||||
event.wait()
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
|
|||
|
||||
import inspect
|
||||
import os
|
||||
import platform
|
||||
import py
|
||||
import pytest
|
||||
import sys
|
||||
import threading
|
||||
import types
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ def daemon(request):
|
|||
assert not thread.is_alive()
|
||||
|
||||
|
||||
if platform.system() != "Windows":
|
||||
if sys.platform != "win32":
|
||||
|
||||
@pytest.fixture
|
||||
def long_tmpdir(request, tmpdir):
|
||||
|
|
|
|||
|
|
@ -151,16 +151,6 @@ def main(tests_pid):
|
|||
proc.pid,
|
||||
)
|
||||
|
||||
# if platform.system() == "Linux":
|
||||
# try:
|
||||
# # gcore will automatically add pid to the filename
|
||||
# core_file = os.path.join(tempfile.gettempdir(), "ptvsd_core")
|
||||
# gcore_cmd = fmt("gcore -o {0} {1}", core_file, proc.pid)
|
||||
# log.warning("WatchDog-{0}: {1}", tests_pid, gcore_cmd)
|
||||
# os.system(gcore_cmd)
|
||||
# except Exception:
|
||||
# log.exception()
|
||||
|
||||
try:
|
||||
proc.kill()
|
||||
except psutil.NoSuchProcess:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue