Skip to content

Commit d375e41

Browse files
committed
Fixes for codeql_lsp_* tool integration tests
1 parent e561fa4 commit d375e41

28 files changed

+6925
-6396
lines changed

client/integration-tests/primitives/tools/codeql_lsp_completion/basic_completion/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22

33
## PURPOSE
44

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.
5+
Tests that `codeql_lsp_completion` returns targeted completion items for a
6+
member-access expression. The cursor is positioned after `f.getBa` so the
7+
language server should return completions matching the prefix (e.g.
8+
`getBaseName`). Uses `file_content` to provide inline query text, which
9+
avoids disk I/O and produces a small, focused result set.
710

811
## INPUTS
912

13+
- **file_content**: Inline QL with cursor after `f.getBa`
1014
- **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)
15+
- **line**: 3 (`where f.getBa`)
16+
- **character**: 13 (end of `getBa` prefix)
17+
- **workspace_uri**: `server/ql/javascript/examples`
1318

1419
## EXPECTED OUTPUTS
1520

16-
- A list of completion items (may be empty if no workspace URI is set).
21+
- A list of completion items matching the `getBa` prefix (e.g. `getBaseName`).
1722
- Monitoring state updated to record a successful `codeql_lsp_completion` call.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"sessions": [],
33
"parameters": {
4+
"file_content": "import javascript\n\nfrom File f\nwhere f.getBa\nselect f",
45
"file_path": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
5-
"line": 12,
6-
"character": 7
6+
"line": 3,
7+
"character": 13,
8+
"workspace_uri": "server/ql/javascript/examples"
79
}
810
}

client/integration-tests/primitives/tools/codeql_lsp_completion/from_clause_completion/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22

33
## PURPOSE
44

5-
Tests that `codeql_lsp_completion` returns completion items when the cursor is
6-
positioned inside a `from` clause after an `import` statement.
5+
Tests that `codeql_lsp_completion` returns keyword completions when the cursor
6+
is positioned after a partial keyword `wh` following a `from` clause. Uses
7+
`file_content` to provide inline query text, producing a small set of
8+
completions (e.g. `where`) rather than an exhaustive type list.
79

810
## INPUTS
911

12+
- **file_content**: Inline QL with cursor after `wh` prefix
1013
- **file_path**: `server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql`
11-
- **line**: 11 (inside the `from` clause)
12-
- **character**: 5 (after keyword prefix)
14+
- **line**: 3 (after `wh`)
15+
- **character**: 2 (end of `wh` prefix)
16+
- **workspace_uri**: `server/ql/javascript/examples`
1317

1418
## EXPECTED OUTPUTS
1519

16-
- A non-empty list of completion items with labels, documentation, and kind.
20+
- A list of completion items matching the `wh` prefix (e.g. `where`).
1721
- Monitoring state updated to record a successful `codeql_lsp_completion` call.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"sessions": [],
33
"parameters": {
4+
"file_content": "import javascript\n\nfrom File f\nwh",
45
"file_path": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
5-
"line": 11,
6-
"character": 5,
6+
"line": 3,
7+
"character": 2,
78
"workspace_uri": "server/ql/javascript/examples"
89
}
910
}

client/integration-tests/primitives/tools/codeql_lsp_definition/basic_definition/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@
22

33
## PURPOSE
44

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.
5+
Tests that `codeql_lsp_definition` resolves the definition of a type used in a
6+
`from` clause. The cursor is on `File` (line 2, character 7) which should
7+
resolve to the `File` class definition in the JavaScript CodeQL library.
8+
Uses `file_content` to provide inline query text.
79

810
## INPUTS
911

12+
- **file_content**: Inline QL with `from File f` clause
1013
- **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)
14+
- **line**: 2 (on the `File` type in `from File f`)
15+
- **character**: 7 (cursor on `File`)
16+
- **workspace_uri**: `server/ql/javascript/examples`
1317

1418
## EXPECTED OUTPUTS
1519

16-
- One or more definition locations, or an empty list if the symbol is not resolvable.
20+
- One or more definition locations with URIs pointing to `.qll` library files.
1721
- Monitoring state updated to record a successful `codeql_lsp_definition` call.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"sessions": [],
33
"parameters": {
4+
"file_content": "import javascript\n\nfrom File f\nwhere f.getBaseName() = \"test.js\"\nselect f, \"found\"",
45
"file_path": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
5-
"line": 13,
6-
"character": 6
6+
"line": 2,
7+
"character": 7,
8+
"workspace_uri": "server/ql/javascript/examples"
79
}
810
}

client/integration-tests/primitives/tools/codeql_lsp_definition/class_definition/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22

33
## PURPOSE
44

5-
Tests that `codeql_lsp_definition` returns definition locations when the cursor
6-
is on a class name used in a `from` clause.
5+
Tests that `codeql_lsp_definition` resolves the definition of the `javascript`
6+
library module from an `import` statement. The cursor is on `javascript`
7+
(line 0, character 10) which should resolve to the library module definition.
8+
Uses `file_content` to provide inline query text.
79

810
## INPUTS
911

12+
- **file_content**: Inline QL with `import javascript` statement
1013
- **file_path**: `server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql`
11-
- **line**: 12 (on the class name in the `from` clause)
12-
- **character**: 5 (cursor on the class name)
14+
- **line**: 0 (on the `import javascript` statement)
15+
- **character**: 10 (cursor on `javascript`)
16+
- **workspace_uri**: `server/ql/javascript/examples`
1317

1418
## EXPECTED OUTPUTS
1519

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"sessions": [],
33
"parameters": {
4+
"file_content": "import javascript\n\nfrom File f\nwhere f.getBaseName() = \"test.js\"\nselect f, \"found\"",
45
"file_path": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
5-
"line": 12,
6-
"character": 5,
6+
"line": 0,
7+
"character": 10,
78
"workspace_uri": "server/ql/javascript/examples"
89
}
910
}

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"test": "npm run test:integration",
5555
"test:coverage": "echo 'NOOP client test:coverage'",
5656
"test:integration": "scripts/run-integration-tests.sh --no-install-packs",
57-
"test:integration:default": "ENABLE_MONITORING_TOOLS=false scripts/run-integration-tests.sh",
57+
"test:integration:default": "ENABLE_MONITORING_TOOLS=false scripts/run-integration-tests.sh --no-install-packs",
5858
"test:integration:install-packs": "scripts/run-integration-tests.sh",
5959
"test:integration:monitoring": "ENABLE_MONITORING_TOOLS=true scripts/run-integration-tests.sh",
6060
"tidy": "npm run lint && npm run format"

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ export class IntegrationTestRunner {
148148
codeql_bqrs_decode: 3,
149149
codeql_bqrs_info: 3,
150150
codeql_database_analyze: 3,
151-
codeql_resolve_database: 3
151+
codeql_resolve_database: 3,
152+
153+
// Priority 3.5: LSP diagnostics runs before other LSP tools to warm up
154+
// the language server JVM. Subsequent codeql_lsp_* tools reuse the
155+
// running server and avoid the cold-start penalty.
156+
codeql_lsp_diagnostics: 3.5
152157

153158
// Priority 4: All other tools (default priority)
154159
// These tools don't have specific database dependencies
@@ -896,7 +901,7 @@ export class IntegrationTestRunner {
896901
const staticPath = this.getStaticFilesPath();
897902

898903
if (toolName === "codeql_lsp_diagnostics") {
899-
params.ql_code = "from DataFlow::Configuration cfg select cfg";
904+
params.ql_code = 'from UndefinedType x where x = "test" select x, "semantic error"';
900905
// Skip workspace_uri for now as it's not needed for basic validation
901906
} else if (toolName === "codeql_bqrs_decode") {
902907
// Use static BQRS file

0 commit comments

Comments
 (0)