From c5d046c00c84335fe835bdea8063bf7583ccebb5 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 23 May 2022 18:43:05 -0700 Subject: [PATCH] continue->next in Ruby script (#104296) --- packages/flutter_tools/bin/podhelper.rb | 2 +- .../ios_content_validation_test.dart | 61 ++++++++++++++----- .../macos_content_validation_test.dart | 2 - packages/flutter_tools/test/src/common.dart | 8 +-- 4 files changed, 50 insertions(+), 23 deletions(-) diff --git a/packages/flutter_tools/bin/podhelper.rb b/packages/flutter_tools/bin/podhelper.rb index 639e32b8bdf24..b76fc953c78e4 100644 --- a/packages/flutter_tools/bin/podhelper.rb +++ b/packages/flutter_tools/bin/podhelper.rb @@ -60,7 +60,7 @@ def flutter_additional_ios_build_settings(target) # Profile can't be derived from the CocoaPods build configuration. Use release framework (for linking only). configuration_engine_dir = build_configuration.type == :debug ? debug_framework_dir : release_framework_dir Dir.new(configuration_engine_dir).each_child do |xcframework_file| - continue if xcframework_file.start_with?(".") # Hidden file, possibly on external disk. + next if xcframework_file.start_with?(".") # Hidden file, possibly on external disk. if xcframework_file.end_with?("-simulator") # ios-arm64_x86_64-simulator build_configuration.build_settings['FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]'] = "\"#{configuration_engine_dir}/#{xcframework_file}\" $(inherited)" elsif xcframework_file.start_with?("ios-") # ios-arm64 diff --git a/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart b/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart index 3055592b4b1b6..de08721d7d453 100644 --- a/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart +++ b/packages/flutter_tools/test/host_cross_arch.shard/ios_content_validation_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; @@ -15,11 +13,12 @@ import '../src/darwin_common.dart'; void main() { group('iOS app validation', () { - String flutterRoot; - Directory pluginRoot; - String projectRoot; - String flutterBin; - Directory tempDir; + late String flutterRoot; + late Directory pluginRoot; + late String projectRoot; + late String flutterBin; + late Directory tempDir; + late File hiddenFile; setUpAll(() { flutterRoot = getFlutterRoot(); @@ -30,6 +29,29 @@ void main() { 'flutter', ); + final Directory xcframeworkArtifact = fileSystem.directory( + fileSystem.path.join( + flutterRoot, + 'bin', + 'cache', + 'artifacts', + 'engine', + 'ios', + 'Flutter.xcframework', + ), + ); + + // Pre-cache iOS engine Flutter.xcframework artifacts. + processManager.runSync([ + flutterBin, + ...getLocalEngineArguments(), + 'precache', + '--ios', + ], workingDirectory: tempDir.path); + + // Pretend the SDK was on an external drive with stray "._" files in the xcframework + hiddenFile = xcframeworkArtifact.childFile('._Info.plist')..createSync(); + // Test a plugin example app to allow plugins validation. processManager.runSync([ flutterBin, @@ -47,22 +69,24 @@ void main() { }); tearDownAll(() { + tryToDelete(hiddenFile); tryToDelete(tempDir); }); for (final BuildMode buildMode in [BuildMode.debug, BuildMode.release]) { group('build in ${buildMode.name} mode', () { - Directory buildPath; - Directory outputApp; - Directory frameworkDirectory; - Directory outputFlutterFramework; - File outputFlutterFrameworkBinary; - Directory outputAppFramework; - File outputAppFrameworkBinary; - File outputPluginFrameworkBinary; + late Directory buildPath; + late Directory outputApp; + late Directory frameworkDirectory; + late Directory outputFlutterFramework; + late File outputFlutterFrameworkBinary; + late Directory outputAppFramework; + late File outputAppFrameworkBinary; + late File outputPluginFrameworkBinary; + late ProcessResult buildResult; setUpAll(() { - processManager.runSync([ + buildResult = processManager.runSync([ flutterBin, ...getLocalEngineArguments(), 'build', @@ -94,6 +118,11 @@ void main() { }); testWithoutContext('flutter build ios builds a valid app', () { + printOnFailure('Output of flutter build ios:'); + printOnFailure(buildResult.stdout.toString()); + printOnFailure(buildResult.stderr.toString()); + expect(buildResult.exitCode, 0); + expect(outputPluginFrameworkBinary, exists); expect(outputAppFrameworkBinary, exists); diff --git a/packages/flutter_tools/test/host_cross_arch.shard/macos_content_validation_test.dart b/packages/flutter_tools/test/host_cross_arch.shard/macos_content_validation_test.dart index 5b48e2214ff67..19f21e4965249 100644 --- a/packages/flutter_tools/test/host_cross_arch.shard/macos_content_validation_test.dart +++ b/packages/flutter_tools/test/host_cross_arch.shard/macos_content_validation_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:file_testing/file_testing.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart index 62b3e4b675f50..6be11e1e60e79 100644 --- a/packages/flutter_tools/test/src/common.dart +++ b/packages/flutter_tools/test/src/common.dart @@ -18,19 +18,19 @@ import 'package:test_api/test_api.dart' hide test; // ignore: deprecated_member_ export 'package:test_api/test_api.dart' hide test, isInstanceOf; // ignore: deprecated_member_use -void tryToDelete(Directory directory) { +void tryToDelete(FileSystemEntity fileEntity) { // This should not be necessary, but it turns out that // on Windows it's common for deletions to fail due to // bogus (we think) "access denied" errors. try { - if (directory.existsSync()) { - directory.deleteSync(recursive: true); + if (fileEntity.existsSync()) { + fileEntity.deleteSync(recursive: true); } } on FileSystemException catch (error) { // We print this so that it's visible in the logs, to get an idea of how // common this problem is, and if any patterns are ever noticed by anyone. // ignore: avoid_print - print('Failed to delete ${directory.path}: $error'); + print('Failed to delete ${fileEntity.path}: $error'); } }