Skip to content

Commit

Permalink
Change references from debugStdLib to justMyCode. Fixes microsoft/ptv…
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Mar 7, 2020
1 parent 198cc57 commit 6b335f1
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import json
from _pydev_bundle import pydev_log
try:
import urllib
urllib.unquote # noqa
Expand All @@ -10,7 +11,7 @@
class DebugOptions(object):

__slots__ = [
'debug_stdlib',
'just_my_code',
'redirect_output',
'show_return_value',
'break_system_exit_zero',
Expand All @@ -21,7 +22,7 @@ class DebugOptions(object):
]

def __init__(self):
self.debug_stdlib = False
self.just_my_code = True
self.redirect_output = False
self.show_return_value = False
self.break_system_exit_zero = False
Expand All @@ -37,8 +38,13 @@ def to_json(self):
return json.dumps(dct)

def update_fom_debug_options(self, debug_options):
if 'DEBUG_STDLIB' in debug_options:
self.debug_stdlib = debug_options.get('DEBUG_STDLIB')

if 'JUST_MY_CODE' in debug_options:
self.just_my_code = debug_options.get('JUST_MY_CODE')
else:
if 'DEBUG_STDLIB' in debug_options:
pydev_log.error_once('DEBUG_STDLIB is deprecated. Use justMyCode=false instead.')
self.just_my_code = not debug_options.get('DEBUG_STDLIB')

if 'REDIRECT_OUTPUT' in debug_options:
self.redirect_output = debug_options.get('REDIRECT_OUTPUT')
Expand All @@ -61,8 +67,14 @@ def update_fom_debug_options(self, debug_options):
# Note: _max_exception_stack_frames cannot be set by debug options.

def update_from_args(self, args):
if 'debugStdLib' in args:
self.debug_stdlib = bool_parser(args['debugStdLib'])

if 'justMyCode' in args:
self.just_my_code = bool_parser(args['justMyCode'])
else:
# i.e.: if justMyCode is provided, don't check the deprecated value
if 'debugStdLib' in args:
pydev_log.error_once('debugStdLib is deprecated. Use justMyCode=false instead.')
self.just_my_code = not bool_parser(args['debugStdLib'])

if 'redirectOutput' in args:
self.redirect_output = bool_parser(args['redirectOutput'])
Expand Down Expand Up @@ -128,6 +140,7 @@ def unquote(s):
'FIX_FILE_PATH_CASE': bool_parser,
'CLIENT_OS_TYPE': unquote,
'DEBUG_STDLIB': bool_parser,
'JUST_MY_CODE': bool_parser,
'STOP_ON_ENTRY': bool_parser,
'SHOW_RETURN_VALUE': bool_parser,
'MULTIPROCESS': bool_parser,
Expand All @@ -143,6 +156,7 @@ def unquote(s):
'Jinja': 'FLASK_DEBUG=True',
'FixFilePathCase': 'FIX_FILE_PATH_CASE=True',
'DebugStdLib': 'DEBUG_STDLIB=True',
'JustMyCode': 'JUST_MY_CODE=True',
'WindowsClient': 'CLIENT_OS_TYPE=WINDOWS',
'UnixClient': 'CLIENT_OS_TYPE=UNIX',
'StopOnEntry': 'STOP_ON_ENTRY=True',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def _set_debug_options(self, py_db, args, start_reason):
self._options.update_fom_debug_options(debug_options)
self._options.update_from_args(args)

self.api.set_use_libraries_filter(py_db, not self._options.debug_stdlib)
self.api.set_use_libraries_filter(py_db, self._options.just_my_code)

path_mappings = []
for pathMapping in args.get('pathMappings', []):
Expand Down
46 changes: 38 additions & 8 deletions src/debugpy/_vendored/pydevd/tests_python/test_debugger_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def update_command_line_args(writer, args):
) as writer:
json_facade = JsonFacade(writer)

json_facade.write_launch(debugStdLib=False if just_my_code else True)
json_facade.write_launch(justMyCode=just_my_code)
json_facade.write_set_exception_breakpoints(['uncaught'])
json_facade.write_make_initial_run()

Expand Down Expand Up @@ -919,7 +919,7 @@ def test_case_path_translation_not_skipped(case_setup):
my_code = debugger_unittest._get_debugger_test_file('my_code')

json_facade.write_launch(
debugOptions=['DebugStdLib'],
justMyCode=False,
pathMappings=[{
'localRoot': sys_folder,
'remoteRoot': my_code,
Expand Down Expand Up @@ -957,7 +957,7 @@ def test_case_skipping_filters(case_setup, custom_setup):
expect_just_my_code = False
if custom_setup == 'set_exclude_launch_path_match_filename':
json_facade.write_launch(
debugOptions=['DebugStdLib'],
justMyCode=False,
rules=[
{'path': '**/other.py', 'include':False},
]
Expand All @@ -966,7 +966,7 @@ def test_case_skipping_filters(case_setup, custom_setup):
elif custom_setup == 'set_exclude_launch_path_match_folder':
not_my_code_dir = debugger_unittest._get_debugger_test_file('not_my_code')
json_facade.write_launch(
debugOptions=['DebugStdLib'],
debugStdLib=True,
rules=[
{'path': not_my_code_dir, 'include':False},
]
Expand Down Expand Up @@ -2172,7 +2172,7 @@ def test_stepping(case_setup):
with case_setup.test_file('_debugger_case_stepping.py') as writer:
json_facade = JsonFacade(writer)

json_facade.write_launch(debugOptions=['DebugStdLib'])
json_facade.write_launch(justMyCode=False)
json_facade.write_set_breakpoints([
writer.get_line_index_with_content('Break here 1'),
writer.get_line_index_with_content('Break here 2')
Expand Down Expand Up @@ -2589,7 +2589,7 @@ def test_source_mapping(case_setup):
json_facade = JsonFacade(writer)

json_facade.write_launch(
debugOptions=['DebugStdLib'],
justMyCode=False,
)

map_to_cell_1_line2 = writer.get_line_index_with_content('map to cell1, line 2')
Expand Down Expand Up @@ -3763,7 +3763,7 @@ def test_debug_options(case_setup, val):
with case_setup.test_file('_debugger_case_debug_options.py') as writer:
json_facade = JsonFacade(writer)
args = dict(
debugStdLib=val,
justMyCode=val,
redirectOutput=True, # Always redirect the output regardless of other values.
showReturnValue=val,
breakOnSystemExitZero=val,
Expand All @@ -3787,7 +3787,7 @@ def test_debug_options(case_setup, val):
translation = {
'django': 'django_debug',
'flask': 'flask_debug',
'debugStdLib': 'debug_stdlib',
'justMyCode': 'just_my_code',
'redirectOutput': 'redirect_output',
'showReturnValue': 'show_return_value',
'breakOnSystemExitZero': 'break_system_exit_zero',
Expand All @@ -3800,6 +3800,36 @@ def test_debug_options(case_setup, val):
writer.finished_ok = True


@pytest.mark.parametrize('debug_stdlib', [True, False])
def test_just_my_code_debug_option_deprecated(case_setup, debug_stdlib, debugger_runner_simple):
from _pydev_bundle import pydev_log
with case_setup.test_file('_debugger_case_debug_options.py') as writer:
json_facade = JsonFacade(writer)
args = dict(
redirectOutput=True, # Always redirect the output regardless of other values.
debugStdLib=debug_stdlib
)
json_facade.write_launch(**args)
json_facade.write_make_initial_run()
output = json_facade.wait_for_json_message(
OutputEvent, lambda msg: msg.body.category == 'stdout' and msg.body.output.startswith('{')and msg.body.output.endswith('}'))

settings = json.loads(output.body.output)
# Note: the internal attribute is just_my_code.
assert settings['just_my_code'] == (not debug_stdlib)
json_facade.wait_for_terminated()

contents = []
for f in pydev_log.list_log_files(debugger_runner_simple.pydevd_debug_file):
if os.path.exists(f):
with open(f, 'r') as stream:
contents.append(stream.read())

assert 'debugStdLib is deprecated. Use justMyCode=false instead.' in ''.join(contents)

writer.finished_ok = True


def test_send_invalid_messages(case_setup):
with case_setup.test_file('_debugger_case_local_variables.py') as writer:
json_facade = JsonFacade(writer)
Expand Down

0 comments on commit 6b335f1

Please sign in to comment.