Describe the bug
QL test discovery throws a user-facing error if one of the workspace folder entries in a multi-root workspace does not exist on the filesystem.
To Reproduce
- Create a VS Code
.code-workspace file (or update an existing one) with the following entry:
{
"folders": [
{
"path": "/does/not/exist"
}
}
- Open that workspace file in VS Code with the CodeQL extension active.
- Activate the CodeQL extension, e.g. by clicking on the CodeQL sidebar panel. (Not necessary if the workspace has CodeQL-related source files or databases that would activate the extension.)
- The extension throws an error:
QL Test Discovery failed. Reason: Resolving tests failed: A fatal error occurred: /does/not/exist does not exist.
[2020-11-30 14:30:07] Exception caught at top level: /does/not/exist does not exist.
com.semmle.cli2.resolve.ResolveTestsCommand.executeJSON(ResolveTestsCommand.java:79)
com.semmle.cli2.resolve.ResolveTestsCommand.executeJSON(ResolveTestsCommand.java:33)
com.semmle.cli2.picocli.SimpleJsonSubcommand.executeInsistingOnJSON(SimpleJsonSubcommand.java:101)
com.semmle.cli2.picocli.SimpleJsonSubcommand.executeSubcommand(SimpleJsonSubcommand.java:77)
com.semmle.cli2.picocli.SubcommandCommon.executeWithParent(SubcommandCommon.java:414)
com.semmle.cli2.execute.CliServerCommand.lambda$executeSubcommand$0(CliServerCommand.java:67)
com.semmle.cli2.picocli.SubcommandMaker.runMain(SubcommandMaker.java:201)
com.semmle.cli2.execute.CliServerCommand.executeSubcommand(CliServerCommand.java:67)
com.semmle.cli2.picocli.SubcommandCommon.call(SubcommandCommon.java:430)
com.semmle.cli2.picocli.SubcommandMaker.runMain(SubcommandMaker.java:201)
com.semmle.cli2.picocli.SubcommandMaker.runMain(SubcommandMaker.java:209)
com.semmle.cli2.CodeQL.main(CodeQL.java:91)
Expected behavior
Test discovery fails gracefully on non-existent workspace folders, and logs a warning without alerting the user.
Additional context
I ran into this for somewhat arcane reasons: I had migrated data between machines, and the filesystem paths to my home directory were different, making the absolute paths in the workspace file incorrect.
A user is more likely to run into this if they delete a directory (source or CodeQL database) from their filesystem without also removing it from the workspace.
Describe the bug
QL test discovery throws a user-facing error if one of the workspace folder entries in a multi-root workspace does not exist on the filesystem.
To Reproduce
.code-workspacefile (or update an existing one) with the following entry:Expected behavior
Test discovery fails gracefully on non-existent workspace folders, and logs a warning without alerting the user.
Additional context
I ran into this for somewhat arcane reasons: I had migrated data between machines, and the filesystem paths to my home directory were different, making the absolute paths in the workspace file incorrect.
A user is more likely to run into this if they delete a directory (source or CodeQL database) from their filesystem without also removing it from the workspace.