Implementing control flow collections (#146601)
This pull request aims for improved readability, based on issue #146600. ```dart // before Set<Color> _distinctVisibleColors() { final Set<Color> distinctVisibleColors = <Color>{}; if (top.style != BorderStyle.none) { distinctVisibleColors.add(top.color); } if (right.style != BorderStyle.none) { distinctVisibleColors.add(right.color); } if (bottom.style != BorderStyle.none) { distinctVisibleColors.add(bottom.color); } if (left.style != BorderStyle.none) { distinctVisibleColors.add(left.color); } return distinctVisibleColors; } // after Set<Color> _distinctVisibleColors() { return <Color>{ if (top.style != BorderStyle.none) top.color, if (right.style != BorderStyle.none) right.color, if (bottom.style != BorderStyle.none) bottom.color, if (left.style != BorderStyle.none) left.color, }; } ``` Most of the repo should be covered in this PR (aside from `flutter_tools/`, since there was a lot going on in there).
This commit is contained in:
@@ -139,28 +139,21 @@ Future<void> verifyExist(
|
||||
String flutterRoot,
|
||||
{@visibleForTesting ProcessManager processManager = const LocalProcessManager()
|
||||
}) async {
|
||||
final Set<String> foundFiles = <String>{};
|
||||
final String cacheDirectory = path.join(flutterRoot, 'bin', 'cache');
|
||||
|
||||
for (final String binaryPath
|
||||
in await findBinaryPaths(cacheDirectory, processManager: processManager)) {
|
||||
if (binariesWithEntitlements(flutterRoot).contains(binaryPath)) {
|
||||
foundFiles.add(binaryPath);
|
||||
} else if (binariesWithoutEntitlements(flutterRoot).contains(binaryPath)) {
|
||||
foundFiles.add(binaryPath);
|
||||
} else {
|
||||
throw Exception(
|
||||
'Found unexpected binary in cache: $binaryPath');
|
||||
}
|
||||
}
|
||||
|
||||
final List<String> binaryPaths = await findBinaryPaths(
|
||||
path.join(flutterRoot, 'bin', 'cache'),
|
||||
processManager: processManager,
|
||||
);
|
||||
final List<String> allExpectedFiles = binariesWithEntitlements(flutterRoot) + binariesWithoutEntitlements(flutterRoot);
|
||||
final Set<String> foundFiles = <String>{
|
||||
for (final String binaryPath in binaryPaths)
|
||||
if (allExpectedFiles.contains(binaryPath)) binaryPath
|
||||
else throw Exception('Found unexpected binary in cache: $binaryPath'),
|
||||
};
|
||||
|
||||
if (foundFiles.length < allExpectedFiles.length) {
|
||||
final List<String> unfoundFiles = allExpectedFiles
|
||||
.where(
|
||||
(String file) => !foundFiles.contains(file),
|
||||
)
|
||||
.toList();
|
||||
final List<String> unfoundFiles = <String>[
|
||||
for (final String file in allExpectedFiles) if (!foundFiles.contains(file)) file,
|
||||
];
|
||||
print(
|
||||
'Expected binaries not found in cache:\n\n${unfoundFiles.join('\n')}\n\n'
|
||||
'If this commit is removing binaries from the cache, this test should be fixed by\n'
|
||||
|
||||
@@ -913,18 +913,14 @@ Future<void> _runFrameworkTests() async {
|
||||
final Uint8List libappBytes = libapp.content as Uint8List; // bytes decompressed here
|
||||
final String libappStrings = utf8.decode(libappBytes, allowMalformed: true);
|
||||
await runCommand(flutter, <String>['clean'], workingDirectory: tracingDirectory);
|
||||
final List<String> results = <String>[];
|
||||
for (final String pattern in allowed) {
|
||||
if (!libappStrings.contains(pattern)) {
|
||||
results.add('When building with --$modeArgument, expected to find "$pattern" in libapp.so but could not find it.');
|
||||
}
|
||||
}
|
||||
for (final String pattern in disallowed) {
|
||||
if (libappStrings.contains(pattern)) {
|
||||
results.add('When building with --$modeArgument, expected to not find "$pattern" in libapp.so but did find it.');
|
||||
}
|
||||
}
|
||||
return results;
|
||||
return <String>[
|
||||
for (final String pattern in allowed)
|
||||
if (!libappStrings.contains(pattern))
|
||||
'When building with --$modeArgument, expected to find "$pattern" in libapp.so but could not find it.',
|
||||
for (final String pattern in disallowed)
|
||||
if (libappStrings.contains(pattern))
|
||||
'When building with --$modeArgument, expected to not find "$pattern" in libapp.so but did find it.',
|
||||
];
|
||||
} catch (error, stackTrace) {
|
||||
return <String>[
|
||||
error.toString(),
|
||||
@@ -1332,11 +1328,9 @@ Future<void> _runDartTest(String workingDirectory, {
|
||||
|
||||
if (collectMetrics) {
|
||||
try {
|
||||
final List<String> testList = <String>[];
|
||||
final Map<int, TestSpecs> allTestSpecs = test.allTestSpecs;
|
||||
for (final TestSpecs testSpecs in allTestSpecs.values) {
|
||||
testList.add(testSpecs.toJson());
|
||||
}
|
||||
final List<String> testList = <String>[
|
||||
for (final TestSpecs testSpecs in test.allTestSpecs.values) testSpecs.toJson(),
|
||||
];
|
||||
if (testList.isNotEmpty) {
|
||||
final String testJson = json.encode(testList);
|
||||
final File testResults = fileSystem.file(
|
||||
|
||||
Reference in New Issue
Block a user