Commit graph

522 commits

Author SHA1 Message Date
Pavel Minaev
0825dbeb37 Add code coverage for tests (excluding ptvsd.server and pydevd).
Fix some issues on Python 2.7.

Remove dead code.
2019-09-18 21:42:51 -07:00
Pavel Minaev
0be597c4b2 Fix #1769: Logpoint messages aren't printed for "launch"
When using launcher to redirect output, tell pydevd to not perform redirection.

Always propagate "output" events from the server to the IDE.

Fix test_log_point to not assume that logpoint output is strictly ordered wrt regular output.
2019-09-16 12:49:28 -07:00
Pavel Minaev
9692e9770f Replace --multiprocess CLI switch with --no-subprocesses to reflect multiproc debugging being on by default.
Fix test_parse_args accordingly.
2019-09-14 01:54:08 -07:00
Pavel Minaev
03b04928e1 Fix test_vs_specific 2019-09-13 11:05:41 -07:00
Pavel Minaev
f00075ffd3 Fix test_disconnect 2019-09-13 11:05:41 -07:00
Pavel Minaev
bb4bc24abf Don't try to gracefully disconnect from the adapter if test fails. 2019-09-13 11:05:41 -07:00
Pavel Minaev
b6d23c4356 test_exception fixes. 2019-09-12 22:33:26 -07:00
Pavel Minaev
8ab0d0d0d6 Fix multiprocessing in Django and Flask tests. 2019-09-12 22:33:26 -07:00
Pavel Minaev
eb1bb4dd5b Test fixes. 2019-09-11 20:12:12 -07:00
Pavel Minaev
340942aafc Fix #1695: Handle IDE, launcher, debug server, and no-debug disconnect
Fix #1721 "runInTerminal" is broken on non-Windows platforms.

Fix #1722: Output is not captured in "noDebug" with "runInTerminal"

Groundwork for #1713: adapter: multiple concurrent sessions

Move "launch" request parsing and debuggee process spawning, PID reporting and tracking, stdio "output" capture, and exit code reporting into launcher. Launcher now communicates to the adapter via a full-fledged message channel.

Refactor adapter. Add an abstraction for a debug session, and treat IDE, launcher, and debug server as separate components managed by that session.

Improve adapter logging to capture information about current debug session, and current message handler if any.

Fix reporting exceptions from message handlers.

Various test fixes.
2019-09-10 15:12:23 -07:00
Karthik Nadig
30615996ba
More test fixes (#1753)
* Migrate tracing feature and update tracing tests

* Other minor fixes

* fix resume on stepping
2019-09-07 10:46:00 -07:00
Karthik Nadig
7623560e3d
Fixes and move more helpers. (#1752) 2019-09-06 14:47:47 -07:00
Karthik Nadig
90d3a6f1ca
Move new tests from master to refactor branch (#1750)
* Add test_step_multi_threads

* Add more tests
2019-09-06 13:39:10 -07:00
Karthik Nadig
6e44d161ca
Fix for attach to pid tests (#1747)
* Fix for attach to pid tests

* Address comments.

* More asserts and comments.
2019-09-05 18:12:22 -07:00
Karthik Nadig
2a367b2f4b
Bunch of minor test fixes (#1726)
* Bunch of minor test fixes

* Fix linter and multiproc

* Remove missed os.environ

* Rename and move stop_debugging

* Add evaluate helper

* Add exit_code property

* Enable pytest and flake8 in workspace

* Fix test failure

* Set ptvsd python path in tests

* Rename exit_code to expected_exit_code
2019-08-29 00:19:50 -07:00
Pavel Minaev
915515d910 Fix output capture for "noDebug".
Ensure that all captured output is reported to the IDE before reporting process exit.

Correctly report "process", "exited", and "terminated" events for "noDebug".

Don't treat partial message reads as fatal error.

Switch test_nodebug to "internalConsole", so that it can properly produce "output" events.

Expect failure response from "setBreakpoints" in test_nodebug.

Fix environment dict being shared between subsequent test runs, causing spurious enable_attach() in debuggee.

Fix ordering in debuggee and adapter cleanup in debug.Session.

Fix launcher.py on Python 2.7
2019-08-24 15:38:48 -07:00
Karthik Nadig
3158583bd3
Fix some tests. (#1719)
* Don't wait for thread event

* Fix get variables

* Fix completion tests

* Fix evaluate tests

* Fix linter
2019-08-23 10:28:46 -07:00
Karthik Nadig
9ece432dff
Attach to pid support (#1701)
* Fix launcher test

* Attach to pid support

* Address comments.

* Minor tweaks
2019-08-19 14:08:23 -07:00
Pavel Minaev
e94980f86c Do not load ptvsd.server (and hence, pydevd) unless the subpackage is loaded explicitly or via a public API entrypoint that requires it.
Move docstrings to top-level package, and update them to reflect the current behavior.

Remove unused code in ptvsd.common.log.

Move sys.path/prefix/site_packages logging into ptvsd.common.log, and log it from adapter and server to the same level of detail as the tests.

Fix injected code snipped for attach-by-PID.

Fix some Unicode issues in adapter and tests.

Refactor Timeline, debug.Session, and start methods.
2019-08-18 11:43:23 -07:00
Karthik Nadig
6eb65d8a7e
Support for noDebug (#1696)
* noDebug mode support

* Ensure we get the debuggee pid on launch

* Fix state change bug

* Tweaking pid retreival

* Use makefile and simplify pid retreival

* Addressing comments

* Run formatter

* Change name common.socket to common.sockets

* Add some timeouts

* Fix linter
2019-08-17 20:23:06 -07:00
Karthik Nadig
0f6a9bb1d6
Update tests to use python debug adapter (#1660)
* Initial fix for launch

* Minor fixes

* Succesful launch tests

* More launch test fixes

* Some bit of cleanup

* Fix linter

* More cleanup

* Attach using import

*  Fix circular importing

* Support attach via command line

* Backchannel and Other test fixes

* Linter fix

* Python path fix in test

* Fix lint after rebase

* Support exitCode in tests

* More fixes after rebase

* Fix expected exit code

* Remove changes to MessageDict __call__

* Remove hold subprocess event
2019-08-12 13:53:24 -07:00
Pavel Minaev
981b1d1559 Fix #1648: Messaging does not allow reverse requests
Separate message parsing and message handling into separate threads.

Remove nested message handling in request handlers via `yield`, since it is incompatible with the new split model, and replace it with NO_RESPONSE and Request.respond() to defer responses until later.

Change Message.cant_handle() and Message.isnt_valid() to respond to the request and return the exception, instead of raising it, to accommodate NO_RESPONSE scenarios where a failure needs to be reported later.

Fix #1678: Do not rely on "processId" being returned by "runInTerminal" request

Extract debuggee PID from the "process" event sent by the debug server.

Fix #1679: "exited" event sometimes reports "exitCode": null

Report it as -1 if it cannot be retrieved from the debuggee process.

Fix #1680: Fatal errors in message loop do not fail fast

os._exit() immediately if a fatal error occurs in message parsing or message handling background threads.
2019-08-11 19:46:54 -07:00
Pavel Minaev
7256e99b52 Use a separate exception type NoMoreMessages to indicate end-of-stream for JSON messaging, to avoid leaking EOFError from disk I/O or from another stream not being properly reported as errors. 2019-08-11 19:46:54 -07:00
Karthik Nadig
e093c86fba
#1449, #1498, partially #1448 (#1651)
* Remove wrapper and in-proc support code

* Fixing up multiproc patching

* Address comments

* Import cleanup

* More cleanup

* Remove loopback fast path

* Disable IDE disconnect unpause-ing

* Add missing file to do not trace
2019-08-02 13:08:07 -07:00
Pavel Minaev
527a17cdce Fix #1614: Test run times out on Python 2.7 (#1615)
Close the watchdog message channel from the test process side after "stop" command is sent and acknowledged.
2019-07-22 22:21:01 -07:00
Pavel Minaev
bb7375da31 Fix test_launcher on Python 2.7. 2019-07-22 17:01:53 -07:00
Karthik Nadig
6aa8134125
Add launcher script that handles wait-on-* feature (#1609)
* Add launcher script that handles wait-on-* feature

* Address comments

* Improve argument parsing

* Add tests

* Address test comments
2019-07-19 13:51:51 -07:00
Pavel Minaev
907351522d Fix race condition in test_attach. 2019-07-18 10:13:02 -07:00
Pavel Minaev
73d29fa55b Work around #1603 in tests.
Add long_tmpdir fixture, that always supplies a long rather than short path name on Windows.

Use long_tmpdir in the implementation of @pyfile, and in all tests that use tmpdir to generate code.
2019-07-18 10:13:02 -07:00
Pavel Minaev
3cb99794d9 Log connection errors in wait_until_port_is_listening() test helper.
Do not reuse socket in wait_until_port_is_listening() to avoid issues on macOS.
2019-07-18 10:13:02 -07:00
Pavel Minaev
4aec028c32 Improve multiprocess and reattach scenario handling in debug.Session.
Use unbuffered pipes for subprocesses on all Python versions.

Make test watchdog more lenient with respect to process ID reuse - warn, but don't fail.
2019-07-18 10:13:02 -07:00
Pavel Minaev
045fb03888 Detect and log watchdog errors in the tests process.
Do not indent messages that are arrays in the log, to reduce watchdog log verbosity.
2019-07-18 10:13:02 -07:00
Pavel Minaev
32e95c434f Fix #1585 for test_add_and_remove_breakpoint 2019-07-18 10:13:02 -07:00
Pavel Minaev
a5312fdc8a Fix #1585 for test_log_point 2019-07-18 10:13:02 -07:00
Pavel Minaev
40f1ded82c Explicitly stop the test watchdog at exit. 2019-07-18 10:13:02 -07:00
Pavel Minaev
c04d394a73 Make test_attach parameters clearer. 2019-07-18 10:13:02 -07:00
Pavel Minaev
2963bf98fe Skip test_reattach (#1594) 2019-07-18 10:13:02 -07:00
Pavel Minaev
44ca8fa3fc Fix #1555: Child process watchdog for tests
Implement per-test-runner out-of-process watchdog for processes spawned by tests.

Add file logging for tests and watchdog.

Improve stdio capture in debug.Session when test fails.

Remove redundant logging in debug.Session.
2019-07-18 10:13:02 -07:00
Pavel Minaev
5dcca5fce0 Fix wrapping in timeline logs, and increase the repr length limit accordingly. 2019-07-18 10:13:02 -07:00
Pavel Minaev
4cd1d4163f Fix #1585: Output tests fail sporadically
Wait on a breakpoint before checking output.

Add temp workaround for #1574: Flask tests fail with "no such option: --wait" on windows py27

Pin Flask version to last known good one in tests/requirements.txt.

Other fixes and improvements:

Make start_method mandatory for debug.Session to avoid problems with tests forgetting to specify it.

Add debug_me.scratchpad to enable async communication between test code and debuggee.

Improve debug.Session logging.

Improve test_attach.
2019-07-18 10:13:02 -07:00
Pavel Minaev
edd5753d7e Further improve timeline logging:
Reformat various timeline log entries to improve readability.

Add pretty-printing of composite expectations, to match pretty-printed JSON.

Avoid redundant repetitions of messages when explaining how occurrences matched expectations.
2019-07-18 10:13:02 -07:00
Pavel Minaev
22f25c8d04 Fix timeline logging on Python 2. 2019-07-18 10:13:02 -07:00
Pavel Minaev
c511e98b02 Remove prints in tests outside of the code being debugged - use logging instead. 2019-07-18 10:13:02 -07:00
Pavel Minaev
8d189c8e91 Improve timeline logging for DAP messages:
Show only the metadata necessary to identify the message to reduce verbosiy.

Use JSON representation for easy matching against message logs.
2019-07-18 10:13:02 -07:00
Pavel Minaev
c03206972d Fix remaining tests to reflect the debug adapter refactoring changes.
Fix Flask and Django multiprocess tests.

Fix test logs not being captured by pytest.

Fix "import debug_me" check improperly applied in tests where it is unnecessary.

Fix some clarifying patterns not respecting the underlying pattern.

Add pattern helpers for strings: starting_with, ending_with, containing.

Move DAP test helpers to a separate module, and add a helper for frames.

Add support for line markers when setting breakpoints and matching frames.

Assorted test fixes around handling of Unicode and paths.
2019-07-11 16:19:06 -07:00
Pavel Minaev
746bda561e Test fixes. 2019-07-09 12:01:13 -07:00
Pavel Minaev
42bbc0946d Test fixes. 2019-07-08 12:03:31 -07:00
Pavel Minaev
82b62b77b5 Fix #1551: Backchannel failures in tests
Fix various bugs around handling of disconnect in JsonIOStream and JsonMessageChannel.

Fix handling of DAP "terminated" event in debug.Session.

Add --ptvsd-logs and --pydevd-logs switches to pytest.

Improve message logging to fully capture the raw message data in the logs if deserialization fails.

Log all debuggee environment variables in debug.Session, and improve log readability.
2019-07-02 17:05:51 -07:00
Karthik Nadig
1e6d2269dd
Replace wait_for_thread_stopped with wait_for_stop (#1550)
* Replace wait_for_thread_stopped with wait_for_stop

* Switch flask tests to use flask server

* Assert linter

* Use marked lines

* Fix stack logging in tests

* Prevent black from formating some debug code

* Simplify flask tests

* Replace send_request(continue) with send_continue

* fix typo
2019-07-01 14:38:07 -07:00
Karthik Nadig
8d75d6d819
Test refactoring migrated to new api (#1544)
* Update ANY to some

* Refactor breakpoint lines in tests

* Replace old import and emable debug with debug_me

* Remove unused code

* Fix some linter issues

* Change from some.such_that to some.str.such_that

* Linting with black
2019-06-28 16:27:38 -07:00