Rename flag to make it more meaningful (#326)

Fixes #322
This commit is contained in:
Don Jayamanne 2018-04-09 15:54:08 -07:00 committed by GitHub
parent 295fdedae6
commit 5f7f764e2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 19 deletions

View file

@ -44,7 +44,7 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio
"Jinja", // Enables Jinja (Flask) Template debugging
"FixFilePathCase", // See FIX_FILE_PATH_CASE in wrapper.py
"DebugStdLib" // Whether to enable debugging of standard library functions
"FilePathIsCaseSensitive" // Whether file paths are case sensitive on the client OS
"WindowsClient" // Whether client OS is Windows or not
],
"pathMappings": [
{

View file

@ -896,7 +896,7 @@ class VSCodeMessageProcessor(ipcjson.SocketIO, ipcjson.IpcChannel):
'Jinja': 'FLASK_DEBUG=True',
'FixFilePathCase': 'FIX_FILE_PATH_CASE=True',
'DebugStdLib': 'DEBUG_STD_LIB=True',
'FilePathIsCaseSensitive': 'FILE_PATH_IS_CASE_SENSITIVE=True',
'WindowsClient': 'WINDOWS_CLIENT=True',
}
return ';'.join(debug_option_mapping[option]
for option in debug_options
@ -911,9 +911,11 @@ class VSCodeMessageProcessor(ipcjson.SocketIO, ipcjson.IpcChannel):
INTERPRETER_OPTIONS=string
WEB_BROWSER_URL=string url
DJANGO_DEBUG=True|False
FILE_PATH_IS_CASE_SENSITIVE=True|False
WINDOWS_CLIENT=True|False
"""
bool_parser = lambda str: str in ("True", "true", "1")
def bool_parser(str):
return str in ("True", "true", "1")
DEBUG_OPTIONS_PARSER = {
'WAIT_ON_ABNORMAL_EXIT': bool_parser,
'WAIT_ON_NORMAL_EXIT': bool_parser,
@ -924,7 +926,7 @@ class VSCodeMessageProcessor(ipcjson.SocketIO, ipcjson.IpcChannel):
'DJANGO_DEBUG': bool_parser,
'FLASK_DEBUG': bool_parser,
'FIX_FILE_PATH_CASE': bool_parser,
'FILE_PATH_IS_CASE_SENSITIVE': bool_parser,
'WINDOWS_CLIENT': bool_parser,
}
options = {}
@ -935,9 +937,8 @@ class VSCodeMessageProcessor(ipcjson.SocketIO, ipcjson.IpcChannel):
continue
options[key] = DEBUG_OPTIONS_PARSER[key](value)
if 'FILE_PATH_IS_CASE_SENSITIVE' not in options:
file_path_is_case_sensitive = platform.system() != 'Windows'
options['FILE_PATH_IS_CASE_SENSITIVE'] = file_path_is_case_sensitive # noqa
if 'WINDOWS_CLIENT' not in options:
options['WINDOWS_CLIENT'] = platform.system() == 'Windows' # noqa
return options
@ -952,12 +953,12 @@ class VSCodeMessageProcessor(ipcjson.SocketIO, ipcjson.IpcChannel):
if len(pathMaps) > 0:
pydevd_file_utils.setup_client_server_paths(pathMaps)
def _send_cmd_version_command(self, file_path_is_case_sensitive):
def _send_cmd_version_command(self, windows_client):
cmd = pydevd_comm.CMD_VERSION
os_id = 'UNIX' if file_path_is_case_sensitive else 'WINDOWS'
os_id = 'WINDOWS' if windows_client else 'UNIX'
msg = '1.1\t{}\tID'.format(os_id)
return self.pydevd_request(cmd, msg)
@async_handler
def on_attach(self, request, args):
# TODO: docstring
@ -966,8 +967,8 @@ class VSCodeMessageProcessor(ipcjson.SocketIO, ipcjson.IpcChannel):
options = self.build_debug_options(args.get('debugOptions', []))
self.debug_options = self._parse_debug_options(
args.get('options', options))
file_path_is_case_sensitive = self.debug_options.get('FILE_PATH_IS_CASE_SENSITIVE', False)
yield self._send_cmd_version_command(file_path_is_case_sensitive)
windows_client = self.debug_options.get('WINDOWS_CLIENT', False)
yield self._send_cmd_version_command(windows_client)
self.send_response(request)
@async_handler
@ -977,8 +978,8 @@ class VSCodeMessageProcessor(ipcjson.SocketIO, ipcjson.IpcChannel):
options = self.build_debug_options(args.get('debugOptions', []))
self.debug_options = self._parse_debug_options(
args.get('options', options))
file_path_is_case_sensitive = platform.system() != 'Windows'
yield self._send_cmd_version_command(file_path_is_case_sensitive)
windows_client = platform.system() == 'Windows'
yield self._send_cmd_version_command(windows_client)
self.send_response(request)
def on_disconnect(self, request, args):

View file

@ -111,11 +111,11 @@ class LifecycleTests(HighlevelTest, unittest.TestCase):
self.attach(expected_os_id=OS_ID, attach_args={})
def test_attach_from_unix_os(self):
attach_args = {'options':'FILE_PATH_IS_CASE_SENSITIVE=True'}
attach_args = {'options': 'WINDOWS_CLIENT=False'}
self.attach(expected_os_id='UNIX', attach_args=attach_args)
def test_attach_from_windows_os(self):
attach_args = {'options': 'FILE_PATH_IS_CASE_SENSITIVE=False'}
attach_args = {'options': 'WINDOWS_CLIENT=True'}
self.attach(expected_os_id='WINDOWS', attach_args=attach_args)
def test_launch(self):

View file

@ -28,11 +28,10 @@ from _pydevd_bundle.pydevd_comm import (
CMD_THREAD_KILL,
CMD_THREAD_RUN,
CMD_THREAD_SUSPEND,
CMD_VERSION,
CMD_WRITE_TO_CONSOLE,
)
from . import OS_ID, RunningTest
from . import RunningTest
from ptvsd.wrapper import UnsupportedPyDevdCommandError