|
|
|
|
@@ -7,12 +7,10 @@ import 'package:file_testing/file_testing.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/cache.dart';
|
|
|
|
|
import 'package:flutter_tools/src/commands/build_windows.dart';
|
|
|
|
|
import 'package:flutter_tools/src/features.dart';
|
|
|
|
|
import 'package:flutter_tools/src/reporting/reporting.dart';
|
|
|
|
|
import 'package:flutter_tools/src/windows/build_windows.dart';
|
|
|
|
|
import 'package:flutter_tools/src/windows/visual_studio.dart';
|
|
|
|
|
import 'package:test/fake.dart';
|
|
|
|
|
import 'package:unified_analytics/unified_analytics.dart';
|
|
|
|
|
@@ -83,7 +81,6 @@ void main() {
|
|
|
|
|
FakeCommand cmakeGenerationCommand({
|
|
|
|
|
void Function()? onRun,
|
|
|
|
|
String generator = _defaultGenerator,
|
|
|
|
|
TargetPlatform targetPlatform = TargetPlatform.windows_x64,
|
|
|
|
|
}) {
|
|
|
|
|
return FakeCommand(
|
|
|
|
|
command: <String>[
|
|
|
|
|
@@ -95,7 +92,7 @@ void main() {
|
|
|
|
|
'-G',
|
|
|
|
|
generator,
|
|
|
|
|
'-A',
|
|
|
|
|
getCmakeWindowsArch(targetPlatform),
|
|
|
|
|
'x64',
|
|
|
|
|
'-DFLUTTER_TARGET_PLATFORM=windows-x64',
|
|
|
|
|
],
|
|
|
|
|
onRun: onRun,
|
|
|
|
|
@@ -129,7 +126,7 @@ void main() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build fails when there is no cmake path', () async {
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = FakeVisualStudio(cmakePath: null);
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -145,7 +142,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build fails when there is no windows project', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockCoreProjectFiles();
|
|
|
|
|
|
|
|
|
|
@@ -163,7 +160,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build fails on non windows platform', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -179,7 +176,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build fails when feature is disabled', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -195,7 +192,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build does not spew stdout to status logger', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -220,7 +217,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build sends timing events', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -260,7 +257,7 @@ void main() {
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build extracts errors from stdout', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -318,7 +315,7 @@ C:\foo\windows\x64\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identif
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows verbose build sets VERBOSE_SCRIPT_LOGGING', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -344,7 +341,7 @@ C:\foo\windows\x64\runner\main.cpp(17,1): error C2065: 'Baz': undeclared identif
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build works around CMake generation bug', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(displayVersion: '17.1.0');
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -481,7 +478,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build invokes build and writes generated files', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -551,7 +548,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows profile build passes Profile configuration', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -574,7 +571,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
const String generator = 'A different generator';
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio(
|
|
|
|
|
cmakeGenerator: generator);
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -595,7 +592,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
|
|
|
|
|
testUsingContext("Windows build uses pubspec's version", () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -641,7 +638,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build uses build-name and build-number', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -685,7 +682,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build build-name overrides pubspec', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -732,7 +729,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build build-number overrides pubspec', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -779,7 +776,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build build-name and build-number override pubspec', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -827,7 +824,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build warns on non-numeric build-number', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -877,7 +874,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
|
|
|
|
|
testUsingContext('Windows build warns on complex build-number', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -926,14 +923,14 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testUsingContext('hidden when not enabled on Windows host', () {
|
|
|
|
|
expect(BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils()).hidden, true);
|
|
|
|
|
expect(BuildWindowsCommand(logger: BufferLogger.test()).hidden, true);
|
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
|
FeatureFlags: () => TestFeatureFlags(),
|
|
|
|
|
Platform: () => windowsPlatform,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testUsingContext('Not hidden when enabled and on Windows host', () {
|
|
|
|
|
expect(BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils()).hidden, false);
|
|
|
|
|
expect(BuildWindowsCommand(logger: BufferLogger.test()).hidden, false);
|
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
|
FeatureFlags: () => TestFeatureFlags(isWindowsEnabled: true),
|
|
|
|
|
Platform: () => windowsPlatform,
|
|
|
|
|
@@ -941,7 +938,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
|
|
|
|
|
testUsingContext('Performs code size analysis and sends analytics', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
@@ -997,7 +994,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
// is resolved on the VS side, we can allow these paths again
|
|
|
|
|
testUsingContext('Test bad path characters', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
fileSystem.currentDirectory = fileSystem.directory("test_'path")
|
|
|
|
|
..createSync();
|
|
|
|
|
@@ -1024,7 +1021,7 @@ if %errorlevel% neq 0 goto :VCEnd</Command>
|
|
|
|
|
// And tests the case where stdout contains the error about missing assets
|
|
|
|
|
testUsingContext('Windows build extracts errors related to pubspec.yaml from stdout', () async {
|
|
|
|
|
final FakeVisualStudio fakeVisualStudio = FakeVisualStudio();
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test(), operatingSystemUtils: FakeOperatingSystemUtils())
|
|
|
|
|
final BuildWindowsCommand command = BuildWindowsCommand(logger: BufferLogger.test())
|
|
|
|
|
..visualStudioOverride = fakeVisualStudio;
|
|
|
|
|
setUpMockProjectFilesForBuild();
|
|
|
|
|
|
|
|
|
|
|