Skip to content

Commit f4e7c3c

Browse files
DanTupCommit Queue
authored andcommitted
[analysis_server] Clean up some temp files after test runs
+ tweak the names of all temp folders created by tests to be more consistent, and more specific so it's easier to tell which are not being cleaned up. Change-Id: Iabc58576ed7070ebca00a22c7ebb5909b98aa500 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433821 Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent 476f915 commit f4e7c3c

File tree

7 files changed

+43
-14
lines changed

7 files changed

+43
-14
lines changed

pkg/analysis_server/integration_test/lsp_server/integration_tests.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ abstract class AbstractLspAnalysisServerIntegrationTest
4444
/// be applied in the same way a real client would apply them.
4545
final _overlayContent = <Uri, String>{};
4646

47+
/// Temporary folders created by the test that should be deleted (recursively)
48+
/// during [tearDown].
49+
final List<String> _temporaryFolders = [];
50+
4751
LspByteStreamServerChannel get channel => client!.channel!;
4852

4953
@override
@@ -137,8 +141,9 @@ abstract class AbstractLspAnalysisServerIntegrationTest
137141
// Set up temporary folder for the test.
138142
projectFolderPath =
139143
Directory.systemTemp
140-
.createTempSync('analysisServer')
144+
.createTempSync('analysisServer_test_integration_lspProject')
141145
.resolveSymbolicLinksSync();
146+
_temporaryFolders.add(projectFolderPath);
142147
newFolder(projectFolderPath);
143148
newFolder(path.join(projectFolderPath, 'lib'));
144149
mainFilePath = path.join(projectFolderPath, 'lib', 'main.dart');
@@ -168,6 +173,9 @@ abstract class AbstractLspAnalysisServerIntegrationTest
168173
void tearDown() {
169174
// TODO(dantup): Graceful shutdown?
170175
client?.close();
176+
for (var temporaryFolder in _temporaryFolders) {
177+
Directory(temporaryFolder).deleteSync(recursive: true);
178+
}
171179
}
172180
}
173181

pkg/analysis_server/integration_test/server/blaze_changes_test.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class BlazeChangesTest extends AbstractAnalysisServerIntegrationTest {
4141
late String blazeGenfilesPath;
4242
late Directory oldSourceDirectory;
4343

44+
/// Temporary folders created by the test that should be deleted (recursively)
45+
/// during [tearDown].
46+
final List<String> _temporaryFolders = [];
47+
4448
String inTmpDir(String relative) =>
4549
path.join(tmpPath, relative.replaceAll('/', path.separator));
4650

@@ -55,9 +59,10 @@ class BlazeChangesTest extends AbstractAnalysisServerIntegrationTest {
5559
tmpPath =
5660
Directory(
5761
Directory.systemTemp
58-
.createTempSync('analysisServer')
62+
.createTempSync('analysisServer_test_integration_blazeProject')
5963
.resolveSymbolicLinksSync(),
6064
).path;
65+
_temporaryFolders.add(tmpPath);
6166
workspacePath = inTmpDir('workspace_root');
6267
writeFile(inWorkspace(file_paths.blazeWorkspaceMarker), '');
6368

@@ -81,7 +86,9 @@ class BlazeChangesTest extends AbstractAnalysisServerIntegrationTest {
8186

8287
@override
8388
Future<void> tearDown() async {
84-
Directory(tmpPath).deleteSync(recursive: true);
89+
for (var temporaryFolder in _temporaryFolders) {
90+
Directory(temporaryFolder).deleteSync(recursive: true);
91+
}
8592
sourceDirectory = oldSourceDirectory;
8693
await super.tearDown();
8794
}

pkg/analysis_server/integration_test/support/integration_tests.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ abstract class AbstractAnalysisServerIntegrationTest extends IntegrationTest
116116
@override
117117
final Server server = Server();
118118

119+
/// Temporary folders created by the test that should be deleted (recursively)
120+
/// during [tearDown].
121+
final List<String> _temporaryFolders = [];
122+
119123
/// Temporary directory in which source files can be stored.
120124
late Directory sourceDirectory;
121125

@@ -223,10 +227,13 @@ abstract class AbstractAnalysisServerIntegrationTest extends IntegrationTest
223227
/// [sourceDirectory] is created.
224228
Future<void> setUp() async {
225229
var pathContext = resourceProvider.pathContext;
226-
var tempDirectoryPath =
227-
Directory.systemTemp
228-
.createTempSync('analysisServer')
229-
.resolveSymbolicLinksSync();
230+
var testTemporaryDirectory = Directory(
231+
Directory.systemTemp
232+
.createTempSync('analysisServer_test_integration_project')
233+
.resolveSymbolicLinksSync(),
234+
);
235+
var tempDirectoryPath = testTemporaryDirectory.path;
236+
_temporaryFolders.add(tempDirectoryPath);
230237
sourceDirectory = Directory(pathContext.join(tempDirectoryPath, 'app'))
231238
..createSync();
232239
packagesDirectory = Directory(
@@ -323,8 +330,9 @@ abstract class AbstractAnalysisServerIntegrationTest extends IntegrationTest
323330
@mustCallSuper
324331
Future<void> tearDown() {
325332
return shutdownIfNeeded().then((_) {
326-
sourceDirectory.deleteSync(recursive: true);
327-
packagesDirectory.deleteSync(recursive: true);
333+
for (var temporaryFolder in _temporaryFolders) {
334+
deleteFolder(temporaryFolder);
335+
}
328336
});
329337
}
330338

pkg/analysis_server/test/src/server/sdk_configuration_test.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ void main() {
1313
Directory? tempDir;
1414

1515
Directory createTempDir() {
16-
return tempDir = Directory.systemTemp.createTempSync('SdkConfiguration');
16+
return tempDir = Directory.systemTemp.createTempSync(
17+
'analysisServer_test_sdkConfiguration',
18+
);
1719
}
1820

1921
tearDown(() {

pkg/analysis_server/test/support/sdk_paths.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Future<String> getAnalysisServerPath(String dartSdkPath) async {
5353
// This is a simple way to run from source using the test_all file that
5454
// runs all tests in a single isolate and will trigger a single
5555
// compilation for all integration tests.
56-
// - An path to a pre-compiled snapshot.
56+
// - A path to a pre-compiled snapshot.
5757
// This allows configuring VS Code to pre-compile the snapshot once and
5858
// then use 'dart test' which will run each sweet in a separate isolate
5959
// without each test/isolate having to compile.
@@ -85,7 +85,7 @@ Future<String> _compileTemporaryServerSnapshot() async {
8585

8686
var dartBinary = Platform.resolvedExecutable;
8787
var tempSnapshotDirectory = Directory.systemTemp.createTempSync(
88-
'dart_analysis_server_tests',
88+
'analysisServer_test_integration_compiledServer',
8989
);
9090
var tempSnapshotFilePath = path.join(
9191
tempSnapshotDirectory.path,

pkg/analysis_server/test/timing/timing_framework.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ abstract class TimingTest extends IntegrationTest {
137137
/// iterations.
138138
Future<void> oneTimeSetUp() {
139139
server = Server();
140-
sourceDirectory = Directory.systemTemp.createTempSync('analysisServer');
140+
sourceDirectory = Directory.systemTemp.createTempSync(
141+
'analysisServer_test_timing',
142+
);
141143
var serverConnected = Completer<void>();
142144
onServerConnected.listen((_) {
143145
serverConnected.complete();

pkg/analysis_server/tool/benchmark_tools/run_utils.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ Future<void> runHelper<E, F, G>(
6868
caption = 'size $size';
6969
}
7070
try {
71-
Directory tmpDir = Directory.systemTemp.createTempSync('lsp_benchmark');
71+
Directory tmpDir = Directory.systemTemp.createTempSync(
72+
'analysisServer_benchmark',
73+
);
7274
try {
7375
Directory cacheDir = Directory.fromUri(tmpDir.uri.resolve('cache/'))
7476
..createSync(recursive: true);

0 commit comments

Comments
 (0)