vscode-swift icon indicating copy to clipboard operation
vscode-swift copied to clipboard

Unable to debug unit tests on VSCode Windows

Open softwarehangar7 opened this issue 1 year ago • 1 comments
trafficstars

I'm trying to debug a unit test on Windows, but I'm receiving the message unable to find executable for <path for file>.xctest.exe (see swift forum discussion )

My build folder doesn't present any file with the .xctest.exe extension. Only .xctest.

Also, it is missing a part of the path. It should be .build\x86_64-unknown-windows-msvc\debug. It's missing the x86_64-unknown-windows-msvc part.

I am able to debug executables, but not unit libraries.

To Reproduce Create any unit test for a swift lib. Open VSCode, build all with --build-tests Click the debug button on the Test Explorer

Environment

  • OS: Windows 10 Pro 21H2 19044.1387
  • Swift version: swift-5.10-RELEASE
  • Visual Studio Code version: 1.87.2
  • vscode-swift version: v1.8.1

softwarehangar7 avatar Mar 23 '24 20:03 softwarehangar7

@compnerd is this a recent change to not include .exe at the end of xctest executable filenames? I was sure it was there previously.

adam-fowler avatar Mar 23 '24 22:03 adam-fowler

I don't think it was ever there, but it really should be.

tristanlabelle avatar Apr 06 '24 12:04 tristanlabelle

This is odd, as I did have it working. I'm currently nowhere near my machine with the Windows VM so can't verify this. I'll probably have to rebuild it again as I haven't touched it in a few months as well.

If I try to fix this blind can you verify this for me @tristanlabelle or @softwarehangar7

adam-fowler avatar Apr 06 '24 12:04 adam-fowler

I've had a look through the code and there is nowhere where the extension adds .exe to xctest executables. @softwarehangar7 Just to verify are you running/debugging tests through the TestExplorer? Also does running tests as opposed to debugging tests work ok?

adam-fowler avatar Apr 06 '24 14:04 adam-fowler

@softwarehangar7 Also finally if you enable setting Swift: Diagnostics in the the Advanced section of the Swift settings. When you run a TestExplorer debug session the launch config used by test explorer is output to the Swift output pane. If you could paste it here that'd be great.

adam-fowler avatar Apr 06 '24 14:04 adam-fowler

I verified that I'm able to debug a test for a Package.swift-driven project.

Also, it is missing a part of the path. It should be .build\x86_64-unknown-windows-msvc\debug. It's missing the x86_64-unknown-windows-msvc part.

On my machine, .build\debug is created as a symbolic link to .build\x86_64-unknown-windows-msvc\debug. Is this not what you see @softwarehangar7 ? If you're missing the symlink, do you have developer mode turned on on your machine? I believe this enables symlinks.

tristanlabelle avatar Apr 09 '24 14:04 tristanlabelle

Hi @adam-fowler and @tristanlabelle. I will test that.

softwarehangar7 avatar Apr 11 '24 23:04 softwarehangar7

On my machine, .build\debug is created as a symbolic link to .build\x86_64-unknown-windows-msvc\debug. Is this not what you see @softwarehangar7 ? If you're missing the symlink, do you have developer mode turned on on your machine? I believe this enables symlinks.

That fixed all the issues. The path issue and also the .xctest.exe issue.

softwarehangar7 avatar Apr 11 '24 23:04 softwarehangar7

I didn't undestand why without symlink it was searching for .xctest.exe though

softwarehangar7 avatar Apr 12 '24 10:04 softwarehangar7

I think this is something internal to vscode. If you try to run an executable and it cannot find it then it tries the same name but with “.exe” appended

On Fri, 12 Apr 2024 at 11:00, Luigi Spacino Scarminio < @.***> wrote:

I didn't undestand why without symlink it was searching for .xctest.exe though

— Reply to this email directly, view it on GitHub https://github.com/swift-server/vscode-swift/issues/728#issuecomment-2051450326, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACHSVJ35XIXYKOI7OYEYCZ3Y46WEXAVCNFSM6AAAAABFE5A5TGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJRGQ2TAMZSGY . You are receiving this because you were mentioned.Message ID: @.***>

adam-fowler avatar Apr 12 '24 12:04 adam-fowler

@softwarehangar7 Nice to hear the issue is fixed. Was it specifically turning on developer mode in settings that did it?

tristanlabelle avatar Apr 12 '24 14:04 tristanlabelle

@tristanlabelle Yes

softwarehangar7 avatar Apr 12 '24 14:04 softwarehangar7

Perhaps we should verify that the user has the SeCreateSymbolicLinkPrivilege privilege before supporting test execution on Windows?

compnerd avatar Apr 28 '24 16:04 compnerd

@compnerd I like the idea, but a few questions:

  1. Does the debug symbolic link exist only to support testing or could it also affect just building / other uses of SPM?
  2. Would testing work if using the full x86_64-unknown-windows-msvc\debug path?
  3. Would it also fail if using swift test directly? What I'm getting at is: is lack of symbolic link a problem for SPM itself, such that it should report the error, or is it only a problem for the VS Code test integration?

tristanlabelle avatar Apr 29 '24 13:04 tristanlabelle

  1. It affects the generated launch.json files as well
  2. Including the triple in the launch.json means it will be different across platforms. For someone who jumps between macOS and Linux using dev containers this could get annoying as the launch.json gets rebuilt and they lose changes
  3. Running swift test would mean you are debugging swift not the test executable.

adam-fowler avatar Apr 29 '24 13:04 adam-fowler

Thanks. It seems reasonable to warn and possibly disable testing if symbolic links are disabled then.

tristanlabelle avatar Apr 29 '24 17:04 tristanlabelle