Skip to content

Commit 81b0326

Browse files
jensjohaCommit Queue
authored andcommitted
[CFE] Update flutter_gallery_leak_tester after flutter started using workspaces
The weekly bot failed because flutter started using workspaces. This fixes the issue (by using the code where it is instead of copying it) and removes some no-longer-needed hack for shoterning the file paths. Change-Id: Ib10f0703566d89f53291f4ce543bfe4c342b7050 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433680 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
1 parent 4d1955e commit 81b0326

File tree

1 file changed

+9
-64
lines changed

1 file changed

+9
-64
lines changed

pkg/front_end/test/flutter_gallery_leak_tester.dart

Lines changed: 9 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,13 @@ Future<void> main(List<String> args) async {
5959
throw "File not found: $frontendServerStarter";
6060
}
6161

62-
Directory gallery = new Directory("$rootPath/gallery");
63-
if (!gallery.existsSync()) {
64-
print("Gallery not found... Copying from flutter dir.");
65-
66-
Directory galleryFlutterDev =
67-
new Directory("$rootPath/flutter/dev/integration_tests/new_gallery");
68-
69-
// Copy it.
70-
Process process = await Process.start(
71-
"cp", ["-r", galleryFlutterDev.path, "$rootPath/gallery"]);
72-
int processExitCode = await process.exitCode;
73-
print("Exit code from cp: $processExitCode");
62+
File packageConfig =
63+
new File("$rootPath/flutter/.dart_tool/package_config.json");
7464

75-
process = await Process.start("../flutter/bin/flutter", ["pub", "get"],
76-
workingDirectory: "$rootPath/gallery/");
65+
if (!packageConfig.existsSync()) {
66+
// If the package_config doesn't exist we should run pub get.
67+
Process process = await Process.start("bin/flutter", ["pub", "get"],
68+
workingDirectory: "$rootPath/flutter/");
7769
process.stdout
7870
.transform(utf8.decoder)
7971
.transform(new LineSplitter())
@@ -86,59 +78,12 @@ Future<void> main(List<String> args) async {
8678
.listen((line) {
8779
print("flutter stderr> $line");
8880
});
89-
processExitCode = await process.exitCode;
81+
int processExitCode = await process.exitCode;
9082
print("Exit code from flutter: $processExitCode");
91-
92-
// Attempt to hack around strings being truncated to 128 bytes in heap dumps
93-
// https://github.com/dart-lang/sdk/blob/c59cdee365b94ce066344840f9e3412d642019b5/runtime/vm/object_graph.cc#L809
94-
// (pub paths can become too long, so two distinct files will look to have
95-
// the same url and thus give a false positive).
96-
Uri pubDirUri = Uri.parse("file://${Platform.environment['HOME']}/"
97-
".pub-cache/hosted/pub.dev/");
98-
Directory pubDir = new Directory.fromUri(pubDirUri);
99-
if (!pubDir.existsSync()) {
100-
File galleryPackageConfig =
101-
new File("$rootPath/gallery/.dart_tool/package_config.json");
102-
String? packagesData;
103-
if (galleryPackageConfig.existsSync()) {
104-
packagesData = galleryPackageConfig.readAsStringSync();
105-
}
106-
107-
throw "Expected to find $pubDir but didn't.\n"
108-
"Content of packages file (${packagesData.runtimeType}): "
109-
"$packagesData";
110-
}
111-
112-
File galleryPackageConfig =
113-
new File("$rootPath/gallery/.dart_tool/package_config.json");
114-
if (!galleryPackageConfig.existsSync()) {
115-
throw "Didn't find $galleryPackageConfig";
116-
}
117-
String data = galleryPackageConfig.readAsStringSync();
118-
data = data.replaceAll(pubDirUri.toString(), "../pub/");
119-
galleryPackageConfig.writeAsStringSync(data);
120-
121-
process = await Process.start("ln", ["-s", pubDir.path, "pub"],
122-
workingDirectory: "$rootPath/gallery/");
123-
process.stdout
124-
.transform(utf8.decoder)
125-
.transform(new LineSplitter())
126-
.listen((line) {
127-
print("ln stdout> $line");
128-
});
129-
process.stderr
130-
.transform(utf8.decoder)
131-
.transform(new LineSplitter())
132-
.listen((line) {
133-
print("ln stderr> $line");
134-
});
135-
processExitCode = await process.exitCode;
136-
print("Exit code from ln: $processExitCode");
13783
}
13884

139-
File packageConfig =
140-
new File("$rootPath/gallery/.dart_tool/package_config.json");
14185
if (!packageConfig.existsSync()) {
86+
// If it still doesn't exist something is wrong.
14287
throw "Didn't find $packageConfig";
14388
}
14489

@@ -179,7 +124,7 @@ Future<void> main(List<String> args) async {
179124
"--output-dill",
180125
"$rootPath/flutter_server_tmp.dill",
181126
"--packages",
182-
"$rootPath/gallery/.dart_tool/package_config.json",
127+
packageConfig.path,
183128
"-Ddart.vm.profile=false",
184129
"-Ddart.vm.product=false",
185130
"--enable-asserts",

0 commit comments

Comments
 (0)