Skip to content

Commit

Permalink
Assorted test fixes for the Azure automated test run. (microsoft#1123)
Browse files Browse the repository at this point in the history
  • Loading branch information
int19h authored Jan 26, 2019
1 parent 92218e7 commit 26cc6b0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
testpaths=tests
timeout=15
timeout=30
timeout_method=thread
addopts=-n8
53 changes: 33 additions & 20 deletions src/ptvsd/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,37 +698,50 @@ def add_or_get_from_path(self, module_path):
pass

search_path = self._get_platform_file_path(module_path)

for _, value in list(sys.modules.items()):
try:
path = self._get_platform_file_path(value.__file__)
except AttributeError:
path = None

if path and search_path == path:
module_id = self._next_id
self._next_id += 1
if not path:
continue

module = {
'id': module_id,
'package': value.__package__ if hasattr(value, '__package__') else None,
'path': module_path,
}
try:
# This tries to open the files to obtain handles, which can be restricted
# by file permissions, but ensures that long/short path mismatch, symlinks
# etc are all accounted for. Fall back to comparing names in case of failure.
if not os.path.samefile(path, search_path):
continue
except Exception:
if path != search_path:
continue

try:
module['name'] = value.__qualname__
except AttributeError:
module['name'] = value.__name__
module_id = self._next_id
self._next_id += 1

try:
module['version'] = value.__version__
except AttributeError:
pass
module = {
'id': module_id,
'package': value.__package__ if hasattr(value, '__package__') else None,
'path': module_path,
}

try:
module['name'] = value.__qualname__
except AttributeError:
module['name'] = value.__name__

try:
module['version'] = value.__version__
except AttributeError:
pass

self.path_to_module_id[module_path] = module_id
self.module_id_to_details[module_id] = module
self.path_to_module_id[module_path] = module_id
self.module_id_to_details[module_id] = module

self.proc.send_event('module', reason='new', module=module)
return module
self.proc.send_event('module', reason='new', module=module)
return module

return None

Expand Down
9 changes: 5 additions & 4 deletions tests/helpers/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ptvsd.messaging import JsonIOStream, JsonMessageChannel, MessageHandlers

import tests.helpers
from . import colors, debuggee, print, watchdog
from . import colors, debuggee, print
from .messaging import LoggingJsonStream
from .pattern import ANY
from .printer import wait_for_output
Expand All @@ -34,8 +34,8 @@


class DebugSession(object):
WAIT_FOR_EXIT_TIMEOUT = 5
BACKCHANNEL_TIMEOUT = 15
WAIT_FOR_EXIT_TIMEOUT = 10
BACKCHANNEL_TIMEOUT = 20

StopInfo = namedtuple('StopInfo', 'thread_stopped, stacktrace, thread_id, frame_id')

Expand Down Expand Up @@ -268,7 +268,7 @@ def initialize(self, **kwargs):
self.pid = self.process.pid
self.psutil_process = psutil.Process(self.pid)
self.is_running = True
watchdog.create(self.pid)
#watchdog.create(self.pid)

self._capture_output(self.process.stdout, 'OUT')
self._capture_output(self.process.stderr, 'ERR')
Expand Down Expand Up @@ -585,6 +585,7 @@ def connect_to_child_session(self, ptvsd_subprocess):
child_session.handshake()
except:
child_session.close()
raise
else:
return child_session

Expand Down

0 comments on commit 26cc6b0

Please sign in to comment.