Unverified Commit 1a36c184 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Tell user how to enable available but disabled features (#79977)

parent cf27be38
...@@ -68,7 +68,7 @@ class BuildLinuxCommand extends BuildSubCommand { ...@@ -68,7 +68,7 @@ class BuildLinuxCommand extends BuildSubCommand {
!= getNameForTargetPlatformArch(targetPlatform); != getNameForTargetPlatformArch(targetPlatform);
if (!featureFlags.isLinuxEnabled) { 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) { if (!globals.platform.isLinux) {
throwToolExit('"build linux" only supported on Linux hosts.'); throwToolExit('"build linux" only supported on Linux hosts.');
......
...@@ -44,7 +44,7 @@ class BuildMacosCommand extends BuildSubCommand { ...@@ -44,7 +44,7 @@ class BuildMacosCommand extends BuildSubCommand {
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
if (!featureFlags.isMacOSEnabled) { 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) { if (!globals.platform.isMacOS) {
throwToolExit('"build macos" only supported on macOS hosts.'); throwToolExit('"build macos" only supported on macOS hosts.');
......
...@@ -79,7 +79,7 @@ class BuildWebCommand extends BuildSubCommand { ...@@ -79,7 +79,7 @@ class BuildWebCommand extends BuildSubCommand {
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
if (!featureFlags.isWebEnabled) { 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 FlutterProject flutterProject = FlutterProject.current();
final String target = stringArg('target'); final String target = stringArg('target');
......
...@@ -46,7 +46,7 @@ class BuildWindowsCommand extends BuildSubCommand { ...@@ -46,7 +46,7 @@ class BuildWindowsCommand extends BuildSubCommand {
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
if (!featureFlags.isWindowsEnabled) { 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) { if (!globals.platform.isWindows) {
throwToolExit('"build windows" only supported on Windows hosts.'); throwToolExit('"build windows" only supported on Windows hosts.');
......
...@@ -46,10 +46,10 @@ class BuildWindowsUwpCommand extends BuildSubCommand { ...@@ -46,10 +46,10 @@ class BuildWindowsUwpCommand extends BuildSubCommand {
final FlutterProject flutterProject = FlutterProject.current(); final FlutterProject flutterProject = FlutterProject.current();
final BuildInfo buildInfo = await getBuildInfo(); final BuildInfo buildInfo = await getBuildInfo();
if (!featureFlags.isWindowsUwpEnabled) { if (!featureFlags.isWindowsUwpEnabled) {
throwToolExit('"build windows" is not currently supported.'); throwToolExit('"build winuwp" is not currently supported.');
} }
if (!globals.platform.isWindows) { if (!globals.platform.isWindows) {
throwToolExit('"build windows" only supported on Windows hosts.'); throwToolExit('"build winuwp" only supported on Windows hosts.');
} }
displayNullSafetyMode(buildInfo); displayNullSafetyMode(buildInfo);
await buildWindowsUwp( await buildWindowsUwp(
......
...@@ -130,7 +130,7 @@ void main() { ...@@ -130,7 +130,7 @@ void main() {
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['build', 'linux', '--no-pub'] const <String>['build', 'linux', '--no-pub']
), throwsToolExit()); ), throwsToolExit(message: '"build linux" only supported on Linux hosts.'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => notLinuxPlatform, Platform: () => notLinuxPlatform,
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
...@@ -138,6 +138,20 @@ void main() { ...@@ -138,6 +138,20 @@ void main() {
FeatureFlags: () => TestFeatureFlags(isLinuxEnabled: true), 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 { testUsingContext('Linux build invokes CMake and ninja, and writes temporary files', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
processManager = FakeProcessManager.list(<FakeCommand>[ processManager = FakeProcessManager.list(<FakeCommand>[
......
...@@ -131,13 +131,12 @@ void main() { ...@@ -131,13 +131,12 @@ void main() {
testUsingContext('macOS build fails on non-macOS platform', () async { testUsingContext('macOS build fails on non-macOS platform', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
fileSystem.file('pubspec.yaml').createSync(); fileSystem.file('pubspec.yaml').createSync();
fileSystem.file('.packages').createSync();
fileSystem.file(fileSystem.path.join('lib', 'main.dart')) fileSystem.file(fileSystem.path.join('lib', 'main.dart'))
.createSync(recursive: true); .createSync(recursive: true);
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['build', 'macos', '--no-pub'] const <String>['build', 'macos', '--no-pub']
), throwsToolExit()); ), throwsToolExit(message: '"build macos" only supported on macOS hosts.'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => notMacosPlatform, Platform: () => notMacosPlatform,
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
...@@ -145,6 +144,22 @@ void main() { ...@@ -145,6 +144,22 @@ void main() {
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true), 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 { testUsingContext('macOS build forwards error stdout to status logger error', () async {
final BuildCommand command = BuildCommand(); final BuildCommand command = BuildCommand();
createMinimalMockProjectFiles(); createMinimalMockProjectFiles();
......
...@@ -87,7 +87,7 @@ void main() { ...@@ -87,7 +87,7 @@ void main() {
expect( expect(
() => runner.run(<String>['build', 'web']), () => runner.run(<String>['build', 'web']),
throwsToolExit(), throwsToolExit(message: '"build web" is not currently supported. To enable, run "flutter config --enable-web".')
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => fakePlatform, Platform: () => fakePlatform,
......
...@@ -175,7 +175,7 @@ void main() { ...@@ -175,7 +175,7 @@ void main() {
expect(createTestCommandRunner(command).run( expect(createTestCommandRunner(command).run(
const <String>['windows', '--no-pub'] const <String>['windows', '--no-pub']
), throwsToolExit()); ), throwsToolExit(message: '"build windows" only supported on Windows hosts.'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => notWindowsPlatform, Platform: () => notWindowsPlatform,
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
...@@ -183,6 +183,22 @@ void main() { ...@@ -183,6 +183,22 @@ void main() {
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true), 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 { testUsingContext('Windows build does not spew stdout to status logger', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath); final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath);
final BuildWindowsCommand command = BuildWindowsCommand() final BuildWindowsCommand command = BuildWindowsCommand()
...@@ -474,6 +490,22 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier ...@@ -474,6 +490,22 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier
FeatureFlags: () => TestFeatureFlags(isWindowsUwpEnabled: true), 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 { testUsingContext('Windows UWP build fails when the project version is out of date', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath); final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath);
final BuildWindowsUwpCommand command = BuildWindowsUwpCommand() final BuildWindowsUwpCommand command = BuildWindowsUwpCommand()
...@@ -491,6 +523,24 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier ...@@ -491,6 +523,24 @@ C:\foo\windows\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identifier
FeatureFlags: () => TestFeatureFlags(isWindowsUwpEnabled: true), 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 { testUsingContext('Windows UWP build fails after writing Cmake file', () async {
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath); final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(cmakePath);
final BuildWindowsUwpCommand command = BuildWindowsUwpCommand() final BuildWindowsUwpCommand command = BuildWindowsUwpCommand()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment