From 2d08fec3686c6d422c19b45b591aa688092bf048 Mon Sep 17 00:00:00 2001 From: xster Date: Mon, 15 Jul 2019 18:31:44 -0700 Subject: [PATCH] Move buildable module test to a module test (#36102) --- dev/devicelab/bin/tasks/module_test_ios.dart | 105 +++++++++++++++++- .../ios_add2app/build_and_test.sh | 8 +- 2 files changed, 102 insertions(+), 11 deletions(-) diff --git a/dev/devicelab/bin/tasks/module_test_ios.dart b/dev/devicelab/bin/tasks/module_test_ios.dart index d24359e3596..a54b555361e 100644 --- a/dev/devicelab/bin/tasks/module_test_ios.dart +++ b/dev/devicelab/bin/tasks/module_test_ios.dart @@ -32,7 +32,7 @@ Future main() async { }); await prepareProvisioningCertificates(projectDir.path); - section('Build ephemeral host app without CocoaPods'); + section('Build ephemeral host app in release mode without CocoaPods'); await inDirectory(projectDir, () async { await flutter( @@ -41,18 +41,96 @@ Future main() async { ); }); - final bool ephemeralHostAppBuilt = exists(Directory(path.join( + final Directory ephemeralReleaseHostApp = Directory(path.join( projectDir.path, 'build', 'ios', 'iphoneos', 'Runner.app', - ))); + )); - if (!ephemeralHostAppBuilt) { + if (!exists(ephemeralReleaseHostApp)) { return TaskResult.failure('Failed to build ephemeral host .app'); } + if (!await _isAppAotBuild(ephemeralReleaseHostApp)) { + return TaskResult.failure( + 'Ephemeral host app ${ephemeralReleaseHostApp.path} was not a release build as expected' + ); + } + + section('Clean build'); + + await inDirectory(projectDir, () async { + await flutter('clean'); + }); + + section('Build ephemeral host app in profile mode without CocoaPods'); + + await inDirectory(projectDir, () async { + await flutter( + 'build', + options: ['ios', '--no-codesign', '--profile'], + ); + }); + + final Directory ephemeralProfileHostApp = Directory(path.join( + projectDir.path, + 'build', + 'ios', + 'iphoneos', + 'Runner.app', + )); + + if (!exists(ephemeralProfileHostApp)) { + return TaskResult.failure('Failed to build ephemeral host .app'); + } + + if (!await _isAppAotBuild(ephemeralProfileHostApp)) { + return TaskResult.failure( + 'Ephemeral host app ${ephemeralProfileHostApp.path} was not a profile build as expected' + ); + } + + section('Clean build'); + + await inDirectory(projectDir, () async { + await flutter('clean'); + }); + + section('Build ephemeral host app in debug mode for simulator without CocoaPods'); + + await inDirectory(projectDir, () async { + await flutter( + 'build', + options: ['ios', '--no-codesign', '--simulator', '--debug'], + ); + }); + + final Directory ephemeralDebugHostApp = Directory(path.join( + projectDir.path, + 'build', + 'ios', + 'iphonesimulator', + 'Runner.app', + )); + + if (!exists(ephemeralDebugHostApp)) { + return TaskResult.failure('Failed to build ephemeral host .app'); + } + + if (!exists(File(path.join( + ephemeralDebugHostApp.path, + 'Frameworks', + 'App.framework', + 'flutter_assets', + 'isolate_snapshot_data', + )))) { + return TaskResult.failure( + 'Ephemeral host app ${ephemeralDebugHostApp.path} was not a debug build as expected' + ); + } + section('Clean build'); await inDirectory(projectDir, () async { @@ -179,3 +257,22 @@ Future main() async { } }); } + +Future _isAppAotBuild(Directory app) async { + final String binary = path.join( + app.path, + 'Frameworks', + 'App.framework', + 'App' + ); + + final String symbolTable = await eval( + 'nm', + [ + '-gU', + binary, + ], + ); + + return symbolTable.contains('kDartIsolateSnapshotInstructions'); +} diff --git a/dev/integration_tests/ios_add2app/build_and_test.sh b/dev/integration_tests/ios_add2app/build_and_test.sh index 0a533de61f0..4c08afdbe79 100755 --- a/dev/integration_tests/ios_add2app/build_and_test.sh +++ b/dev/integration_tests/ios_add2app/build_and_test.sh @@ -5,13 +5,7 @@ set -e cd "$(dirname "$0")" pushd flutterapp -../../../../bin/flutter build ios --debug --no-codesign -v - -pushd .ios -xcodebuild -workspace Runner.xcworkspace -scheme Runner -destination generic/platform=iOS -configuration Debug CODE_SIGNING_REQUIRED=NO CODE_SIGNING_IDENTITY="" CODE_SIGNING_ALLOWED=NO -xcodebuild -workspace Runner.xcworkspace -scheme Runner -destination generic/platform=iOS -configuration Profile CODE_SIGNING_REQUIRED=NO CODE_SIGNING_IDENTITY="" CODE_SIGNING_ALLOWED=NO -xcodebuild -workspace Runner.xcworkspace -scheme Runner -destination generic/platform=iOS -configuration Release CODE_SIGNING_REQUIRED=NO CODE_SIGNING_IDENTITY="" CODE_SIGNING_ALLOWED=NO -popd +../../../../bin/flutter build ios --debug --simulator --no-codesign popd pod install