|
| 1 | +// Copyright 2014 The Flutter Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style license that can be |
| 3 | +// found in the LICENSE file. |
| 4 | + |
| 5 | +import 'package:file_testing/file_testing.dart'; |
| 6 | +import 'package:flutter_tools/src/base/file_system.dart'; |
| 7 | +import 'package:flutter_tools/src/base/io.dart'; |
| 8 | + |
| 9 | +import '../src/common.dart'; |
| 10 | +import 'test_utils.dart'; |
| 11 | + |
| 12 | +void main() { |
| 13 | + test('flutter build macOS --config only updates generated xcconfig file without performing build', () async { |
| 14 | + final String workingDirectory = fileSystem.path.join( |
| 15 | + getFlutterRoot(), |
| 16 | + 'dev', |
| 17 | + 'integration_tests', |
| 18 | + 'flutter_gallery', |
| 19 | + ); |
| 20 | + final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); |
| 21 | + |
| 22 | + await processManager.run(<String>[ |
| 23 | + flutterBin, |
| 24 | + ...getLocalEngineArguments(), |
| 25 | + 'clean', |
| 26 | + ], workingDirectory: workingDirectory); |
| 27 | + final List<String> buildCommand = <String>[ |
| 28 | + flutterBin, |
| 29 | + ...getLocalEngineArguments(), |
| 30 | + 'build', |
| 31 | + 'macos', |
| 32 | + '--config-only', |
| 33 | + '--release', |
| 34 | + '--obfuscate', |
| 35 | + '--split-debug-info=info', |
| 36 | + ]; |
| 37 | + final ProcessResult firstRunResult = await processManager.run(buildCommand, workingDirectory: workingDirectory); |
| 38 | + |
| 39 | + printOnFailure('Output of flutter build macOS:'); |
| 40 | + final String firstRunStdout = firstRunResult.stdout.toString(); |
| 41 | + printOnFailure('First run stdout: $firstRunStdout'); |
| 42 | + printOnFailure('First run stderr: ${firstRunResult.stderr}'); |
| 43 | + |
| 44 | + expect(firstRunResult.exitCode, 0); |
| 45 | + expect(firstRunStdout, contains('Running pod install')); |
| 46 | + |
| 47 | + final File generatedConfig = fileSystem.file(fileSystem.path.join( |
| 48 | + workingDirectory, |
| 49 | + 'macos', |
| 50 | + 'Flutter', |
| 51 | + 'ephemeral', |
| 52 | + 'Flutter-Generated.xcconfig', |
| 53 | + )); |
| 54 | + |
| 55 | + // Config is updated if command succeeded. |
| 56 | + expect(generatedConfig, exists); |
| 57 | + expect(generatedConfig.readAsStringSync(), contains('DART_OBFUSCATION=true')); |
| 58 | + |
| 59 | + // file that only exists if app was fully built. |
| 60 | + final File frameworkPlist = fileSystem.file(fileSystem.path.join( |
| 61 | + workingDirectory, |
| 62 | + 'build', |
| 63 | + 'macos', |
| 64 | + 'Build', |
| 65 | + 'Products', |
| 66 | + 'Release', |
| 67 | + 'App.framework', |
| 68 | + 'Resources', |
| 69 | + 'Info.plist' |
| 70 | + )); |
| 71 | + |
| 72 | + expect(frameworkPlist, isNot(exists)); |
| 73 | + |
| 74 | + // Run again with no changes. |
| 75 | + final ProcessResult secondRunResult = await processManager.run(buildCommand, workingDirectory: workingDirectory); |
| 76 | + final String secondRunStdout = secondRunResult.stdout.toString(); |
| 77 | + printOnFailure('Second run stdout: $secondRunStdout'); |
| 78 | + printOnFailure('Second run stderr: ${secondRunResult.stderr}'); |
| 79 | + |
| 80 | + expect(secondRunResult.exitCode, 0); |
| 81 | + }, skip: !platform.isMacOS); // [intended] macOS builds only work on macos. |
| 82 | +} |
0 commit comments