vscode-swift
vscode-swift copied to clipboard
Unable to debug unit tests on VSCode Windows
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
@compnerd is this a recent change to not include .exe at the end of xctest executable filenames? I was sure it was there previously.
I don't think it was ever there, but it really should be.
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
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?
@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.
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 thex86_64-unknown-windows-msvcpart.
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.
Hi @adam-fowler and @tristanlabelle. I will test that.
On my machine,
.build\debugis 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.
I didn't undestand why without symlink it was searching for .xctest.exe though
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: @.***>
@softwarehangar7 Nice to hear the issue is fixed. Was it specifically turning on developer mode in settings that did it?
@tristanlabelle Yes
Perhaps we should verify that the user has the SeCreateSymbolicLinkPrivilege privilege before supporting test execution on Windows?
@compnerd I like the idea, but a few questions:
- Does the
debugsymbolic link exist only to support testing or could it also affect just building / other uses of SPM? - Would testing work if using the full
x86_64-unknown-windows-msvc\debugpath? - Would it also fail if using
swift testdirectly? 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?
- It affects the generated launch.json files as well
- 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
- Running
swift testwould mean you are debuggingswiftnot the test executable.
Thanks. It seems reasonable to warn and possibly disable testing if symbolic links are disabled then.