Skip to content

Commit b20db0b

Browse files
committed
Fix CI failures and improve LSP tool reliability
- Add LSP tools to longRunningTools (300s timeout) in integration test runner to prevent CI timeouts during JVM startup - Convert relative workspace_uri to file:// URIs in lsp-handlers - Replace synchronous readFileSync with async readFile - Add isRunning() guards to LSP feature methods - Guard exit notification in shutdown to prevent "not running" error - Fix semantic_validation test to use resolvable QL code - Centralize logger mock in test/setup.ts (removes 16 per-file mocks) - Add server-manager getLanguageServer/getQueryServer/getCLIServer tests - Clarify --debug/--tuple-counting arg ordering in server-config - Add missing README.md files to integration test directories
1 parent 0202522 commit b20db0b

File tree

30 files changed

+361
-136
lines changed

30 files changed

+361
-136
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `codeql_lsp_completion/basic_completion`
2+
3+
## PURPOSE
4+
5+
Tests that `codeql_lsp_completion` returns completion items when the cursor is
6+
positioned on a type name in a `from` clause of a CodeQL query.
7+
8+
## INPUTS
9+
10+
- **file_path**: `server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql`
11+
- **line**: 12 (on the type name in the `from` clause)
12+
- **character**: 7 (cursor on the type name)
13+
14+
## EXPECTED OUTPUTS
15+
16+
- A list of completion items (may be empty if no workspace URI is set).
17+
- Monitoring state updated to record a successful `codeql_lsp_completion` call.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `codeql_lsp_definition/basic_definition`
2+
3+
## PURPOSE
4+
5+
Tests that `codeql_lsp_definition` returns definition locations when the cursor
6+
is on a variable name in a `where` clause of a CodeQL query.
7+
8+
## INPUTS
9+
10+
- **file_path**: `server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql`
11+
- **line**: 13 (on a variable reference in the `where` clause)
12+
- **character**: 6 (cursor on the variable name)
13+
14+
## EXPECTED OUTPUTS
15+
16+
- One or more definition locations, or an empty list if the symbol is not resolvable.
17+
- Monitoring state updated to record a successful `codeql_lsp_definition` call.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `codeql_lsp_diagnostics/semantic_validation`
2+
3+
## PURPOSE
4+
5+
Tests that `codeql_lsp_diagnostics` detects semantic errors in QL code that
6+
references undefined types (e.g., `UndefinedType`).
7+
8+
## INPUTS
9+
10+
- **ql_code**: A QL query fragment referencing `UndefinedType` which does not
11+
exist, triggering a semantic "could not resolve type" diagnostic.
12+
13+
## EXPECTED OUTPUTS
14+
15+
- `isValid` is `false` with semantic diagnostics about unresolvable types.
16+
- The `semantic_query.ql` file remains unchanged (identical in before/ and after/).
17+
- Monitoring state updated to record a successful `codeql_lsp_diagnostics` call.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"sessions": []
2+
"sessions": [],
3+
"parameters": {
4+
"ql_code": "from UndefinedType x\nwhere x = \"test\"\nselect x, \"semantic error: undefined type\""
5+
}
36
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# `codeql_lsp_diagnostics/syntax_validation`
2+
3+
## PURPOSE
4+
5+
Tests that `codeql_lsp_diagnostics` detects syntax errors in invalid QL code.
6+
7+
## INPUTS
8+
9+
- **ql_code**: Invalid QL snippet with syntax errors (`invalid_type x\nwhere x = "test"\nselect x, "This has syntax errors"`).
10+
11+
## EXPECTED OUTPUTS
12+
13+
- `isValid` is `false` with one or more error diagnostics.
14+
- The `test_query.ql` file remains unchanged (identical in before/ and after/).
15+
- Monitoring state updated to record a successful `codeql_lsp_diagnostics` call.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `codeql_lsp_references/basic_references`
2+
3+
## PURPOSE
4+
5+
Tests that `codeql_lsp_references` returns reference locations when the cursor
6+
is on a variable name used in a `where` clause of a CodeQL query.
7+
8+
## INPUTS
9+
10+
- **file_path**: `server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql`
11+
- **line**: 13 (on a variable reference in the `where` clause)
12+
- **character**: 6 (cursor on the variable name)
13+
14+
## EXPECTED OUTPUTS
15+
16+
- One or more reference locations, including the declaration.
17+
- Monitoring state updated to record a successful `codeql_lsp_references` call.

client/src/lib/integration-test-runner.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,10 +737,14 @@ export class IntegrationTestRunner {
737737
// Call the tool with appropriate parameters
738738
// Set extended timeout for long-running operations
739739
const longRunningTools = [
740-
"codeql_query_run",
741-
"codeql_test_run",
742740
"codeql_database_analyze",
743-
"codeql_database_create"
741+
"codeql_database_create",
742+
"codeql_lsp_completion",
743+
"codeql_lsp_definition",
744+
"codeql_lsp_diagnostics",
745+
"codeql_lsp_references",
746+
"codeql_query_run",
747+
"codeql_test_run"
744748
];
745749

746750
const requestOptions = longRunningTools.includes(toolName)

server/dist/codeql-development-mcp-server.js

Lines changed: 40 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/dist/codeql-development-mcp-server.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"build": "npm run clean && npm run lint && npm run bundle",
8282
"build:all": "npm run build && npm run test:ql:fail-fast",
8383
"bundle": "node esbuild.config.js",
84-
"clean": "rm -rf dist",
84+
"clean": "rm -rf dist .tmp",
8585
"dev:stdio": "npm run build && TRANSPORT_MODE=stdio node dist/codeql-development-mcp-server.js",
8686
"dev:http": "npm run build && TRANSPORT_MODE=http node dist/codeql-development-mcp-server.js",
8787
"format": "prettier --write 'src/**/*.ts'",

0 commit comments

Comments
 (0)