swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
706 stars 47 forks source link

Provide error when debugger isn't started #853

Closed plemarquand closed 3 weeks ago

plemarquand commented 3 weeks ago

When debugging an XCTest that fails to build the debugger promise rejects but did not provide an error. The undefined error is caught and passed to getErrorDescription which fails to read stderr off of it. This caused another error to be thrown and caught at the top level, showing a dialog.

Throw an error string instead of undefined, and handle the undefined error case in getErrorDescription.

adam-fowler commented 3 weeks ago

If a build fails and I click on debug anyway in the dialog, it doesn't run the debug anymore

EDIT: I think you can get rid of the if (buildFailed) section as if the build fails, started is set to false, if you want to change the error message check it in the else block of if (started)

award999 commented 3 weeks ago

If a build fails and I click on debug anyway in the dialog, it doesn't run the debug anymore

So it works for me IFF it succeeded building before. So if delete .build and try to debug the test with build errors, even if I click Debug Anyway, the LLDB extension bails on the debug session. But if the build succeeds once and then introduce the error, then Debug Anyway runs

plemarquand commented 3 weeks ago

"Debug Anyway" is problematic. Right now when debugging swift-testing tests, if Build All fails we close out the named pipe listening for test results. Then the user hits "Debug Anyway" and the pipe has been closed, and no test results arrive and the test run hangs forever.

If we don't close out the named pipe on build failure and the user hits "Abort", then the named pipe stays open and subsequent test runs hang forever.

852 will help somewhat, but only in that it will prevent the "Abort/Debug Anyway" dialog from coming up at all. Then, in the case that a build fails we wont even try to start the debugger.

plemarquand commented 3 weeks ago

I've broken out the build step when debugging and if there is a failure we exit before the debugger is started, sidestepping this issue.