Repository: microsoft/ptvsd

Issue:
Custom event with process information
Basically identical to the standard 'process' event, but custom. Workaround for [this](https://github.com/Microsoft/ptvsd/issues/503#issuecomment-431193971).


Discussion:

Resolving patch:
diff --git a/ptvsd/wrapper.py b/ptvsd/wrapper.py
--- a/ptvsd/wrapper.py
+++ b/ptvsd/wrapper.py
@@ -1540,7 +1540,6 @@ def send_process_event(self, start_method):
             'startMethod': start_method,
         }
         self.send_event('process', **evt)
-        self.send_event('ptvsd_process', **evt)
 
     @async_handler
     def on_threads(self, request, args):
diff --git a/pytests/helpers/session.py b/pytests/helpers/session.py
--- a/pytests/helpers/session.py
+++ b/pytests/helpers/session.py
@@ -363,16 +363,14 @@ def start_debugging(self, freeze=True):
         # The relative ordering of 'process' and 'configurationDone' is not deterministic.
         # (implementation varies depending on whether it's launch or attach, but in any
         # case, it is an implementation detail).
-        start = self.wait_for_next(Event('process') & Event('ptvsd_process') & Response(configurationDone_request))
+        start = self.wait_for_next(Event('process') & Response(configurationDone_request))
 
-        expected_process_body = {
+        self.expect_new(Event('process', {
             'name': ANY.str,
             'isLocalProcess': True,
             'startMethod': 'launch' if self.method == 'launch' else 'attach',
             'systemProcessId': self.pid if self.pid is not None else ANY.int,
-        }
-        self.expect_new(Event('process', expected_process_body))
-        self.expect_new(Event('ptvsd_process', expected_process_body))
+        }))
 
         if not freeze:
             self.proceed()


Test patch:
diff --git a/tests/highlevel/__init__.py b/tests/highlevel/__init__.py
--- a/tests/highlevel/__init__.py
+++ b/tests/highlevel/__init__.py
@@ -280,10 +280,9 @@ def _handshake(self, command, threadnames=None, config=None, requests=None,
 
         if process:
             with self._fix.wait_for_event('process'):
-                with self._fix.wait_for_event('ptvsd_process'):
-                    with self._fix.wait_for_event('thread'):
-                        if self._pydevd:
-                            self._pydevd.notify_main_thread()
+                with self._fix.wait_for_event('thread'):
+                    if self._pydevd:
+                        self._pydevd.notify_main_thread()
 
         if reset:
             self._fix.reset()
diff --git a/tests/highlevel/test_lifecycle.py b/tests/highlevel/test_lifecycle.py
--- a/tests/highlevel/test_lifecycle.py
+++ b/tests/highlevel/test_lifecycle.py
@@ -78,7 +78,7 @@ def attach(self, expected_os_id, attach_args):
                 req_attach = self.send_request('attach', attach_args)
 
             # configuration
-            with self._fix.wait_for_events(['process', 'ptvsd_process']):
+            with self._fix.wait_for_events(['process']):
                 req_config = self.send_request('configurationDone')
 
             # Normal ops would go here.
@@ -108,12 +108,6 @@ def attach(self, expected_os_id, attach_args):
                isLocalProcess=True,
                startMethod='attach',
             )),
-            self.new_event('ptvsd_process', **dict(
-               name=sys.argv[0],
-               systemProcessId=os.getpid(),
-               isLocalProcess=True,
-               startMethod='attach',
-            )),
         ])
         self.assert_received(self.debugger, [
             self.debugger_msgs.new_request(CMD_VERSION,
diff --git a/tests/highlevel/test_live_pydevd.py b/tests/highlevel/test_live_pydevd.py
--- a/tests/highlevel/test_live_pydevd.py
+++ b/tests/highlevel/test_live_pydevd.py
@@ -165,14 +165,6 @@ def test_launch(self):
                         isLocalProcess=True,
                         startMethod='attach',
                     )),
-                self.new_event(
-                    'ptvsd_process',
-                    **dict(
-                        name=sys.argv[0],
-                        systemProcessId=os.getpid(),
-                        isLocalProcess=True,
-                        startMethod='attach',
-                    )),
                 self.new_event('thread', reason='started', threadId=1),
                 #self.new_event('exited', exitCode=0),
                 #self.new_event('terminated'),
@@ -517,14 +509,6 @@ def test_basic(self):
                     isLocalProcess=True,
                     startMethod='attach',
                 )),
-            self.new_event(
-                'ptvsd_process',
-                **dict(
-                    name=sys.argv[0],
-                    systemProcessId=os.getpid(),
-                    isLocalProcess=True,
-                    startMethod='attach',
-                )),
             self.new_event('thread', reason='started', threadId=1),
             self.new_event(
                 'output',
diff --git a/tests/highlevel/test_messages.py b/tests/highlevel/test_messages.py
--- a/tests/highlevel/test_messages.py
+++ b/tests/highlevel/test_messages.py
@@ -2403,12 +2403,6 @@ def test_launched(self):
                 isLocalProcess=True,
                 startMethod='launch',
             )),
-            self.new_event('ptvsd_process', **dict(
-                name=sys.argv[0],
-                systemProcessId=os.getpid(),
-                isLocalProcess=True,
-                startMethod='launch',
-            )),
             self.expected_event(
                 reason='started',
                 threadId=tid,
@@ -2430,12 +2424,6 @@ def test_attached(self):
                 isLocalProcess=True,
                 startMethod='attach',
             )),
-            self.new_event('ptvsd_process', **dict(
-                name=sys.argv[0],
-                systemProcessId=os.getpid(),
-                isLocalProcess=True,
-                startMethod='attach',
-            )),
             self.expected_event(
                 reason='started',
                 threadId=tid,
@@ -2457,12 +2445,6 @@ def test_process_one_off(self):
                 isLocalProcess=True,
                 startMethod='launch',
             )),
-            self.new_event('ptvsd_process', **dict(
-                name=sys.argv[0],
-                systemProcessId=os.getpid(),
-                isLocalProcess=True,
-                startMethod='launch',
-            )),
             self.expected_event(
                 reason='started',
                 threadId=tid1,
diff --git a/tests/system_tests/test_main.py b/tests/system_tests/test_main.py
--- a/tests/system_tests/test_main.py
+++ b/tests/system_tests/test_main.py
@@ -129,7 +129,7 @@ def test_launch_ptvsd_client(self):
         # Skipping the "thread exited" and "terminated" messages which
         # may appear randomly in the received list.
         received = list(_strip_newline_output_events(session.received))
-        self.assert_received(received[:8], [
+        self.assert_received(received[:7], [
             self.new_version_event(session.received),
             self.new_response(req_initialize.req, **INITIALIZE_RESPONSE),
             self.new_event('initialized'),
@@ -141,12 +141,6 @@ def test_launch_ptvsd_client(self):
                 'startMethod': 'launch',
                 'name': filename,
             }),
-            self.new_event('ptvsd_process', **{
-                'isLocalProcess': True,
-                'systemProcessId': adapter.pid,
-                'startMethod': 'launch',
-                'name': filename,
-            }),
             self.new_event('thread', reason='started', threadId=1),
         ])
 
@@ -168,7 +162,7 @@ def test_launch_ptvsd_server(self):
             adapter.wait()
 
         received = list(_strip_newline_output_events(session.received))
-        self.assert_received(received[:8], [
+        self.assert_received(received[:7], [
             self.new_version_event(session.received),
             self.new_response(req_initialize.req, **INITIALIZE_RESPONSE),
             self.new_event('initialized'),
@@ -180,12 +174,6 @@ def test_launch_ptvsd_server(self):
                 'startMethod': 'launch',
                 'name': filename,
             }),
-            self.new_event('ptvsd_process', **{
-                'isLocalProcess': True,
-                'systemProcessId': adapter.pid,
-                'startMethod': 'launch',
-                'name': filename,
-            }),
             self.new_event('thread', reason='started', threadId=1),
             #self.new_event('thread', reason='exited', threadId=1),
             #self.new_event('exited', exitCode=0),
@@ -209,7 +197,7 @@ def test_attach_started_separately(self):
                 adapter.wait()
 
         received = list(_strip_newline_output_events(session.received))
-        self.assert_received(received[:8], [
+        self.assert_received(received[:7], [
             self.new_version_event(session.received),
             self.new_response(req_initialize.req, **INITIALIZE_RESPONSE),
             self.new_event('initialized'),
@@ -221,12 +209,6 @@ def test_attach_started_separately(self):
                 'startMethod': 'attach',
                 'name': filename,
             }),
-            self.new_event('ptvsd_process', **{
-                'isLocalProcess': True,
-                'systemProcessId': adapter.pid,
-                'startMethod': 'attach',
-                'name': filename,
-            }),
             self.new_event('thread', reason='started', threadId=1),
             #self.new_event('thread', reason='exited', threadId=1),
             #self.new_event('exited', exitCode=0),
@@ -283,12 +265,6 @@ def test_attach_embedded(self):
                 'startMethod': 'attach',
                 'name': filename,
             }),
-            self.new_event('ptvsd_process', **{
-                'isLocalProcess': True,
-                'systemProcessId': adapter.pid,
-                'startMethod': 'attach',
-                'name': filename,
-            }),
             self.new_event('output', output='success!', category='stdout'),
             self.new_event('exited', exitCode=0),
             self.new_event('terminated'),
@@ -338,12 +314,6 @@ def test_reattach(self):
                 'startMethod': 'attach',
                 'name': filename,
             }),
-            self.new_event('ptvsd_process', **{
-                'isLocalProcess': True,
-                'systemProcessId': adapter.pid,
-                'startMethod': 'attach',
-                'name': filename,
-            }),
             self.new_event('thread', reason='started', threadId=1),
             self.new_response(req_disconnect.req),
         ])
@@ -362,12 +332,6 @@ def test_reattach(self):
                 'startMethod': 'attach',
                 'name': filename,
             }),
-            self.new_event('ptvsd_process', **{
-                'isLocalProcess': True,
-                'systemProcessId': adapter.pid,
-                'startMethod': 'attach',
-                'name': filename,
-            }),
             self.new_event('exited', exitCode=0),
             self.new_event('terminated'),
         ])
@@ -487,12 +451,6 @@ def test_detach_clear_and_resume(self):
                 'startMethod': 'attach',
                 'name': filename,
             }),
-            self.new_event('ptvsd_process', **{
-                'isLocalProcess': True,
-                'systemProcessId': adapter.pid,
-                'startMethod': 'attach',
-                'name': filename,
-            }),
             self.new_response(req_bps.req, **{
                 'breakpoints': [{
                     'id': 1,
@@ -548,12 +506,6 @@ def test_detach_clear_and_resume(self):
                 'startMethod': 'attach',
                 'name': filename,
             }),
-            self.new_event('ptvsd_process', **{
-                'isLocalProcess': True,
-                'systemProcessId': adapter.pid,
-                'startMethod': 'attach',
-                'name': filename,
-            }),
             #self.new_event(
             #    'thread',
             #    threadId=tid2,
@@ -769,12 +721,6 @@ def test_attach_breakpoints(self):
                 'startMethod': 'attach',
                 'name': filename,
             }),
-            self.new_event('ptvsd_process', **{
-                'isLocalProcess': True,
-                'systemProcessId': adapter.pid,
-                'startMethod': 'attach',
-                'name': filename,
-            }),
             self.new_event(
                 'stopped',
                 threadId=tid,