Revert the preview-device feature, tests, and code that only existed for it. (#162835)

Closes https://github.com/flutter/flutter/issues/162693.

Fortunately due to the power of `git`, it will live forever 🫡
This commit is contained in:
Matan Lurey 2025-02-07 17:03:25 -08:00 committed by GitHub
parent 494c47cb4f
commit 6cca066620
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 24 additions and 1195 deletions

View File

@ -187,11 +187,9 @@ List<FlutterCommand> generateCommands({required bool verboseHelp, required bool
fileSystem: globals.fs,
),
BuildCommand(
artifacts: globals.artifacts!,
fileSystem: globals.fs,
buildSystem: globals.buildSystem,
osUtils: globals.os,
processUtils: globals.processUtils,
verboseHelp: verboseHelp,
androidSdk: globals.androidSdk,
logger: globals.logger,

View File

@ -73,9 +73,6 @@ enum Artifact {
/// The location of file generators.
flutterToolsFileGenerators,
/// Pre-built desktop debug app.
flutterPreviewDevice,
}
/// A subset of [Artifact]s that are platform and build mode independent
@ -241,8 +238,6 @@ String? _artifactToFileName(Artifact artifact, Platform hostPlatform, [BuildMode
return 'const_finder.dart.snapshot';
case Artifact.flutterToolsFileGenerators:
return '';
case Artifact.flutterPreviewDevice:
return 'flutter_preview$exe';
}
}
@ -672,7 +667,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
case Artifact.flutterToolsFileGenerators:
case Artifact.flutterPreviewDevice:
return _getHostArtifactPath(artifact, platform, mode);
}
}
@ -724,7 +718,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
case Artifact.flutterToolsFileGenerators:
case Artifact.flutterPreviewDevice:
return _getHostArtifactPath(artifact, platform, mode);
}
}
@ -771,7 +764,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
case Artifact.flutterToolsFileGenerators:
case Artifact.flutterPreviewDevice:
return _getHostArtifactPath(artifact, platform, mode);
}
}
@ -823,7 +815,6 @@ class CachedArtifacts implements Artifacts {
case Artifact.windowsCppClientWrapper:
case Artifact.windowsDesktopPath:
case Artifact.flutterToolsFileGenerators:
case Artifact.flutterPreviewDevice:
return _getHostArtifactPath(artifact, platform, mode);
}
}
@ -955,9 +946,6 @@ class CachedArtifacts implements Artifacts {
throw StateError('Artifact $artifact not available for platform $platform.');
case Artifact.flutterToolsFileGenerators:
return _getFileGeneratorsPath();
case Artifact.flutterPreviewDevice:
assert(platform == TargetPlatform.windows_x64);
return _cache.getArtifactDirectory('flutter_preview').childFile('flutter_preview.exe').path;
}
}
@ -1442,13 +1430,6 @@ class CachedLocalEngineArtifacts implements Artifacts {
return _fileSystem.path.join(_getDartSdkPath(), 'bin', 'snapshots', artifactFileName);
case Artifact.flutterToolsFileGenerators:
return _getFileGeneratorsPath();
case Artifact.flutterPreviewDevice:
return _backupCache.getArtifactPath(
artifact,
platform: platform,
mode: mode,
environmentType: environmentType,
);
}
}
@ -1624,7 +1605,6 @@ class CachedLocalWebSdkArtifacts implements Artifacts {
case Artifact.fontSubset:
case Artifact.constFinder:
case Artifact.flutterToolsFileGenerators:
case Artifact.flutterPreviewDevice:
break;
}
}

View File

@ -5,14 +5,11 @@
import 'package:meta/meta.dart';
import '../android/android_sdk.dart';
import '../artifacts.dart';
import '../base/file_system.dart';
import '../base/logger.dart';
import '../base/os.dart';
import '../base/process.dart';
import '../build_info.dart';
import '../build_system/build_system.dart';
import '../cache.dart';
import '../commands/build_linux.dart';
import '../commands/build_macos.dart';
import '../commands/build_windows.dart';
@ -24,18 +21,15 @@ import 'build_bundle.dart';
import 'build_ios.dart';
import 'build_ios_framework.dart';
import 'build_macos_framework.dart';
import 'build_preview.dart';
import 'build_web.dart';
class BuildCommand extends FlutterCommand {
BuildCommand({
required Artifacts artifacts,
required FileSystem fileSystem,
required BuildSystem buildSystem,
required OperatingSystemUtils osUtils,
required Logger logger,
required AndroidSdk? androidSdk,
required ProcessUtils processUtils,
bool verboseHelp = false,
}) {
_addSubcommand(
@ -71,16 +65,6 @@ class BuildCommand extends FlutterCommand {
_addSubcommand(
BuildWindowsCommand(logger: logger, operatingSystemUtils: osUtils, verboseHelp: verboseHelp),
);
_addSubcommand(
BuildPreviewCommand(
artifacts: artifacts,
flutterRoot: Cache.flutterRoot!,
fs: fileSystem,
logger: logger,
processUtils: processUtils,
verboseHelp: verboseHelp,
),
);
}
void _addSubcommand(BuildSubCommand command) {

View File

@ -1,118 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:file/file.dart';
import '../artifacts.dart';
import '../base/common.dart';
import '../base/io.dart';
import '../base/process.dart';
import '../build_info.dart';
import '../cache.dart';
import '../dart/package_map.dart';
import '../globals.dart' as globals;
import '../project.dart';
import '../runner/flutter_command.dart' show FlutterCommandResult;
import '../windows/build_windows.dart';
import 'build.dart';
class BuildPreviewCommand extends BuildSubCommand {
BuildPreviewCommand({
required super.logger,
required super.verboseHelp,
required this.fs,
required this.flutterRoot,
required this.processUtils,
required this.artifacts,
});
@override
final String name = '_preview';
@override
final bool hidden = true;
@override
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => <DevelopmentArtifact>{
DevelopmentArtifact.windows,
};
@override
final String description = 'Build Flutter preview (desktop) app.';
final FileSystem fs;
final String flutterRoot;
final ProcessUtils processUtils;
final Artifacts artifacts;
@override
void requiresPubspecYaml() {}
static const String appName = 'flutter_preview';
@override
Future<FlutterCommandResult> runCommand() async {
if (!globals.platform.isWindows) {
throwToolExit('"build _preview" is currently only supported on Windows hosts.');
}
final Directory targetDir = fs.systemTempDirectory.createTempSync('flutter-build-preview');
try {
final FlutterProject flutterProject = await _createProject(targetDir);
final File packageConfigFile = findPackageConfigFileOrDefault(flutterProject.directory);
final BuildInfo buildInfo = BuildInfo(
BuildMode.debug,
null, // no flavor
// users may add icons later
packageConfigPath: packageConfigFile.path,
packageConfig: await loadPackageConfigWithLogging(packageConfigFile, logger: logger),
treeShakeIcons: false,
);
// TODO(loic-sharma): Support windows-arm64 preview device, https://github.com/flutter/flutter/issues/139949.
await buildWindows(flutterProject.windows, buildInfo, TargetPlatform.windows_x64);
final File previewDevice = targetDir
.childDirectory(getWindowsBuildDirectory(TargetPlatform.windows_x64))
.childDirectory('runner')
.childDirectory('Debug')
.childFile('$appName.exe');
if (!previewDevice.existsSync()) {
throw StateError('Preview device not found at ${previewDevice.absolute.path}');
}
final String newPath = artifacts.getArtifactPath(Artifact.flutterPreviewDevice);
fs.file(newPath).parent.createSync(recursive: true);
previewDevice.copySync(newPath);
return FlutterCommandResult.success();
} finally {
try {
targetDir.deleteSync(recursive: true);
} on FileSystemException catch (exception) {
logger.printError('Failed to delete ${targetDir.path}\n\n$exception');
}
}
}
Future<FlutterProject> _createProject(Directory targetDir) async {
final List<String> cmd = <String>[
fs.path.join(flutterRoot, 'bin', 'flutter.bat'),
'create',
'--empty',
'--project-name',
'flutter_preview',
targetDir.path,
];
final RunResult result = await processUtils.run(cmd, allowReentrantFlutter: true);
if (result.exitCode != 0) {
final StringBuffer buffer = StringBuffer(
'${cmd.join(' ')} exited with code ${result.exitCode}\n',
);
buffer.writeln('stdout:\n${result.stdout}\n');
buffer.writeln('stderr:\n${result.stderr}');
throw ProcessException(cmd.first, cmd.sublist(1), buffer.toString(), result.exitCode);
}
return FlutterProject.fromDirectory(targetDir);
}
}

View File

@ -585,23 +585,6 @@ class DaemonDomain extends Domain {
'fixCode': _ReasonCode.config.name,
});
}
case PlatformType.windowsPreview:
// TODO(fujino): detect if there any plugins with native code
if (!featureFlags.isPreviewDeviceEnabled) {
reasons.add(<String, Object>{
'reasonText': 'the Preview Device feature is not enabled',
'fixText': 'Run "flutter config --enable-flutter-preview',
'fixCode': _ReasonCode.config.name,
});
}
if (!supportedPlatforms.contains(SupportedPlatform.windows)) {
reasons.add(<String, Object>{
'reasonText': 'the Windows platform is not enabled for this project',
'fixText':
'Run "flutter create --platforms=windows ." in your application directory',
'fixCode': _ReasonCode.create.name,
});
}
}
if (reasons.isEmpty) {

View File

@ -253,7 +253,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
linuxPlatform: platform.isLinux,
macOSPlatform: platform.isMacOS,
windowsPlatform: platform.isWindows,
allowedPlugins: const <String>[],
);
// Generate initial package_config.json, otherwise the build will fail.

View File

@ -50,8 +50,7 @@ enum PlatformType {
macos,
windows,
fuchsia,
custom,
windowsPreview;
custom;
@override
String toString() => name;

View File

@ -48,9 +48,6 @@ abstract class FeatureFlags {
/// Whether native assets compilation and bundling is enabled.
bool get isNativeAssetsEnabled => false;
/// Whether native assets compilation and bundling is enabled.
bool get isPreviewDeviceEnabled => true;
/// Whether Swift Package Manager dependency management is enabled.
bool get isSwiftPackageManagerEnabled => false;
@ -75,7 +72,6 @@ const List<Feature> allFeatures = <Feature>[
flutterCustomDevicesFeature,
cliAnimation,
nativeAssets,
previewDevice,
swiftPackageManager,
explicitPackageDependencies,
];
@ -159,15 +155,6 @@ const Feature nativeAssets = Feature(
master: FeatureChannelSetting(available: true),
);
/// Enable Flutter preview prebuilt device.
const Feature previewDevice = Feature(
name: 'Flutter preview prebuilt device',
configSetting: 'enable-flutter-preview',
environmentOverride: 'FLUTTER_PREVIEW_DEVICE',
master: FeatureChannelSetting(available: true),
beta: FeatureChannelSetting(available: true),
);
/// Enable Swift Package Manager as a darwin dependency manager.
const Feature swiftPackageManager = Feature(
name: 'support for Swift Package Manager for iOS and macOS',

View File

@ -25,7 +25,6 @@ import 'macos/macos_ipad_device.dart';
import 'macos/macos_workflow.dart';
import 'macos/xcdevice.dart';
import 'native_assets.dart';
import 'preview_device.dart';
import 'tester/flutter_tester.dart';
import 'version.dart';
import 'web/web_device.dart';
@ -94,14 +93,6 @@ class FlutterDeviceManager extends DeviceManager {
fileSystem: fileSystem,
operatingSystemUtils: operatingSystemUtils,
),
PreviewDeviceDiscovery(
platform: platform,
artifacts: artifacts,
fileSystem: fileSystem,
logger: logger,
processManager: processManager,
featureFlags: featureFlags,
),
LinuxDevices(
platform: platform,
featureFlags: featureFlags,

View File

@ -55,9 +55,6 @@ class FlutterFeatureFlags implements FeatureFlags {
@override
bool get isNativeAssetsEnabled => isEnabled(nativeAssets);
@override
bool get isPreviewDeviceEnabled => isEnabled(previewDevice);
@override
bool get isSwiftPackageManagerEnabled => isEnabled(swiftPackageManager);

View File

@ -900,37 +900,12 @@ List<Plugin> _filterPluginsByVariant(
Future<void> writeWindowsPluginFiles(
FlutterProject project,
List<Plugin> plugins,
TemplateRenderer templateRenderer, {
Iterable<String>? allowedPlugins,
}) async {
TemplateRenderer templateRenderer,
) async {
final List<Plugin> methodChannelPlugins = _filterMethodChannelPlugins(
plugins,
WindowsPlugin.kConfigKey,
);
if (allowedPlugins != null) {
final List<Plugin> disallowedPlugins =
methodChannelPlugins.toList()
..removeWhere((Plugin plugin) => allowedPlugins.contains(plugin.name));
if (disallowedPlugins.isNotEmpty) {
final StringBuffer buffer = StringBuffer();
buffer.writeln(
'The Flutter Preview device does not support the following plugins from your pubspec.yaml:',
);
buffer.writeln();
buffer.writeln(disallowedPlugins.map((Plugin p) => p.name).toList().toString());
buffer.writeln();
buffer.writeln(
'In order to build a Flutter app with plugins, you must use another target platform,',
);
buffer.writeln(
'such as Windows. Type `flutter doctor` into your terminal to see which target platforms',
);
buffer.writeln(
'are ready to be used, and how to get required dependencies for other platforms.',
);
throwToolExit(buffer.toString());
}
}
final List<Plugin> win32Plugins = _filterPluginsByVariant(
methodChannelPlugins,
WindowsPlugin.kConfigKey,
@ -1212,7 +1187,6 @@ Future<void> injectPlugins(
bool linuxPlatform = false,
bool macOSPlatform = false,
bool windowsPlatform = false,
Iterable<String>? allowedPlugins,
DarwinDependencyManagement? darwinDependencyManagement,
bool? releaseMode,
}) async {
@ -1244,7 +1218,6 @@ Future<void> injectPlugins(
project,
pluginsByPlatform[WindowsPlugin.kConfigKey]!,
globals.templateRenderer,
allowedPlugins: allowedPlugins,
);
}
if (iosPlatform || macOSPlatform) {

View File

@ -1,261 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:meta/meta.dart';
import 'package:process/process.dart';
import 'application_package.dart';
import 'artifacts.dart';
import 'base/file_system.dart';
import 'base/io.dart';
import 'base/logger.dart';
import 'base/platform.dart';
import 'build_info.dart';
import 'bundle_builder.dart';
import 'desktop_device.dart';
import 'devfs.dart';
import 'device.dart';
import 'device_port_forwarder.dart';
import 'features.dart';
import 'project.dart';
import 'protocol_discovery.dart';
typedef BundleBuilderFactory = BundleBuilder Function();
BundleBuilder _defaultBundleBuilder() {
return BundleBuilder();
}
class PreviewDeviceDiscovery extends PollingDeviceDiscovery {
PreviewDeviceDiscovery({
required Platform platform,
required Artifacts artifacts,
required FileSystem fileSystem,
required Logger logger,
required ProcessManager processManager,
required FeatureFlags featureFlags,
}) : _artifacts = artifacts,
_logger = logger,
_processManager = processManager,
_fileSystem = fileSystem,
_platform = platform,
_features = featureFlags,
super('Flutter preview device');
final Platform _platform;
final Artifacts _artifacts;
final Logger _logger;
final ProcessManager _processManager;
final FileSystem _fileSystem;
final FeatureFlags _features;
@override
bool get canListAnything => _platform.isWindows;
@override
bool get supportsPlatform => _platform.isWindows;
@override
List<String> get wellKnownIds => <String>['preview'];
@override
Future<List<Device>> pollingGetDevices({Duration? timeout}) async {
final File previewBinary = _fileSystem.file(
_artifacts.getArtifactPath(Artifact.flutterPreviewDevice),
);
if (!previewBinary.existsSync()) {
return const <Device>[];
}
final PreviewDevice device = PreviewDevice(
artifacts: _artifacts,
fileSystem: _fileSystem,
logger: _logger,
processManager: _processManager,
previewBinary: previewBinary,
);
return <Device>[if (_features.isPreviewDeviceEnabled) device];
}
@override
Future<List<Device>> discoverDevices({Duration? timeout, DeviceDiscoveryFilter? filter}) {
return devices();
}
}
/// A device type that runs a prebuilt desktop binary alongside a locally compiled kernel file.
class PreviewDevice extends Device {
PreviewDevice({
required ProcessManager processManager,
required super.logger,
required FileSystem fileSystem,
required Artifacts artifacts,
required File previewBinary,
@visibleForTesting BundleBuilderFactory builderFactory = _defaultBundleBuilder,
}) : _previewBinary = previewBinary,
_processManager = processManager,
_logger = logger,
_fileSystem = fileSystem,
_bundleBuilderFactory = builderFactory,
_artifacts = artifacts,
super(
'preview',
ephemeral: false,
category: Category.desktop,
platformType: PlatformType.windowsPreview,
);
final ProcessManager _processManager;
final Logger _logger;
final FileSystem _fileSystem;
final BundleBuilderFactory _bundleBuilderFactory;
final Artifacts _artifacts;
final File _previewBinary;
/// The set of plugins that are allowed to be used by Preview users.
///
/// Currently no plugins are supported.
static const List<String> supportedPubPlugins = <String>[];
@override
void clearLogs() {}
@override
Future<void> dispose() async {}
@override
Future<String?> get emulatorId async => null;
final DesktopLogReader _logReader = DesktopLogReader();
@override
FutureOr<DeviceLogReader> getLogReader({ApplicationPackage? app, bool includePastLogs = false}) =>
_logReader;
@override
Future<bool> installApp(ApplicationPackage? app, {String? userIdentifier}) async => true;
@override
Future<bool> isAppInstalled(ApplicationPackage app, {String? userIdentifier}) async => false;
@override
Future<bool> isLatestBuildInstalled(ApplicationPackage app) async => false;
@override
Future<bool> get isLocalEmulator async => false;
@override
bool isSupported() => true;
@override
bool isSupportedForProject(FlutterProject flutterProject) => true;
@override
String get name => 'Preview';
@override
DevicePortForwarder get portForwarder => const NoOpDevicePortForwarder();
@override
Future<String> get sdkNameAndVersion async => 'preview';
Process? _process;
@override
Future<LaunchResult> startApp(
ApplicationPackage? package, {
String? mainPath,
String? route,
required DebuggingOptions debuggingOptions,
Map<String, dynamic> platformArgs = const <String, dynamic>{},
bool prebuiltApplication = false,
String? userIdentifier,
}) async {
final Directory assetDirectory = _fileSystem.systemTempDirectory.createTempSync(
'flutter_preview.',
);
// Build assets and perform initial compilation.
Status? status;
try {
status = _logger.startProgress('Compiling application for preview...');
await _bundleBuilderFactory().build(
buildInfo: debuggingOptions.buildInfo,
mainPath: mainPath,
platform: TargetPlatform.windows_x64,
assetDirPath: getAssetBuildDirectory(),
);
copyDirectory(
_fileSystem.directory(getAssetBuildDirectory()),
assetDirectory.childDirectory('data').childDirectory('flutter_assets'),
);
} finally {
status?.stop();
}
// Merge with precompiled executable.
final String copiedPreviewBinaryPath = assetDirectory.childFile(_previewBinary.basename).path;
_previewBinary.copySync(copiedPreviewBinaryPath);
final String windowsPath = _artifacts.getArtifactPath(
Artifact.windowsDesktopPath,
platform: TargetPlatform.windows_x64,
mode: BuildMode.debug,
);
final File windowsDll = _fileSystem.file(
_fileSystem.path.join(windowsPath, 'flutter_windows.dll'),
);
final File icu = _fileSystem.file(_fileSystem.path.join(windowsPath, 'icudtl.dat'));
windowsDll.copySync(assetDirectory.childFile('flutter_windows.dll').path);
icu.copySync(assetDirectory.childDirectory('data').childFile('icudtl.dat').path);
final Process process = await _processManager.start(<String>[copiedPreviewBinaryPath]);
_process = process;
_logReader.initializeProcess(process);
final ProtocolDiscovery vmServiceDiscovery = ProtocolDiscovery.vmService(
_logReader,
devicePort: debuggingOptions.deviceVmServicePort,
hostPort: debuggingOptions.hostVmServicePort,
ipv6: debuggingOptions.ipv6,
logger: _logger,
);
try {
final Uri? vmServiceUri = await vmServiceDiscovery.uri;
if (vmServiceUri != null) {
return LaunchResult.succeeded(vmServiceUri: vmServiceUri);
}
_logger.printError(
'Error waiting for a debug connection: '
'The log reader stopped unexpectedly.',
);
} on Exception catch (error) {
_logger.printError('Error waiting for a debug connection: $error');
} finally {
await vmServiceDiscovery.cancel();
}
return LaunchResult.failed();
}
@override
Future<bool> stopApp(ApplicationPackage? app, {String? userIdentifier}) async {
return _process?.kill() ?? false;
}
@override
Future<TargetPlatform> get targetPlatform async {
return TargetPlatform.windows_x64;
}
@override
Future<bool> uninstallApp(ApplicationPackage app, {String? userIdentifier}) async {
return true;
}
@override
DevFSWriter createDevFSWriter(ApplicationPackage? app, String? userIdentifier) {
return LocalDevFSWriter(fileSystem: _fileSystem);
}
}

View File

@ -325,13 +325,8 @@ class FlutterProject {
/// registrants for app and module projects only.
///
/// Will not create project platform directories if they do not already exist.
///
/// If [allowedPlugins] is non-null, all plugins with method channels in the
/// project's pubspec.yaml will be validated to be in that set, or else a
/// [ToolExit] will be thrown.
Future<void> regeneratePlatformSpecificTooling({
DeprecationBehavior deprecationBehavior = DeprecationBehavior.none,
Iterable<String>? allowedPlugins,
bool? releaseMode,
}) async {
return ensureReadyForPlatformSpecificTooling(
@ -344,7 +339,6 @@ class FlutterProject {
windowsPlatform: featureFlags.isWindowsEnabled && windows.existsSync(),
webPlatform: featureFlags.isWebEnabled && web.existsSync(),
deprecationBehavior: deprecationBehavior,
allowedPlugins: allowedPlugins,
releaseMode: releaseMode,
);
}
@ -359,7 +353,6 @@ class FlutterProject {
bool windowsPlatform = false,
bool webPlatform = false,
DeprecationBehavior deprecationBehavior = DeprecationBehavior.none,
Iterable<String>? allowedPlugins,
bool? releaseMode,
}) async {
if (!directory.existsSync() || isPlugin) {
@ -391,7 +384,6 @@ class FlutterProject {
linuxPlatform: linuxPlatform,
macOSPlatform: macOSPlatform,
windowsPlatform: windowsPlatform,
allowedPlugins: allowedPlugins,
releaseMode: releaseMode,
);
}

View File

@ -27,7 +27,6 @@ import '../dart/pub.dart';
import '../device.dart';
import '../features.dart';
import '../globals.dart' as globals;
import '../preview_device.dart';
import '../project.dart';
import '../reporting/reporting.dart';
import '../reporting/unified_analytics.dart';
@ -1945,19 +1944,7 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
return;
}
// TODO(matanlurey): Determine if PreviewDevice should be kept.
// https://github.com/flutter/flutter/issues/162693
final List<String>? allowedPlugins;
if (stringArg(FlutterGlobalOptions.kDeviceIdOption, global: true) == 'preview') {
// The preview device does not currently support any plugins.
allowedPlugins = PreviewDevice.supportedPubPlugins;
} else {
// null means all plugins are allowed
allowedPlugins = null;
}
await project.regeneratePlatformSpecificTooling(
allowedPlugins: allowedPlugins,
// TODO(matanlurey): Move this up, i.e. releaseMode ??= getBuildMode().release.
//
// As it stands, this is a breaking change until https://github.com/flutter/flutter/issues/162704 is

View File

@ -3,11 +3,9 @@
// found in the LICENSE file.
import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
@ -23,7 +21,6 @@ import '../../src/test_flutter_command_runner.dart';
void main() {
late BufferLogger logger;
late MemoryFileSystem fs;
late Artifacts artifacts;
late FakeProcessManager processManager;
late Platform platform;
late Cache cache;
@ -37,7 +34,6 @@ void main() {
fs = MemoryFileSystem.test();
final Directory flutterRoot = fs.directory('flutter');
Cache.flutterRoot = flutterRoot.path;
artifacts = Artifacts.test(fileSystem: fs);
logger = BufferLogger.test();
platform = FakePlatform(environment: const <String, String>{'PATH': ''});
processManager = FakeProcessManager.empty();
@ -63,12 +59,10 @@ flutter:
final BuildCommand command = BuildCommand(
androidSdk: FakeAndroidSdk(),
artifacts: artifacts,
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fs,
logger: logger,
osUtils: FakeOperatingSystemUtils(),
processUtils: ProcessUtils(logger: logger, processManager: processManager),
);
expect(
@ -120,12 +114,10 @@ flutter:
final BuildCommand command = BuildCommand(
androidSdk: FakeAndroidSdk(),
artifacts: artifacts,
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fs,
logger: logger,
osUtils: FakeOperatingSystemUtils(),
processUtils: ProcessUtils(logger: logger, processManager: processManager),
);
await createTestCommandRunner(command).run(const <String>['build', 'aar', '--no-pub']);

View File

@ -5,13 +5,11 @@
import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_sdk.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/cache.dart';
@ -71,8 +69,6 @@ void main() {
late FakeAnalytics fakeAnalytics;
late BufferLogger logger;
late FakeProcessManager processManager;
late ProcessUtils processUtils;
late Artifacts artifacts;
setUpAll(() {
Cache.disableLocking();
@ -80,14 +76,12 @@ void main() {
setUp(() {
fileSystem = MemoryFileSystem.test();
artifacts = Artifacts.test(fileSystem: fileSystem);
fakeAnalytics = getInitializedFakeAnalyticsInstance(
fs: fileSystem,
fakeFlutterVersion: FakeFlutterVersion(),
);
logger = BufferLogger.test();
processManager = FakeProcessManager.empty();
processUtils = ProcessUtils(logger: logger, processManager: processManager);
});
// Sets up the minimal mock project files necessary to look like a Flutter project.
@ -205,12 +199,10 @@ void main() {
'ios build fails when there is no ios project',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createCoreMockProjectFiles();
@ -232,12 +224,10 @@ void main() {
'ios build fails in debug with code analysis',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createCoreMockProjectFiles();
@ -261,12 +251,10 @@ void main() {
'ios build fails on non-macOS platform',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fileSystem.file('pubspec.yaml').createSync();
@ -295,12 +283,10 @@ void main() {
'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();
@ -335,12 +321,10 @@ void main() {
'ios build invokes xcode build',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -373,12 +357,10 @@ void main() {
'ios build invokes xcode build with disable port publication setting',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -413,12 +395,10 @@ void main() {
'ios build invokes xcode build without disable port publication setting when not in CI',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -452,13 +432,11 @@ void main() {
'ios build invokes xcode build with renamed xcodeproj and xcworkspace',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
osUtils: FakeOperatingSystemUtils(),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
);
processManager.addCommands(<FakeCommand>[
@ -501,12 +479,10 @@ void main() {
'ios build invokes xcode build with device ID',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -541,12 +517,10 @@ void main() {
'ios simulator build invokes xcode build',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -580,12 +554,10 @@ void main() {
'ios build invokes xcode build with verbosity',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -617,12 +589,10 @@ void main() {
'Performs code size analysis and sends analytics',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -698,13 +668,11 @@ void main() {
'Sends an analytics event when Impeller is enabled',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: MemoryFileSystem.test(),
logger: BufferLogger.test(),
osUtils: FakeOperatingSystemUtils(),
processUtils: processUtils,
);
createMinimalMockProjectFiles();
@ -749,13 +717,11 @@ void main() {
'Sends an analytics event when Impeller is disabled',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: BufferLogger.test(),
osUtils: FakeOperatingSystemUtils(),
processUtils: processUtils,
);
createMinimalMockProjectFiles();
@ -821,12 +787,10 @@ void main() {
'Trace error if xcresult is empty.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -864,12 +828,10 @@ void main() {
'Display xcresult issues on console if parsed, suppress Xcode output',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -914,12 +876,10 @@ void main() {
'Do not display xcresult issues that needs to be discarded.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -969,12 +929,10 @@ void main() {
'Trace if xcresult bundle does not exist.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1009,12 +967,10 @@ void main() {
'Extra error message for provision profile issue in xcresult bundle.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1067,12 +1023,10 @@ void main() {
'Display xcresult issues with no provisioning profile.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1116,12 +1070,10 @@ void main() {
'Extra error message for missing simulator platform in xcresult bundle.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1159,12 +1111,10 @@ void main() {
'Delete xcresult bundle before each xcodebuild command.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1219,12 +1169,10 @@ void main() {
'Failed to parse xcresult but display missing provisioning profile issue from stdout.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1265,12 +1213,10 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
'Failed to parse xcresult but detected no development team issue.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1309,12 +1255,10 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
'xcresult did not detect issue but detected by stdout.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
@ -1357,12 +1301,10 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
'xcresult did not detect issue, no development team is detected from build setting.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1400,12 +1342,10 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
'No development team issue error message is not displayed if no provisioning profile issue is detected from xcresult first.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1445,12 +1385,10 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
'General provisioning profile issue error message is not displayed if no development team issue is detected first.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1499,12 +1437,10 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
'Trace error if xcresult is empty.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1545,12 +1481,10 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
'Display xcresult issues on console if parsed.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[
@ -1595,12 +1529,10 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
'Do not display xcresult issues that needs to be discarded.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
@ -1654,12 +1586,10 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
'Trace if xcresult bundle does not exist.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[

View File

@ -6,11 +6,9 @@ import 'dart:typed_data';
import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/base/version.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/cache.dart';
@ -74,10 +72,8 @@ class FakePlistUtils extends Fake implements PlistParser {
void main() {
late MemoryFileSystem fileSystem;
late FakeProcessManager fakeProcessManager;
late ProcessUtils processUtils;
late FakePlistUtils plistUtils;
late BufferLogger logger;
late Artifacts artifacts;
late FakeAnalytics fakeAnalytics;
setUpAll(() {
@ -86,10 +82,8 @@ void main() {
setUp(() {
fileSystem = MemoryFileSystem.test();
artifacts = Artifacts.test(fileSystem: fileSystem);
fakeProcessManager = FakeProcessManager.empty();
logger = BufferLogger.test();
processUtils = ProcessUtils(logger: logger, processManager: fakeProcessManager);
plistUtils = FakePlistUtils();
fakeAnalytics = getInitializedFakeAnalyticsInstance(
fs: fileSystem,
@ -234,12 +228,10 @@ void main() {
'ipa build fails when there is no ios project',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createCoreMockProjectFiles();
@ -261,12 +253,10 @@ void main() {
'ipa build fails in debug with code analysis',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createCoreMockProjectFiles();
@ -290,12 +280,10 @@ void main() {
'ipa build fails on non-macOS platform',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fileSystem.file('pubspec.yaml').createSync();
@ -325,12 +313,10 @@ void main() {
'ipa build fails when export plist does not exist',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -356,12 +342,10 @@ void main() {
() async {
final Directory bogus = fileSystem.directory('bogus')..createSync();
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -385,12 +369,10 @@ void main() {
'ipa build fails when --export-options-plist and --export-method are used together',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -420,12 +402,10 @@ void main() {
'ipa build reports method from --export-method when used',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -456,12 +436,10 @@ void main() {
() async {
final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist');
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -512,12 +490,10 @@ void main() {
() async {
final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist');
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -568,12 +544,10 @@ void main() {
() async {
final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist');
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -623,12 +597,10 @@ void main() {
'ipa build accepts "enterprise" export method when on Xcode versions <= 15.3',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -658,12 +630,10 @@ void main() {
() async {
final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist');
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -713,12 +683,10 @@ void main() {
'ipa build accepts legacy methods when on Xcode versions <= 15.3',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -760,12 +728,10 @@ void main() {
exportArchiveCommand(exportOptionsPlist: exportOptions.path),
]);
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(
@ -790,12 +756,10 @@ void main() {
'ipa build reports when IPA fails',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -851,12 +815,10 @@ void main() {
() async {
final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist');
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -888,12 +850,10 @@ void main() {
() async {
final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist');
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -947,12 +907,10 @@ void main() {
() async {
final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist');
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -1008,12 +966,10 @@ void main() {
() async {
final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist');
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -1068,12 +1024,10 @@ void main() {
'ipa build invokes xcode build with verbosity',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -1100,12 +1054,10 @@ void main() {
'ipa build invokes xcode build without disablePortPublication',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -1133,12 +1085,10 @@ void main() {
'ipa build --no-codesign skips codesigning and IPA creation',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -1195,12 +1145,10 @@ void main() {
'code size analysis fails when app not found',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -1226,12 +1174,10 @@ void main() {
'Performs code size analysis and sends analytics',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -1293,12 +1239,10 @@ void main() {
);
final File exportOptions = fileSystem.file('ExportOptions.plist')..createSync();
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -1337,12 +1281,10 @@ void main() {
'Trace error if xcresult is empty.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -1379,12 +1321,10 @@ void main() {
'Display xcresult issues on console if parsed.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -1425,12 +1365,10 @@ void main() {
'Do not display xcresult issues that needs to be discarded.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -1479,12 +1417,10 @@ void main() {
'Trace if xcresult bundle does not exist.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -1518,12 +1454,10 @@ void main() {
'Extra error message for provision profile issue in xcresult bundle.',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fakeProcessManager.addCommands(<FakeCommand>[
@ -1593,12 +1527,10 @@ void main() {
};
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -1659,12 +1591,10 @@ void main() {
};
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -1723,12 +1653,10 @@ void main() {
};
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -1782,12 +1710,10 @@ void main() {
};
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -1832,12 +1758,10 @@ void main() {
};
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -1929,12 +1853,10 @@ void main() {
createMinimalMockProjectFiles();
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -2023,12 +1945,10 @@ void main() {
createMinimalMockProjectFiles();
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -2101,12 +2021,10 @@ void main() {
createMinimalMockProjectFiles();
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -2177,12 +2095,10 @@ void main() {
createMinimalMockProjectFiles();
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -2253,12 +2169,10 @@ void main() {
createMinimalMockProjectFiles();
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -2330,12 +2244,10 @@ void main() {
createMinimalMockProjectFiles();
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -2450,12 +2362,10 @@ void main() {
createMinimalMockProjectFiles();
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -2543,12 +2453,10 @@ void main() {
createMinimalMockProjectFiles();
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);
@ -2635,12 +2543,10 @@ void main() {
createMinimalMockProjectFiles();
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
logger: logger,
fileSystem: fileSystem,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(<String>['build', 'ipa', '--no-pub']);

View File

@ -5,12 +5,10 @@
import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/os.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/cache.dart';
@ -45,18 +43,14 @@ void main() {
late MemoryFileSystem fileSystem;
late FakeProcessManager processManager;
late ProcessUtils processUtils;
late Logger logger;
late Artifacts artifacts;
late FakeAnalytics fakeAnalytics;
setUp(() {
fileSystem = MemoryFileSystem.test();
artifacts = Artifacts.test(fileSystem: fileSystem);
Cache.flutterRoot = _kTestFlutterRoot;
logger = BufferLogger.test();
processManager = FakeProcessManager.empty();
processUtils = ProcessUtils(logger: logger, processManager: processManager);
fakeAnalytics = getInitializedFakeAnalyticsInstance(
fs: fileSystem,
fakeFlutterVersion: FakeFlutterVersion(),
@ -116,12 +110,10 @@ void main() {
'Linux build fails when there is no linux project',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockCoreProjectFiles();
@ -148,12 +140,11 @@ void main() {
'Linux build fails on non-linux platform',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockProjectFilesForBuild();
@ -175,12 +166,11 @@ void main() {
'Linux build fails when feature is disabled',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockProjectFilesForBuild();
@ -205,12 +195,11 @@ void main() {
'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>[
@ -236,12 +225,11 @@ void main() {
'Linux build invokes CMake and ninja, and writes temporary files',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
processManager.addCommands(<FakeCommand>[cmakeCommand('release'), ninjaCommand('release')]);
@ -282,12 +270,11 @@ void main() {
'Handles missing cmake',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockProjectFilesForBuild();
@ -311,12 +298,11 @@ void main() {
'Handles argument error from missing ninja',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockProjectFilesForBuild();
@ -348,12 +334,11 @@ void main() {
'Linux build does not spew stdout to status logger',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockProjectFilesForBuild();
@ -383,12 +368,11 @@ void main() {
'Linux build extracts errors from stdout',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockProjectFilesForBuild();
@ -445,12 +429,11 @@ ERROR: No file or variants found for asset: images/a_dot_burr.jpeg
'Linux verbose build sets VERBOSE_SCRIPT_LOGGING',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockProjectFilesForBuild();
@ -485,12 +468,11 @@ ERROR: No file or variants found for asset: images/a_dot_burr.jpeg
'Linux on x64 build --debug passes debug mode to cmake and ninja',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockProjectFilesForBuild();
@ -514,12 +496,11 @@ ERROR: No file or variants found for asset: images/a_dot_burr.jpeg
'Linux on ARM64 build --debug passes debug mode to cmake and ninja',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: CustomFakeOperatingSystemUtils(hostPlatform: HostPlatform.linux_arm64),
);
setUpMockProjectFilesForBuild();
@ -544,12 +525,11 @@ ERROR: No file or variants found for asset: images/a_dot_burr.jpeg
'Linux on x64 build --profile passes profile mode to make',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockProjectFilesForBuild();
@ -572,12 +552,11 @@ ERROR: No file or variants found for asset: images/a_dot_burr.jpeg
'Linux on ARM64 build --profile passes profile mode to make',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: CustomFakeOperatingSystemUtils(hostPlatform: HostPlatform.linux_arm64),
);
setUpMockProjectFilesForBuild();
@ -602,12 +581,11 @@ ERROR: No file or variants found for asset: images/a_dot_burr.jpeg
'Not support Linux cross-build for x64 on arm64',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: CustomFakeOperatingSystemUtils(hostPlatform: HostPlatform.linux_arm64),
);
@ -628,12 +606,11 @@ ERROR: No file or variants found for asset: images/a_dot_burr.jpeg
'Linux build configures CMake exports',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockProjectFilesForBuild();
@ -733,12 +710,11 @@ set(BINARY_NAME "fizz_bar")
() {
final CommandRunner<void> runner = createTestCommandRunner(
BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
),
);
@ -786,12 +762,11 @@ set(BINARY_NAME "fizz_bar")
'Performs code size analysis and sends analytics',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
setUpMockProjectFilesForBuild();
@ -847,12 +822,11 @@ set(BINARY_NAME "fizz_bar")
'Linux on ARM64 build --release passes, and check if the LinuxBuildDirectory for arm64 can be referenced correctly by using analytics',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: CustomFakeOperatingSystemUtils(hostPlatform: HostPlatform.linux_arm64),
);
setUpMockProjectFilesForBuild();

View File

@ -11,7 +11,6 @@ import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/cache.dart';
@ -55,10 +54,8 @@ final Platform notMacosPlatform = FakePlatform(environment: <String, String>{'FL
void main() {
late MemoryFileSystem fileSystem;
late FakeProcessManager fakeProcessManager;
late ProcessUtils processUtils;
late BufferLogger logger;
late XcodeProjectInterpreter xcodeProjectInterpreter;
late Artifacts artifacts;
late FakeAnalytics fakeAnalytics;
setUpAll(() {
@ -67,10 +64,8 @@ void main() {
setUp(() {
fileSystem = MemoryFileSystem.test();
artifacts = Artifacts.test(fileSystem: fileSystem);
logger = BufferLogger.test();
fakeProcessManager = FakeProcessManager.empty();
processUtils = ProcessUtils(logger: logger, processManager: fakeProcessManager);
xcodeProjectInterpreter = FakeXcodeProjectInterpreter();
fakeAnalytics = getInitializedFakeAnalyticsInstance(
fs: fileSystem,
@ -156,12 +151,10 @@ STDERR STUFF
'macOS build fails when there is no macos project',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createCoreMockProjectFiles();
@ -188,12 +181,10 @@ STDERR STUFF
'macOS build successfully with renamed .xcodeproj/.xcworkspace files',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
@ -230,12 +221,10 @@ STDERR STUFF
'macOS build fails on non-macOS platform',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fileSystem.file('pubspec.yaml').createSync();
@ -258,12 +247,10 @@ STDERR STUFF
'macOS build fails when feature is disabled',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
fileSystem.file('pubspec.yaml').createSync();
@ -289,12 +276,10 @@ STDERR STUFF
'macOS build forwards error stdout to status logger error',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -332,11 +317,9 @@ STDERR STUFF
'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(),
);
@ -362,12 +345,10 @@ STDERR STUFF
'macOS build invokes xcode build (debug)',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -390,12 +371,10 @@ STDERR STUFF
'macOS build invokes xcode build (debug) with verbosity',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -420,12 +399,10 @@ STDERR STUFF
'macOS build invokes xcode build (profile)',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -449,12 +426,10 @@ STDERR STUFF
'macOS build invokes xcode build (release)',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -477,12 +452,10 @@ STDERR STUFF
'macOS build supports standard desktop build options',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -578,12 +551,10 @@ STDERR STUFF
]);
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
@ -607,12 +578,10 @@ STDERR STUFF
'macOS build supports build-name and build-number',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -648,12 +617,10 @@ STDERR STUFF
() {
final CommandRunner<void> runner = createTestCommandRunner(
BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
),
);
@ -694,12 +661,10 @@ STDERR STUFF
'code size analysis throws StateError if no code size snapshot generated by gen_snapshot',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -741,12 +706,10 @@ STDERR STUFF
'Performs code size analysis and sends analytics from arm64 host',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -804,12 +767,10 @@ STDERR STUFF
'macOS build overrides CODE_SIGN_ENTITLEMENTS when in CI if entitlement file exists (debug)',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();
@ -875,12 +836,10 @@ STDERR STUFF
'macOS build overrides CODE_SIGN_ENTITLEMENTS when in CI if entitlement file exists (release)',
() async {
final BuildCommand command = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
createMinimalMockProjectFiles();

View File

@ -4,10 +4,8 @@
import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
@ -39,30 +37,24 @@ void main() {
late MemoryFileSystem fs;
late BufferLogger logger;
late ProcessManager processManager;
late ProcessUtils processUtils;
late Artifacts artifacts;
setUp(() {
fs = MemoryFileSystem.test();
artifacts = Artifacts.test(fileSystem: fs);
fs.file('/package/pubspec.yaml').createSync(recursive: true);
fs.currentDirectory = '/package';
Cache.disableLocking();
logger = BufferLogger.test();
processManager = FakeProcessManager.empty();
processUtils = ProcessUtils(logger: logger, processManager: processManager);
});
testUsingContext(
"doesn't fail if --fatal-warnings specified and no warnings occur",
() async {
command = FakeBuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fs,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
try {
@ -80,12 +72,10 @@ void main() {
"doesn't fail if --fatal-warnings not specified",
() async {
command = FakeBuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fs,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
testLogger.printWarning('Warning: Mild annoyance Will Robinson!');
@ -102,12 +92,10 @@ void main() {
'fails if --fatal-warnings specified and warnings emitted',
() async {
command = FakeBuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fs,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
testLogger.printWarning('Warning: Mild annoyance Will Robinson!');
@ -128,12 +116,10 @@ void main() {
'fails if --fatal-warnings specified and errors emitted',
() async {
command = FakeBuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fs,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
testLogger.printError('Error: Danger Will Robinson!');
@ -178,8 +164,6 @@ class FakeBuildCommand extends BuildCommand {
required super.osUtils,
required Logger logger,
required super.androidSdk,
required super.processUtils,
required super.artifacts,
bool verboseHelp = false,
}) : super(logger: logger) {
addSubcommand(FakeBuildSubcommand(logger: logger, verboseHelp: verboseHelp));

View File

@ -4,12 +4,10 @@
import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/build_system/targets/web.dart';
@ -31,10 +29,8 @@ import '../../src/test_flutter_command_runner.dart';
void main() {
late FileSystem fileSystem;
final Platform fakePlatform = FakePlatform(environment: <String, String>{'FLUTTER_ROOT': '/'});
late ProcessUtils processUtils;
late BufferLogger logger;
late ProcessManager processManager;
late Artifacts artifacts;
// TODO(matanlurey): Remove after `explicit-package-dependencies` is enabled by default.
// See https://github.com/flutter/flutter/issues/160257 for details.
@ -59,10 +55,8 @@ void main() {
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
fileSystem.file(fileSystem.path.join('web', 'index.html')).createSync(recursive: true);
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
artifacts = Artifacts.test(fileSystem: fileSystem);
logger = BufferLogger.test();
processManager = FakeProcessManager.any();
processUtils = ProcessUtils(logger: logger, processManager: processManager);
});
testUsingContext(
@ -71,12 +65,10 @@ void main() {
fileSystem.file(fileSystem.path.join('web', 'index.html')).deleteSync();
final CommandRunner<void> runner = createTestCommandRunner(
BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
),
);
@ -99,12 +91,10 @@ void main() {
() async {
final CommandRunner<void> runner = createTestCommandRunner(
BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: MemoryFileSystem.test(),
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
),
);
@ -129,12 +119,10 @@ void main() {
'Setup for a web build with default output directory',
() async {
final BuildCommand buildCommand = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
final CommandRunner<void> runner = createTestCommandRunner(buildCommand);
@ -182,13 +170,11 @@ void main() {
'Does not allow -O0 optimization level',
() async {
final BuildCommand buildCommand = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: BufferLogger.test(),
osUtils: FakeOperatingSystemUtils(),
processUtils: processUtils,
);
final CommandRunner<void> runner = createTestCommandRunner(buildCommand);
setupFileSystemForEndToEndTest(fileSystem);
@ -244,12 +230,10 @@ void main() {
'Setup for a web build with a user specified output directory',
() async {
final BuildCommand buildCommand = BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
final CommandRunner<void> runner = createTestCommandRunner(buildCommand);

View File

@ -8,11 +8,9 @@ import 'dart:typed_data';
import 'package:fake_async/fake_async.dart';
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_device.dart';
import 'package:flutter_tools/src/android/android_workflow.dart';
import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/dds.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/utils.dart';
@ -23,7 +21,6 @@ import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/ios/ios_workflow.dart';
import 'package:flutter_tools/src/preview_device.dart';
import 'package:flutter_tools/src/resident_runner.dart';
import 'package:flutter_tools/src/vmservice.dart';
import 'package:flutter_tools/src/windows/windows_workflow.dart';
@ -127,7 +124,7 @@ void main() {
expect(response.data['id'], 0);
expect(response.data['result'], isNotEmpty);
expect(response.data['result']! as Map<String, Object?>, const <String, Object>{
'platforms': <String>['macos', 'windows', 'windowsPreview'],
'platforms': <String>['macos', 'windows'],
'platformTypes': <String, Map<String, Object>>{
'web': <String, Object>{
'isSupported': false,
@ -197,7 +194,6 @@ void main() {
},
],
},
'windowsPreview': <String, bool>{'isSupported': true},
},
});
},
@ -208,7 +204,6 @@ void main() {
isAndroidEnabled: false,
isIOSEnabled: false,
isMacOSEnabled: true,
isPreviewDeviceEnabled: true,
isWindowsEnabled: true,
),
},
@ -424,20 +419,9 @@ void main() {
final FakePollingDeviceDiscovery discoverer = FakePollingDeviceDiscovery();
daemon.deviceDomain.addDeviceDiscoverer(discoverer);
discoverer.addDevice(FakeAndroidDevice());
final MemoryFileSystem fs = MemoryFileSystem.test();
discoverer.addDevice(
PreviewDevice(
processManager: FakeProcessManager.empty(),
logger: BufferLogger.test(),
fileSystem: fs,
previewBinary: fs.file(r'preview_device.exe'),
artifacts: Artifacts.test(fileSystem: fs),
builderFactory: () => throw UnimplementedError('TODO implement builder factory'),
),
);
final List<Map<String, Object?>> names = <Map<String, Object?>>[];
await daemonStreams.outputs.stream.skipWhile(_isConnectedEvent).take(2).forEach((
await daemonStreams.outputs.stream.skipWhile(_isConnectedEvent).take(1).forEach((
DaemonMessage response,
) async {
expect(response.data['event'], 'device.added');
@ -472,28 +456,6 @@ void main() {
'startPaused': true,
},
},
<String, Object?>{
'id': 'preview',
'name': 'Preview',
'platform': 'windows-x64',
'emulator': false,
'category': 'desktop',
'platformType': 'windowsPreview',
'ephemeral': false,
'emulatorId': null,
'sdk': 'preview',
'isConnected': true,
'connectionInterface': 'attached',
'capabilities': <String, Object?>{
'hotReload': true,
'hotRestart': true,
'screenshot': false,
'fastStart': false,
'flutterExit': true,
'hardwareRendering': true,
'startPaused': true,
},
},
]),
);
},

View File

@ -534,21 +534,6 @@ void main() {
),
);
expect(
artifacts.getArtifactPath(
Artifact.flutterPreviewDevice,
platform: TargetPlatform.windows_x64,
),
fileSystem.path.join(
'root',
'bin',
'cache',
'artifacts',
'flutter_preview',
'flutter_preview.exe',
),
);
fileSystem
.file(fileSystem.path.join('/out', 'host_debug_unopt', 'impellerc'))
.createSync(recursive: true);

View File

@ -5,12 +5,10 @@
import 'package:args/args.dart';
import 'package:args/command_runner.dart';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/base/signals.dart';
import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/build_info.dart';
@ -115,18 +113,12 @@ void main() {
testUsingContext('Include only supported sub commands', () {
final BufferLogger logger = BufferLogger.test();
final ProcessUtils processUtils = ProcessUtils(
logger: logger,
processManager: FakeProcessManager.empty(),
);
final MemoryFileSystem fs = MemoryFileSystem.test();
final BuildCommand command = BuildCommand(
artifacts: Artifacts.test(fileSystem: fs),
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: fs,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
);
for (final Command<void> x in command.subcommands.values) {

View File

@ -23,7 +23,6 @@ import 'package:flutter_tools/src/ios/xcodeproj.dart';
import 'package:flutter_tools/src/macos/darwin_dependency_management.dart';
import 'package:flutter_tools/src/platform_plugins.dart';
import 'package:flutter_tools/src/plugins.dart';
import 'package:flutter_tools/src/preview_device.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:test/fake.dart';
@ -1892,37 +1891,6 @@ flutter:
},
);
testUsingContext(
'injectPlugins will validate if all plugins in the project are part of the passed allowedPlugins',
() async {
// Re-run the setup using the Windows filesystem.
setUpProject(fsWindows);
createFakePlugins(fsWindows, const <String>['plugin_one', 'plugin_two']);
expect(
() => injectPlugins(
flutterProject,
linuxPlatform: true,
windowsPlatform: true,
allowedPlugins: PreviewDevice.supportedPubPlugins,
),
throwsToolExit(
message: '''
The Flutter Preview device does not support the following plugins from your pubspec.yaml:
[plugin_one, plugin_two]
''',
),
);
},
overrides: <Type, Generator>{
FileSystem: () => fsWindows,
ProcessManager: () => FakeProcessManager.empty(),
FeatureFlags: enableExplicitPackageDependencies,
Pub: FakePubWithPrimedDeps.new,
},
);
testUsingContext(
'iOS and macOS project setup up Darwin Dependency Management',
() async {

View File

@ -1,220 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:file/memory.dart';
import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/bundle.dart';
import 'package:flutter_tools/src/bundle_builder.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/preview_device.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:meta/meta.dart';
import 'package:test/fake.dart';
import '../src/common.dart';
import '../src/context.dart';
import '../src/fakes.dart';
void main() {
String? flutterRootBackup;
late MemoryFileSystem fs;
late File previewBinary;
setUp(() {
fs = MemoryFileSystem.test(style: FileSystemStyle.windows);
Cache.flutterRoot = r'C:\path\to\flutter';
previewBinary = fs.file(
'${Cache.flutterRoot}\\bin\\cache\\artifacts\\flutter_preview\\flutter_preview.exe',
);
previewBinary.createSync(recursive: true);
flutterRootBackup = Cache.flutterRoot;
});
tearDown(() {
Cache.flutterRoot = flutterRootBackup;
});
testWithoutContext('PreviewDevice defaults', () async {
final PreviewDevice device = PreviewDevice(
artifacts: Artifacts.test(),
fileSystem: fs,
processManager: FakeProcessManager.any(),
previewBinary: previewBinary,
logger: BufferLogger.test(),
);
expect(await device.isLocalEmulator, false);
expect(device.name, 'Preview');
expect(await device.sdkNameAndVersion, 'preview');
expect(await device.targetPlatform, TargetPlatform.windows_x64);
expect(device.category, Category.desktop);
expect(device.ephemeral, false);
expect(device.id, 'preview');
expect(device.isSupported(), true);
expect(device.isSupportedForProject(FakeFlutterProject()), true);
expect(await device.isLatestBuildInstalled(FakeApplicationPackage()), false);
expect(await device.isAppInstalled(FakeApplicationPackage()), false);
expect(await device.uninstallApp(FakeApplicationPackage()), true);
});
testUsingContext('Can build a simulator app', () async {
final Completer<void> completer = Completer<void>();
final BufferLogger logger = BufferLogger.test();
final PreviewDevice device = PreviewDevice(
artifacts: Artifacts.test(),
fileSystem: fs,
previewBinary: previewBinary,
processManager: FakeProcessManager.list(<FakeCommand>[
FakeCommand(
command: const <String>[r'C:\.tmp_rand0\flutter_preview.rand0\flutter_preview.exe'],
stdout: 'The Dart VM service is listening on http://127.0.0.1:64494/fZ_B2N6JRwY=/\n',
completer: completer,
),
]),
logger: logger,
builderFactory: () => FakeBundleBuilder(fs),
);
final Directory previewDeviceCacheDir = fs.directory(
'Artifact.windowsDesktopPath.TargetPlatform.windows_x64.debug',
)..createSync(recursive: true);
previewDeviceCacheDir.childFile('flutter_windows.dll').writeAsStringSync('1010101');
previewDeviceCacheDir.childFile('icudtl.dat').writeAsStringSync('1010101');
final LaunchResult result = await device.startApp(
FakeApplicationPackage(),
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
);
expect(result.started, true);
expect(result.vmServiceUri, Uri.parse('http://127.0.0.1:64494/fZ_B2N6JRwY=/'));
});
group('PreviewDeviceDiscovery', () {
late Artifacts artifacts;
late ProcessManager processManager;
final FakePlatform windowsPlatform = FakePlatform(operatingSystem: 'windows');
final FakePlatform macPlatform = FakePlatform(operatingSystem: 'macos');
final FakePlatform linuxPlatform = FakePlatform();
final TestFeatureFlags featureFlags = TestFeatureFlags(isPreviewDeviceEnabled: true);
setUp(() {
artifacts = Artifacts.test(fileSystem: fs);
processManager = FakeProcessManager.empty();
});
testWithoutContext('PreviewDeviceDiscovery on linux', () async {
final PreviewDeviceDiscovery discovery = PreviewDeviceDiscovery(
artifacts: artifacts,
fileSystem: fs,
logger: BufferLogger.test(),
processManager: processManager,
platform: linuxPlatform,
featureFlags: featureFlags,
);
final List<Device> devices = await discovery.devices();
expect(devices, isEmpty);
});
testWithoutContext('PreviewDeviceDiscovery on macOS', () async {
final PreviewDeviceDiscovery discovery = PreviewDeviceDiscovery(
artifacts: artifacts,
fileSystem: fs,
logger: BufferLogger.test(),
processManager: processManager,
platform: macPlatform,
featureFlags: featureFlags,
);
final List<Device> devices = await discovery.devices();
expect(devices, isEmpty);
});
testWithoutContext(
'PreviewDeviceDiscovery on Windows returns preview when binary exists',
() async {
// ensure Flutter preview binary exists in cache.
fs.file(artifacts.getArtifactPath(Artifact.flutterPreviewDevice)).writeAsBytesSync(<int>[
1,
0,
0,
1,
]);
final PreviewDeviceDiscovery discovery = PreviewDeviceDiscovery(
artifacts: artifacts,
fileSystem: fs,
logger: BufferLogger.test(),
processManager: processManager,
platform: windowsPlatform,
featureFlags: featureFlags,
);
final List<Device> devices = await discovery.devices();
expect(devices, hasLength(1));
final Device previewDevice = devices.first;
expect(previewDevice, isA<PreviewDevice>());
},
);
testWithoutContext(
'PreviewDeviceDiscovery on Windows returns nothing when binary does not exist',
() async {
final PreviewDeviceDiscovery discovery = PreviewDeviceDiscovery(
artifacts: artifacts,
fileSystem: fs,
logger: BufferLogger.test(),
processManager: processManager,
platform: windowsPlatform,
featureFlags: featureFlags,
);
final List<Device> devices = await discovery.devices();
expect(devices, isEmpty);
},
);
});
}
class FakeFlutterProject extends Fake implements FlutterProject {}
class FakeApplicationPackage extends Fake implements ApplicationPackage {}
class FakeBundleBuilder extends Fake implements BundleBuilder {
FakeBundleBuilder(this.fileSystem);
final FileSystem fileSystem;
@override
Future<void> build({
required TargetPlatform platform,
required BuildInfo buildInfo,
FlutterProject? project,
String? mainPath,
String manifestPath = defaultManifestPath,
String? applicationKernelFilePath,
String? depfilePath,
String? assetDirPath,
bool buildNativeAssets = true,
@visibleForTesting BuildSystem? buildSystem,
}) async {
final Directory assetDirectory = fileSystem
.directory(assetDirPath)
.childDirectory('flutter_assets')..createSync(recursive: true);
assetDirectory.childFile('kernel_blob.bin').createSync();
}
}

View File

@ -37,14 +37,10 @@ void main() {
testWithoutContext('getEnabledFeatures not null', () {
config.setValue('cli-animations', true);
config.setValue('enable-flutter-preview', true);
final String? enabledFeatures = getEnabledFeatures(config);
expect(enabledFeatures, isNotNull);
expect(
enabledFeatures!.split(','),
unorderedEquals(<String>['enable-flutter-preview', 'cli-animations']),
);
expect(enabledFeatures!.split(','), unorderedEquals(<String>['cli-animations']));
});
});

View File

@ -3,10 +3,8 @@
// found in the LICENSE file.
import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/build.dart';
@ -41,20 +39,16 @@ void main() {
late File registrant;
// Environment overrides
late Artifacts artifacts;
late FileSystem fileSystem;
late ProcessManager processManager;
late BuildSystem buildSystem;
late ProcessUtils processUtils;
late BufferLogger logger;
setUp(() {
// Prepare environment overrides
fileSystem = MemoryFileSystem.test();
artifacts = Artifacts.test(fileSystem: fileSystem);
processManager = FakeProcessManager.any();
logger = BufferLogger.test();
processUtils = ProcessUtils(processManager: processManager, logger: logger);
buildSystem = TestBuildSystem.all(BuildResult(success: true));
// Write some initial state into our testing filesystem
@ -72,13 +66,11 @@ void main() {
await createTestCommandRunner(
BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: buildSystem,
fileSystem: fileSystem,
logger: BufferLogger.test(),
osUtils: FakeOperatingSystemUtils(),
processUtils: processUtils,
),
).run(<String>['build', 'web', '--no-pub']);
@ -104,13 +96,11 @@ void main() {
await createTestCommandRunner(
BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: buildSystem,
fileSystem: fileSystem,
logger: logger,
osUtils: FakeOperatingSystemUtils(),
processUtils: processUtils,
),
).run(<String>['build', 'web', '--no-pub']);
@ -135,12 +125,10 @@ void main() {
await createTestCommandRunner(
BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: buildSystem,
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
),
).run(<String>['build', 'web', '--no-pub']);
@ -168,12 +156,10 @@ void main() {
await createTestCommandRunner(
BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: buildSystem,
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
),
).run(<String>['build', 'web', '--no-pub']);
@ -200,12 +186,10 @@ void main() {
await createTestCommandRunner(
BuildCommand(
artifacts: artifacts,
androidSdk: FakeAndroidSdk(),
buildSystem: buildSystem,
fileSystem: fileSystem,
logger: logger,
processUtils: processUtils,
osUtils: FakeOperatingSystemUtils(),
),
).run(<String>['build', 'web', '--no-pub']);

View File

@ -1,54 +0,0 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:io';
import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart';
import '../src/common.dart';
import '../src/context.dart';
import 'test_utils.dart';
void main() {
Cache.disableLocking();
late Directory tempDir;
final FileSystem fs = LocalFileSystemBlockingSetCurrentDirectory();
final File previewBin = fs
.directory(getFlutterRoot())
.childDirectory('bin')
.childDirectory('cache')
.childDirectory('artifacts')
.childDirectory('flutter_preview')
.childFile('flutter_preview.exe');
setUp(() {
tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_preview_integration_test.');
});
tearDown(() {
tryToDelete(tempDir);
tryToDelete(previewBin);
});
testUsingContext(
'flutter build _preview creates preview device',
() async {
final ProcessResult result = await processManager.run(<String>[
flutterBin,
'build',
'_preview',
'--verbose',
]);
expect(result, const ProcessResultMatcher());
expect(previewBin, exists);
},
// [intended] Flutter Preview only supported on Windows currently
skip: !const LocalPlatform().isWindows,
);
}

View File

@ -484,7 +484,6 @@ class TestFeatureFlags implements FeatureFlags {
this.areCustomDevicesEnabled = false,
this.isCliAnimationEnabled = true,
this.isNativeAssetsEnabled = false,
this.isPreviewDeviceEnabled = false,
this.isSwiftPackageManagerEnabled = false,
this.isExplicitPackageDependenciesEnabled = false,
});
@ -519,9 +518,6 @@ class TestFeatureFlags implements FeatureFlags {
@override
final bool isNativeAssetsEnabled;
@override
final bool isPreviewDeviceEnabled;
@override
final bool isSwiftPackageManagerEnabled;