Reland #128236, reverted in https://github.com/flutter/flutter/pull/143125, https://github.com/flutter/flutter/pull/145261, and https://github.com/flutter/flutter/pull/145487. The errors were raised in post-submit tests on Windows. I have finally obtained a Windows machine to reproduce the errors locally and adjust the test (remove size expectation and rename output `.exe`). ## Original description Improves the build output: 1. Gives confirmation that the build succeeded, in green 1. Gives the path to the built executable, without a trailing period to make it slightly easier to cmd/ctrl+open 1. Gives the size of the built executable (when the built executable is self contained) ### `apk`, `appbundle` <img width="607" alt="image" src="https://github.com/flutter/flutter/assets/6655696/ecc52abe-cd2e-4116-b22a-8385ae3e980d"> <img width="634" alt="image" src="https://github.com/flutter/flutter/assets/6655696/8af8bd33-c0bd-4215-9a06-9652ee019436"> ### `macos`, `ios`, `ipa` Build executables are self-contained and use a newly introduced `OperatingSystemUtils.getDirectorySize`. <img width="514" alt="image" src="https://github.com/flutter/flutter/assets/6655696/b5918a69-3959-4417-9205-4f501d185257"> <img width="581" alt="image" src="https://github.com/flutter/flutter/assets/6655696/d72fd420-18cf-4470-9e4b-b6ac10fbcd50"> <img width="616" alt="image" src="https://github.com/flutter/flutter/assets/6655696/5f235ce1-252a-4c13-898f-139f6c7bc698"> ### `windows`, `linux`, and `web` Build executables aren't self-contained, and folder size can sometimes overestimate distribution size, therefore their size isn't mentioned (see discussion below). <img width="647" alt="image" src="https://github.com/flutter/flutter/assets/6655696/7179e771-1eb7-48f6-b770-975bc073437b"> <img width="658" alt="image" src="https://github.com/flutter/flutter/assets/6655696/a6801cab-7b5a-4975-a406-f4c9fa44d7a2"> <img width="608" alt="image" src="https://github.com/flutter/flutter/assets/6655696/ee7c4125-a273-4a65-95d7-ab441edf8ac5"> ### Size reporting When applicable, the printed size matches the OS reported size. - macOS <img width="391" alt="image" src="https://github.com/flutter/flutter/assets/6655696/881cbfb1-d355-444b-ab44-c1a6343190ce"> - Windows <img width="338" alt="image" src="https://github.com/flutter/flutter/assets/6655696/3b806def-3d15-48a9-8a25-df200d6feef7"> - Linux <img width="320" alt="image" src="https://github.com/flutter/flutter/assets/6655696/89a4aa3d-2148-4f3b-b231-f93a057fee2b"> ## Related issues Part of #120127 Fixes https://github.com/flutter/flutter/issues/121401
This commit is contained in:
@@ -282,6 +282,36 @@ void main() {
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||
});
|
||||
|
||||
|
||||
testUsingContext('ios build outputs path and size when successful', () async {
|
||||
final BuildCommand command = BuildCommand(
|
||||
artifacts: artifacts,
|
||||
androidSdk: FakeAndroidSdk(),
|
||||
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
|
||||
fileSystem: MemoryFileSystem.test(),
|
||||
logger: BufferLogger.test(),
|
||||
processUtils: processUtils,
|
||||
osUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
createMinimalMockProjectFiles();
|
||||
|
||||
await createTestCommandRunner(command).run(
|
||||
const <String>['build', 'ios', '--no-pub']
|
||||
);
|
||||
expect(testLogger.statusText, contains(RegExp(r'✓ Built build/ios/iphoneos/Runner\.app \(\d+\.\d+MB\)')));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
|
||||
xattrCommand,
|
||||
setUpFakeXcodeBuildHandler(onRun: (_) {
|
||||
fileSystem.directory('build/ios/Release-iphoneos/Runner.app').createSync(recursive: true);
|
||||
}),
|
||||
setUpRsyncCommand(),
|
||||
]),
|
||||
Platform: () => macosPlatform,
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
|
||||
});
|
||||
|
||||
testUsingContext('ios build invokes xcode build', () async {
|
||||
final BuildCommand command = BuildCommand(
|
||||
artifacts: artifacts,
|
||||
|
||||
@@ -576,7 +576,7 @@ void main() {
|
||||
|
||||
expect(logger.statusText, contains('build/ios/archive/Runner.xcarchive'));
|
||||
expect(logger.statusText, contains('Building App Store IPA'));
|
||||
expect(logger.statusText, contains('Built IPA to /build/ios/ipa'));
|
||||
expect(logger.statusText, contains(RegExp(r'Built IPA to build/ios/ipa \(\d+\.\d+MB\)')));
|
||||
expect(logger.statusText, contains('To upload to the App Store'));
|
||||
expect(logger.statusText, contains('Apple Transporter macOS app'));
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
@@ -628,7 +628,7 @@ void main() {
|
||||
|
||||
expect(logger.statusText, contains('build/ios/archive/Runner.xcarchive'));
|
||||
expect(logger.statusText, contains('Building ad-hoc IPA'));
|
||||
expect(logger.statusText, contains('Built IPA to /build/ios/ipa'));
|
||||
expect(logger.statusText, contains(RegExp(r'Built IPA to build/ios/ipa \(\d+\.\d+MB\)')));
|
||||
// Don'ltruct how to upload to the App Store.
|
||||
expect(logger.statusText, isNot(contains('To upload')));
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
@@ -680,7 +680,7 @@ void main() {
|
||||
|
||||
expect(logger.statusText, contains('build/ios/archive/Runner.xcarchive'));
|
||||
expect(logger.statusText, contains('Building enterprise IPA'));
|
||||
expect(logger.statusText, contains('Built IPA to /build/ios/ipa'));
|
||||
expect(logger.statusText, contains(RegExp(r'Built IPA to build/ios/ipa \(\d+\.\d+MB\)')));
|
||||
// Don'ltruct how to upload to the App Store.
|
||||
expect(logger.statusText, isNot(contains('To upload')));
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
@@ -889,7 +889,7 @@ void main() {
|
||||
|
||||
testUsingContext('ipa build invokes xcode build export archive when passed plist', () async {
|
||||
final String outputPath =
|
||||
fileSystem.path.absolute(fileSystem.path.join('build', 'ios', 'ipa'));
|
||||
fileSystem.path.relative(fileSystem.path.join('build', 'ios', 'ipa'));
|
||||
final File exportOptions = fileSystem.file('ExportOptions.plist')
|
||||
..createSync();
|
||||
final BuildCommand command = BuildCommand(
|
||||
@@ -918,7 +918,7 @@ void main() {
|
||||
],
|
||||
);
|
||||
|
||||
expect(logger.statusText, contains('Built IPA to $outputPath.'));
|
||||
expect(logger.statusText, contains(RegExp('Built IPA to $outputPath ' r'\(\d+\.\d+MB\)')));
|
||||
expect(fakeProcessManager, hasNoRemainingExpectations);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
|
||||
@@ -194,6 +194,35 @@ void main() {
|
||||
FeatureFlags: () => TestFeatureFlags(),
|
||||
});
|
||||
|
||||
testUsingContext('Linux build outputs path when successful', () async {
|
||||
final BuildCommand command = BuildCommand(
|
||||
artifacts: artifacts,
|
||||
androidSdk: FakeAndroidSdk(),
|
||||
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
|
||||
fileSystem: MemoryFileSystem.test(),
|
||||
logger: BufferLogger.test(),
|
||||
processUtils: processUtils,
|
||||
osUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
cmakeCommand('release'),
|
||||
ninjaCommand('release'),
|
||||
]);
|
||||
|
||||
setUpMockProjectFilesForBuild();
|
||||
|
||||
await createTestCommandRunner(command).run(
|
||||
const <String>['build', 'linux', '--no-pub']
|
||||
);
|
||||
expect(testLogger.statusText, contains('✓ Built build/linux/x64/release/bundle'));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
Platform: () => linuxPlatform,
|
||||
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
|
||||
OperatingSystemUtils: () => FakeOperatingSystemUtils(),
|
||||
});
|
||||
|
||||
testUsingContext('Linux build invokes CMake and ninja, and writes temporary files', () async {
|
||||
final BuildCommand command = BuildCommand(
|
||||
artifacts: artifacts,
|
||||
|
||||
@@ -301,6 +301,31 @@ STDERR STUFF
|
||||
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('macOS build outputs path and size when successful', () async {
|
||||
final BuildCommand command = BuildCommand(
|
||||
artifacts: artifacts,
|
||||
androidSdk: FakeAndroidSdk(),
|
||||
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
|
||||
fileSystem: MemoryFileSystem.test(),
|
||||
processUtils: processUtils,
|
||||
logger: BufferLogger.test(),
|
||||
osUtils: FakeOperatingSystemUtils(),
|
||||
);
|
||||
createMinimalMockProjectFiles();
|
||||
|
||||
await createTestCommandRunner(command).run(
|
||||
const <String>['build', 'macos', '--no-pub']
|
||||
);
|
||||
expect(testLogger.statusText, contains(RegExp(r'✓ Built build/macos/Build/Products/Release/example.app \(\d+\.\d+MB\)')));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
|
||||
setUpFakeXcodeBuildHandler('Release'),
|
||||
]),
|
||||
Platform: () => macosPlatform,
|
||||
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('macOS build invokes xcode build (debug)', () async {
|
||||
final BuildCommand command = BuildCommand(
|
||||
artifacts: artifacts,
|
||||
@@ -639,7 +664,7 @@ STDERR STUFF
|
||||
);
|
||||
createMinimalMockProjectFiles();
|
||||
|
||||
fileSystem.file('build/macos/Build/Products/Release/Runner.app/App')
|
||||
fileSystem.file('build/macos/Build/Products/Release/example.app/App')
|
||||
..createSync(recursive: true)
|
||||
..writeAsBytesSync(List<int>.generate(10000, (int index) => 0));
|
||||
|
||||
|
||||
@@ -140,6 +140,7 @@ void main() {
|
||||
final Directory buildDir = fileSystem.directory(fileSystem.path.join('build', 'web'));
|
||||
|
||||
expect(buildDir.existsSync(), true);
|
||||
expect(testLogger.statusText, contains('✓ Built ${buildDir.path}'));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => fakePlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
@@ -236,6 +237,7 @@ void main() {
|
||||
]);
|
||||
|
||||
expect(buildDir.existsSync(), true);
|
||||
expect(testLogger.statusText, contains('✓ Built $newBuildDir'));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => fakePlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
|
||||
@@ -570,6 +570,28 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
||||
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('Windows build outputs path when successful', () async {
|
||||
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
||||
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
||||
..visualStudioOverride = fakeVisualStudio;
|
||||
setUpMockProjectFilesForBuild();
|
||||
|
||||
processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
cmakeGenerationCommand(),
|
||||
buildCommand('Release'),
|
||||
]);
|
||||
|
||||
await createTestCommandRunner(command).run(
|
||||
const <String>['windows', '--release', '--no-pub']
|
||||
);
|
||||
expect(testLogger.statusText, contains(r'✓ Built build\windows\x64\runner\Release'));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
Platform: () => windowsPlatform,
|
||||
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('Windows build passes correct generator', () async {
|
||||
const String generator = 'A different generator';
|
||||
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(
|
||||
|
||||
@@ -751,7 +751,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(
|
||||
() => unknownOsUtils.unzip(fileSystem.file('foo.zip'), fileSystem.currentDirectory),
|
||||
() => unknownOsUtils.unzip(fileSystem.file('foo.zip'), fileSystem.currentDirectory),
|
||||
throwsToolExit
|
||||
(message: 'Missing "unzip" tool. Unable to extract foo.zip.\n'
|
||||
'Please install unzip.'),
|
||||
@@ -759,6 +759,26 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWithoutContext('directory size', () {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final OperatingSystemUtils osUtils = OperatingSystemUtils(
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
platform: FakePlatform(operatingSystem: 'fuchsia'),
|
||||
processManager: fakeProcessManager,
|
||||
);
|
||||
|
||||
final Directory directory = fileSystem.systemTempDirectory.childDirectory('test_directory');
|
||||
directory.createSync();
|
||||
directory.childFile('file1.txt').writeAsBytesSync(List<int>.filled(10, 0));
|
||||
directory.childFile('file2.txt').writeAsBytesSync(List<int>.filled(20, 0));
|
||||
final Directory subDirectory = directory.childDirectory('sub_directory');
|
||||
subDirectory.createSync();
|
||||
subDirectory.childFile('file3.txt').writeAsBytesSync(List<int>.filled(15, 0));
|
||||
|
||||
expect(osUtils.getDirectorySize(directory), equals(10 + 20 + 15));
|
||||
});
|
||||
|
||||
testWithoutContext('stream compression level', () {
|
||||
expect(OperatingSystemUtils.gzipLevel1.level, equals(1));
|
||||
});
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/base/utils.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
@@ -406,4 +407,14 @@ needs to be wrapped.
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testWithoutContext('getSizeAsMB', () async {
|
||||
// ignore: avoid_redundant_argument_values
|
||||
expect(getSizeAsPlatformMB(10 * 1000 * 1000, platform: FakePlatform(operatingSystem: 'linux')), '10.0MB');
|
||||
expect(getSizeAsPlatformMB(10 * 1000 * 1000, platform: FakePlatform(operatingSystem: 'macos')), '10.0MB');
|
||||
expect(getSizeAsPlatformMB(10 * 1000 * 1000, platform: FakePlatform(operatingSystem: 'windows')), '9.5MB');
|
||||
expect(getSizeAsPlatformMB(10 * 1000 * 1000, platform: FakePlatform(operatingSystem: 'android')), '10.0MB');
|
||||
expect(getSizeAsPlatformMB(10 * 1000 * 1000, platform: FakePlatform(operatingSystem: 'ios')), '10.0MB');
|
||||
expect(getSizeAsPlatformMB(10 * 1000 * 1000, platform: FakePlatform(operatingSystem: 'web')), '10.0MB');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -550,6 +550,9 @@ class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
|
||||
@override
|
||||
List<File> whichAll(String execName) => <File>[];
|
||||
|
||||
@override
|
||||
int? getDirectorySize(Directory directory) => 10000000; // 10 MB / 9.5 MiB
|
||||
|
||||
@override
|
||||
void unzip(File file, Directory targetDirectory) { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user