Tell user how to enable available but disabled features (#79977)
This commit is contained in:
parent
cf27be38a9
commit
1a36c18497
@ -68,7 +68,7 @@ class BuildLinuxCommand extends BuildSubCommand {
|
||||
!= getNameForTargetPlatformArch(targetPlatform);
|
||||
|
||||
if (!featureFlags.isLinuxEnabled) {
|
||||
throwToolExit('"build linux" is not currently supported.');
|
||||
throwToolExit('"build linux" is not currently supported. To enable, run "flutter config --enable-linux-desktop".');
|
||||
}
|
||||
if (!globals.platform.isLinux) {
|
||||
throwToolExit('"build linux" only supported on Linux hosts.');
|
||||
|
@ -44,7 +44,7 @@ class BuildMacosCommand extends BuildSubCommand {
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
if (!featureFlags.isMacOSEnabled) {
|
||||
throwToolExit('"build macos" is not currently supported.');
|
||||
throwToolExit('"build macos" is not currently supported. To enable, run "flutter config --enable-macos-desktop".');
|
||||
}
|
||||
if (!globals.platform.isMacOS) {
|
||||
throwToolExit('"build macos" only supported on macOS hosts.');
|
||||
|
@ -79,7 +79,7 @@ class BuildWebCommand extends BuildSubCommand {
|
||||
@override
|
||||
Future<FlutterCommandResult> runCommand() async {
|
||||
if (!featureFlags.isWebEnabled) {
|
||||
throwToolExit('"build web" is not currently supported.');
|
||||
throwToolExit('"build web" is not currently supported. To enable, run "flutter config --enable-web".');
|
||||
}
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
final String target = stringArg('target');
|
||||
|
@ -46,7 +46,7 @@ class BuildWindowsCommand extends BuildSubCommand {
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
if (!featureFlags.isWindowsEnabled) {
|
||||
throwToolExit('"build windows" is not currently supported.');
|
||||
throwToolExit('"build windows" is not currently supported. To enable, run "flutter config --enable-windows-desktop".');
|
||||
}
|
||||
if (!globals.platform.isWindows) {
|
||||
throwToolExit('"build windows" only supported on Windows hosts.');
|
||||
|
@ -46,10 +46,10 @@ class BuildWindowsUwpCommand extends BuildSubCommand {
|
||||
final FlutterProject flutterProject = FlutterProject.current();
|
||||
final BuildInfo buildInfo = await getBuildInfo();
|
||||
if (!featureFlags.isWindowsUwpEnabled) {
|
||||
throwToolExit('"build windows" is not currently supported.');
|
||||
throwToolExit('"build winuwp" is not currently supported.');
|
||||
}
|
||||
if (!globals.platform.isWindows) {
|
||||
throwToolExit('"build windows" only supported on Windows hosts.');
|
||||
throwToolExit('"build winuwp" only supported on Windows hosts.');
|
||||
}
|
||||
displayNullSafetyMode(buildInfo);
|
||||
await buildWindowsUwp(
|
||||
|
@ -130,7 +130,7 @@ void main() {
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['build', 'linux', '--no-pub']
|
||||
), throwsToolExit());
|
||||
), throwsToolExit(message: '"build linux" only supported on Linux hosts.'));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => notLinuxPlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
@ -138,6 +138,20 @@ void main() {
|
||||
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('Linux build fails when feature is disabled', () async {
|
||||
final BuildCommand command = BuildCommand();
|
||||
setUpMockProjectFilesForBuild();
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['build', 'linux', '--no-pub']
|
||||
), throwsToolExit(message: '"build linux" is not currently supported. To enable, run "flutter config --enable-linux-desktop".'));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => linuxPlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: false),
|
||||
});
|
||||
|
||||
testUsingContext('Linux build invokes CMake and ninja, and writes temporary files', () async {
|
||||
final BuildCommand command = BuildCommand();
|
||||
processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
|
@ -131,13 +131,12 @@ void main() {
|
||||
testUsingContext('macOS build fails on non-macOS platform', () async {
|
||||
final BuildCommand command = BuildCommand();
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file('.packages').createSync();
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart'))
|
||||
.createSync(recursive: true);
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['build', 'macos', '--no-pub']
|
||||
), throwsToolExit());
|
||||
), throwsToolExit(message: '"build macos" only supported on macOS hosts.'));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => notMacosPlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
@ -145,6 +144,22 @@ void main() {
|
||||
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('macOS build fails when feature is disabled', () async {
|
||||
final BuildCommand command = BuildCommand();
|
||||
fileSystem.file('pubspec.yaml').createSync();
|
||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart'))
|
||||
.createSync(recursive: true);
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['build', 'macos', '--no-pub']
|
||||
), throwsToolExit(message: '"build macos" is not currently supported. To enable, run "flutter config --enable-macos-desktop".'));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => macosPlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: false),
|
||||
});
|
||||
|
||||
testUsingContext('macOS build forwards error stdout to status logger error', () async {
|
||||
final BuildCommand command = BuildCommand();
|
||||
createMinimalMockProjectFiles();
|
||||
|
@ -87,7 +87,7 @@ void main() {
|
||||
|
||||
expect(
|
||||
() => runner.run(<String>['build', 'web']),
|
||||
throwsToolExit(),
|
||||
throwsToolExit(message: '"build web" is not currently supported. To enable, run "flutter config --enable-web".')
|
||||
);
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => fakePlatform,
|
||||
|
@ -175,7 +175,7 @@ void main() {
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['windows', '--no-pub']
|
||||
), throwsToolExit());
|
||||
), throwsToolExit(message: '"build windows" only supported on Windows hosts.'));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => notWindowsPlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
@ -183,6 +183,22 @@ void main() {
|
||||
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('Windows build fails when feature is disabled', () async {
|
||||
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath);
|
||||
final BuildWindowsCommand command = BuildWindowsCommand()
|
||||
..visualStudioOverride = fakeVisualStudio;
|
||||
setUpMockProjectFilesForBuild();
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['windows', '--no-pub']
|
||||
), throwsToolExit(message: '"build windows" is not currently supported. To enable, run "flutter config --enable-windows-desktop".'));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => windowsPlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: false),
|
||||
});
|
||||
|
||||
testUsingContext('Windows build does not spew stdout to status logger', () async {
|
||||
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath);
|
||||
final BuildWindowsCommand command = BuildWindowsCommand()
|
||||
@ -474,6 +490,22 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier
|
||||
FeatureFlags: () => TestFeatureFlags(isWindowsUwpEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('Windows UWP uild fails on non windows platform', () async {
|
||||
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath);
|
||||
final BuildWindowsUwpCommand command = BuildWindowsUwpCommand()
|
||||
..visualStudioOverride = fakeVisualStudio;
|
||||
setUpMockProjectFilesForBuild();
|
||||
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['winuwp', '--no-pub']
|
||||
), throwsToolExit(message: '"build winuwp" only supported on Windows hosts.'));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => notWindowsPlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
FeatureFlags: () => TestFeatureFlags(isWindowsUwpEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('Windows UWP build fails when the project version is out of date', () async {
|
||||
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath);
|
||||
final BuildWindowsUwpCommand command = BuildWindowsUwpCommand()
|
||||
@ -491,6 +523,24 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier
|
||||
FeatureFlags: () => TestFeatureFlags(isWindowsUwpEnabled: true),
|
||||
});
|
||||
|
||||
testUsingContext('Windows UWP build fails when feature is disabled', () async {
|
||||
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath);
|
||||
final BuildWindowsUwpCommand command = BuildWindowsUwpCommand()
|
||||
..visualStudioOverride = fakeVisualStudio;
|
||||
setUpMockProjectFilesForBuild();
|
||||
|
||||
// This message should include 'To enable, run "flutter config --enable-windows-uwp-desktop"."
|
||||
// once the `windowsUwpEmbedding` feature is available on all platforms.
|
||||
expect(createTestCommandRunner(command).run(
|
||||
const <String>['winuwp', '--no-pub']
|
||||
), throwsToolExit(message: RegExp(r'"build winuwp" is not currently supported\.$')));
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => windowsPlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
FeatureFlags: () => TestFeatureFlags(isWindowsUwpEnabled: false),
|
||||
});
|
||||
|
||||
testUsingContext('Windows UWP build fails after writing Cmake file', () async {
|
||||
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath);
|
||||
final BuildWindowsUwpCommand command = BuildWindowsUwpCommand()
|
||||
|
Loading…
x
Reference in New Issue
Block a user