Skip to content

Commit cad9f43

Browse files
authored
[tool_tests] Remove bringup from Windows tool_tests_commands_2_2 (flutter#191732)
Fixes Windows-specific path and test failures in `tool_tests_commands` subshard `2_2`: - Use `Glob(entry).matches(relativePath)` with POSIX relative paths in `project.dart`. - Normalize backslashes to POSIX forward slashes in `SwiftPackagePackageDependency.format()` in `swift_packages.dart`. - Normalize path separators when encoding `workspacePackages` dependencies in `preview_pubspec_builder.dart`. - Consolidate `Cache.disableLocking()` in `upgrade_test.dart` `setUpAll()` and pass missing `runInContext` overrides. - Guard NDK directory listing with `ndkDir.existsSync()` in `build_aar_test.dart`. - Update test expectations and add retry backoff in `widget_preview_test.dart`, `test_test.dart`, and `regress_176018_test.dart`. - Remove `bringup: true` from `Windows tool_tests_commands_2_2` in `.ci.yaml`.
1 parent 4e3a2e9 commit cad9f43

9 files changed

Lines changed: 66 additions & 47 deletions

File tree

‎.ci.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7158,7 +7158,6 @@ targets:
71587158
- name: Windows tool_tests_commands_2_2
71597159
recipe: flutter/flutter_drone
71607160
timeout: 60
7161-
bringup: true
71627161
properties:
71637162
add_recipes_cq: "true"
71647163
dependencies: >-

‎packages/flutter_tools/lib/src/macos/swift_packages.dart‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ class SwiftPackagePackageDependency {
331331
// dependencies: [
332332
// .package(name: "image_picker_ios", path: "/path/to/packages/image_picker/image_picker_ios/ios/image_picker_ios"),
333333
// ],
334-
return '.package(name: "$name", path: "$path")';
334+
final String posixPath = path.replaceAll(r'\', '/');
335+
return '.package(name: "$name", path: "$posixPath")';
335336
}
336337
}
337338

‎packages/flutter_tools/lib/src/project.dart‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,18 @@ class FlutterProject {
203203

204204
// Update the workspace projects based on the new manifest.
205205
_workspaceProjects = <FlutterProject>[];
206+
if (!directory.existsSync()) {
207+
return;
208+
}
206209
for (final String entry in manifest.workspace) {
207-
final glob = Glob(entry, context: directory.fileSystem.path);
208-
for (final Directory globResult
209-
in glob
210-
.listFileSystemSync(directory.fileSystem, root: directory.path)
211-
.whereType<Directory>()) {
212-
if (globResult.childFile('pubspec.yaml').existsSync()) {
210+
final glob = Glob(entry);
211+
for (final Directory entity in directory.listSync(recursive: true).whereType<Directory>()) {
212+
final String relativePath = directory.fileSystem.path
213+
.relative(entity.path, from: directory.path)
214+
.replaceAll(r'\', '/');
215+
if (glob.matches(relativePath) && entity.childFile('pubspec.yaml').existsSync()) {
213216
try {
214-
_workspaceProjects.add(FlutterProject.fromDirectory(globResult));
217+
_workspaceProjects.add(FlutterProject.fromDirectory(entity));
215218
} on Exception catch (_) {
216219
// Ignore child projects with invalid manifests.
217220
}

‎packages/flutter_tools/lib/src/widget_preview/preview_pubspec_builder.dart‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ class PreviewPubspecBuilder {
127127
if (project.manifest.appName.isNotEmpty)
128128
// Use `json.encode` to handle escapes correctly.
129129
project.manifest.appName: json.encode(<String, Object?>{
130-
'path': widgetPreviewScaffoldProject.directory.fileSystem.path.absolute(
131-
project.directory.path,
132-
),
130+
'path': widgetPreviewScaffoldProject.directory.fileSystem.path
131+
.absolute(project.directory.path)
132+
.replaceAll(r'\', '/'),
133133
}),
134134
};
135135

‎packages/flutter_tools/test/commands.shard/hermetic/test_test.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ resolution: workspace
716716
final Map<String, dynamic> myApp = packages.cast<Map<String, dynamic>>().firstWhere(
717717
(Map<String, dynamic> p) => p['name'] == 'my_app',
718718
);
719-
expect(myApp['rootUri'], fs.directory('/package').absolute.uri.toString());
719+
expect(myApp['rootUri'], fs.currentDirectory.uri.toString());
720720
},
721721
);
722722
expect(caughtToolExit, true);

‎packages/flutter_tools/test/commands.shard/hermetic/widget_preview/regress_176018_test.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ dependencies:
9393
loadYaml(rootProject.widgetPreviewScaffoldProject.pubspecFile.readAsStringSync())
9494
as YamlMap;
9595
final expectedDependencies = <String, Object?>{
96-
'abcd': {'path': packageProject.projectRoot.path},
97-
'example': {'path': exampleProject.projectRoot.path},
96+
'abcd': {'path': packageProject.projectRoot.path.replaceAll(r'\', '/')},
97+
'example': {'path': exampleProject.projectRoot.path.replaceAll(r'\', '/')},
9898
};
9999

100100
// The generated pubspec.yaml should have path dependencies on both the package and example

‎packages/flutter_tools/test/commands.shard/permeable/build_aar_test.dart‎

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,7 @@ void main() {
224224
expect(buildInfo.flavor, isNull);
225225
expect(buildInfo.splitDebugInfoPath, isNull);
226226
expect(buildInfo.dartObfuscation, isFalse);
227-
expect(androidBuildInfo.targetArchs, <CpuArch>[
228-
CpuArch.armv7,
229-
CpuArch.arm64,
230-
CpuArch.x64,
231-
]);
227+
expect(androidBuildInfo.targetArchs, <CpuArch>[CpuArch.armv7, CpuArch.arm64, CpuArch.x64]);
232228
}
233229
expect(buildModes, hasLength(3));
234230
expect(
@@ -395,22 +391,23 @@ void main() {
395391
tempDir,
396392
arguments: <String>['--no-pub', '--template=module'],
397393
);
398-
final AndroidSdk androidSdk = globals.androidSdk!;
399-
final List<String> installedNdkVersions =
400-
androidSdk.directory
401-
.childDirectory('ndk')
402-
.listSync()
403-
.whereType<Directory>()
404-
.map((Directory dir) => dir.basename)
405-
.where(
406-
(String version) => androidSdk.directory
407-
.childDirectory('ndk')
408-
.childDirectory(version)
409-
.childFile('source.properties')
410-
.existsSync(),
411-
)
412-
.toList()
413-
..sort();
394+
final AndroidSdk? androidSdk = globals.androidSdk;
395+
if (androidSdk == null) {
396+
return;
397+
}
398+
final Directory ndkDir = androidSdk.directory.childDirectory('ndk');
399+
final List<String> installedNdkVersions = ndkDir.existsSync()
400+
? ndkDir
401+
.listSync()
402+
.whereType<Directory>()
403+
.map((Directory dir) => dir.basename)
404+
.where(
405+
(String version) =>
406+
ndkDir.childDirectory(version).childFile('source.properties').existsSync(),
407+
)
408+
.toList()
409+
: <String>[];
410+
installedNdkVersions.sort();
414411
final ndkProvisioningProperties = <String>[
415412
'-Pflutter.androidSdkRoot=${androidSdk.directory.path}',
416413
'-Pflutter.installedNdkVersions=${installedNdkVersions.join(',')}',

‎packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import '../../src/test_flutter_command_runner.dart';
2525

2626
void main() {
2727
setUpAll(() {
28+
Cache.disableLocking();
2829
Cache.flutterRoot = getFlutterRoot();
2930
});
30-
3131
group('UpgradeCommandRunner', () {
3232
final jan12026 = DateTime.utc(2026);
3333

@@ -655,13 +655,20 @@ void main() {
655655
},
656656
);
657657

658-
await runInContext(() async {
659-
await runner.run(<String>['upgrade', '--continue']);
660-
// Verify that ensureVersionFile() was invoked, which will create flutter.version.json
661-
// if it doesn't exist.
662-
expect(latestVersion.didEnsureVersionFile, true);
663-
expect(latestVersion.didDeleteVersionFile, false);
664-
}, overrides: {FlutterVersion: () => latestVersion});
658+
await runInContext(
659+
() async {
660+
await runner.run(<String>['upgrade', '--continue']);
661+
// Verify that ensureVersionFile() was invoked, which will create flutter.version.json
662+
// if it doesn't exist.
663+
expect(latestVersion.didEnsureVersionFile, true);
664+
expect(latestVersion.didDeleteVersionFile, false);
665+
},
666+
overrides: <Type, Generator>{
667+
FlutterVersion: () => latestVersion,
668+
ProcessManager: () => FakeProcessManager.any(),
669+
Platform: () => fakePlatform,
670+
},
671+
);
665672
},
666673
overrides: <Type, Generator>{
667674
ProcessManager: () => FakeProcessManager.any(),
@@ -831,7 +838,6 @@ void main() {
831838
late FileSystem fs;
832839

833840
setUp(() {
834-
Cache.disableLocking();
835841
fakeProcessManager = FakeProcessManager.list(<FakeCommand>[
836842
const FakeCommand(command: <String>['git', 'tag', '--points-at', 'HEAD']),
837843
const FakeCommand(
@@ -845,7 +851,6 @@ void main() {
845851
});
846852

847853
tearDown(() {
848-
Cache.enableLocking();
849854
tryToDelete(tempDir);
850855
});
851856

‎packages/flutter_tools/test/commands.shard/permeable/widget_preview/widget_preview_test.dart‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,21 @@ void main() {
283283
}
284284

285285
Future<void> cleanWidgetPreview({required Directory rootProject}) async {
286-
await runWidgetPreviewCommand(<String>['clean', rootProject.path]);
286+
var retries = 5;
287+
var delay = const Duration(milliseconds: 100);
288+
while (true) {
289+
try {
290+
await runWidgetPreviewCommand(<String>['clean', rootProject.path]);
291+
break;
292+
} on Exception catch (_) {
293+
retries--;
294+
if (retries <= 0) {
295+
rethrow;
296+
}
297+
await Future<void>.delayed(delay);
298+
delay *= 2;
299+
}
300+
}
287301
expect(fs.directory(rootProject).childDirectory('.widget_preview'), isNot(exists));
288302
}
289303

0 commit comments

Comments
 (0)