Skip to content

Commit 5d2d5cb

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Pre-compile server for integration tests
By default the integration tests spawn the server using the snapshot from the active SDK. If you forget to recompile the SDK when running the integration tests, you may get inaccurate results. One option is to set the `TEST_SERVER_SNAPSHOT` env variable to `"false"` which will run the tests from source, however using the "Run All Tests" command in VS Code will result in a lot of timeouts because tests run concurrently and each one will cause a compilation. This change instead creates a new VS Code task that will compile the server to a temporary file in `.dart_tool`, and creates a launch configuration that triggers this task (via `preLaunchTask`) when running integration tests. This supports both running all tests (with the "Run All Tests" command) or running individual integration test files, with just a single up-front compilation. Change-Id: I0970ffb76240abd54ff2c8a9c9be4bab40693691 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436341 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Keerti Parthasarathy <[email protected]> Reviewed-by: Keerti Parthasarathy <[email protected]>
1 parent 5e562b2 commit 5d2d5cb

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

pkg/analysis_server/.vscode/launch.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@
1212
"request": "launch",
1313
"type": "dart",
1414
"program": "test/test_all.dart",
15+
},
16+
{
17+
"name": "Dart - Integration Tests",
18+
"type": "dart",
19+
"request": "launch",
20+
// By specifying "templateFor", this config acts as a template when launching things inside the "integration_test" folder
21+
// from the CodeLens links and from the VS Code test runner.
22+
"templateFor": "integration_test",
23+
// Run the task to pre-compile the analysis server into the .dart_tool folder.
24+
"preLaunchTask": "dart: compile analysis server",
25+
// Pass the path of that snapshot in the `TEST_SERVER_SNAPSHOT` env variable so
26+
// that the integration tests will use this instead of the one in the current
27+
// SDK.
28+
"env": {
29+
"TEST_SERVER_SNAPSHOT": ".dart_tool/integration_tests_analysis_server.dart.snapshot"
30+
},
1531
}
1632
]
17-
}
33+
}

pkg/analysis_server/.vscode/tasks.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@
66
"type": "shell",
77
"command": "tool/spec/generate_files",
88
"problemMatcher": []
9+
},
10+
{
11+
// This task compiles the analysis server to a kernel snapshot
12+
// in the .dart_tool folder. It is used as a "preLaunchTask" for
13+
// the "Dart - Integration Tests" template which is invoked when
14+
// executing integration tests.
15+
"type": "dart",
16+
"command": "dart",
17+
"args": [
18+
"compile",
19+
"kernel",
20+
"bin/server.dart",
21+
"-o",
22+
".dart_tool/integration_tests_analysis_server.dart.snapshot"
23+
],
24+
"problemMatcher": [],
25+
"label": "dart: compile analysis server",
26+
"detail": "Compiles the analysis server into .dart_tool for use by integration tests"
927
}
1028
]
11-
}
29+
}

0 commit comments

Comments
 (0)