Reduce usage of testUsingContext (#131078)
Part of https://github.com/flutter/flutter/issues/47161
This commit is contained in:
parent
f2ba0a2b0a
commit
43afac1e29
@ -4,9 +4,9 @@
|
||||
|
||||
import 'package:pub_semver/pub_semver.dart';
|
||||
|
||||
import 'base/logger.dart';
|
||||
import 'build_info.dart';
|
||||
import 'cmake_project.dart';
|
||||
import 'globals.dart' as globals;
|
||||
|
||||
/// Extracts the `BINARY_NAME` from a project's CMake file.
|
||||
///
|
||||
@ -41,12 +41,12 @@ String _determineVersionString(CmakeBasedProject project, BuildInfo buildInfo) {
|
||||
: buildName;
|
||||
}
|
||||
|
||||
Version _determineVersion(CmakeBasedProject project, BuildInfo buildInfo) {
|
||||
Version _determineVersion(CmakeBasedProject project, BuildInfo buildInfo, Logger logger) {
|
||||
final String version = _determineVersionString(project, buildInfo);
|
||||
try {
|
||||
return Version.parse(version);
|
||||
} on FormatException {
|
||||
globals.printWarning('Warning: could not parse version $version, defaulting to 1.0.0.');
|
||||
logger.printWarning('Warning: could not parse version $version, defaulting to 1.0.0.');
|
||||
|
||||
return Version(1, 0, 0);
|
||||
}
|
||||
@ -74,25 +74,27 @@ void writeGeneratedCmakeConfig(
|
||||
String flutterRoot,
|
||||
CmakeBasedProject project,
|
||||
BuildInfo buildInfo,
|
||||
Map<String, String> environment) {
|
||||
Map<String, String> environment,
|
||||
Logger logger,
|
||||
) {
|
||||
// Only a limited set of variables are needed by the CMake files themselves,
|
||||
// the rest are put into a list to pass to the re-entrant build step.
|
||||
final String escapedFlutterRoot = _escapeBackslashes(flutterRoot);
|
||||
final String escapedProjectDir = _escapeBackslashes(project.parent.directory.path);
|
||||
|
||||
final Version version = _determineVersion(project, buildInfo);
|
||||
final Version version = _determineVersion(project, buildInfo, logger);
|
||||
final int? buildVersion = _tryDetermineBuildVersion(version);
|
||||
|
||||
// Since complex Dart build identifiers cannot be converted into integers,
|
||||
// different Dart versions may be converted into the same Windows numeric version.
|
||||
// Warn the user as some Windows installers, like MSI, don't update files if their versions are equal.
|
||||
if (buildVersion == null && project is WindowsProject) {
|
||||
final String buildIdentifier = version.build.join('.');
|
||||
globals.printWarning(
|
||||
'Warning: build identifier $buildIdentifier in version $version is not numeric '
|
||||
'and cannot be converted into a Windows build version number. Defaulting to 0.\n'
|
||||
'This may cause issues with Windows installers.'
|
||||
);
|
||||
final String buildIdentifier = version.build.join('.');
|
||||
logger.printWarning(
|
||||
'Warning: build identifier $buildIdentifier in version $version is not numeric '
|
||||
'and cannot be converted into a Windows build version number. Defaulting to 0.\n'
|
||||
'This may cause issues with Windows installers.'
|
||||
);
|
||||
}
|
||||
|
||||
final StringBuffer buffer = StringBuffer('''
|
||||
|
@ -2,8 +2,10 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
|
||||
import '../base/analyze_size.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/os.dart';
|
||||
import '../build_info.dart';
|
||||
import '../cache.dart';
|
||||
@ -83,18 +85,20 @@ class BuildLinuxCommand extends BuildSubCommand {
|
||||
'Cross-build from Linux x64 host to Linux arm64 target is not currently supported.');
|
||||
}
|
||||
displayNullSafetyMode(buildInfo);
|
||||
final Logger logger = globals.logger;
|
||||
await buildLinux(
|
||||
flutterProject.linux,
|
||||
buildInfo,
|
||||
target: targetFile,
|
||||
sizeAnalyzer: SizeAnalyzer(
|
||||
fileSystem: globals.fs,
|
||||
logger: globals.logger,
|
||||
logger: logger,
|
||||
flutterUsage: globals.flutterUsage,
|
||||
),
|
||||
needCrossBuild: needCrossBuild,
|
||||
targetPlatform: targetPlatform,
|
||||
targetSysroot: stringArg('target-sysroot')!,
|
||||
logger: logger,
|
||||
);
|
||||
return FlutterCommandResult.success();
|
||||
}
|
||||
|
@ -29,12 +29,13 @@ final RegExp errorMatcher = RegExp(r'(?:(?:.*:\d+:\d+|clang):\s)?(fatal\s)?(?:er
|
||||
Future<void> buildLinux(
|
||||
LinuxProject linuxProject,
|
||||
BuildInfo buildInfo, {
|
||||
String? target,
|
||||
SizeAnalyzer? sizeAnalyzer,
|
||||
bool needCrossBuild = false,
|
||||
required TargetPlatform targetPlatform,
|
||||
String targetSysroot = '/',
|
||||
}) async {
|
||||
String? target,
|
||||
SizeAnalyzer? sizeAnalyzer,
|
||||
bool needCrossBuild = false,
|
||||
required TargetPlatform targetPlatform,
|
||||
String targetSysroot = '/',
|
||||
required Logger logger,
|
||||
}) async {
|
||||
target ??= 'lib/main.dart';
|
||||
if (!linuxProject.cmakeFile.existsSync()) {
|
||||
throwToolExit('No Linux desktop project configured. See '
|
||||
@ -43,7 +44,7 @@ Future<void> buildLinux(
|
||||
}
|
||||
|
||||
final List<ProjectMigrator> migrators = <ProjectMigrator>[
|
||||
CmakeCustomCommandMigration(linuxProject, globals.logger),
|
||||
CmakeCustomCommandMigration(linuxProject, logger),
|
||||
];
|
||||
|
||||
final ProjectMigration migration = ProjectMigration(migrators);
|
||||
@ -59,11 +60,11 @@ Future<void> buildLinux(
|
||||
environmentConfig['FLUTTER_ENGINE'] = globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath));
|
||||
environmentConfig['LOCAL_ENGINE'] = localEngineInfo.localEngineName;
|
||||
}
|
||||
writeGeneratedCmakeConfig(Cache.flutterRoot!, linuxProject, buildInfo, environmentConfig);
|
||||
writeGeneratedCmakeConfig(Cache.flutterRoot!, linuxProject, buildInfo, environmentConfig, logger);
|
||||
|
||||
createPluginSymlinks(linuxProject.parent);
|
||||
|
||||
final Status status = globals.logger.startProgress(
|
||||
final Status status = logger.startProgress(
|
||||
'Building Linux application...',
|
||||
);
|
||||
try {
|
||||
@ -97,13 +98,13 @@ Future<void> buildLinux(
|
||||
.childDirectory('.flutter-devtools'), 'linux-code-size-analysis', 'json',
|
||||
)..writeAsStringSync(jsonEncode(output));
|
||||
// This message is used as a sentinel in analyze_apk_size_test.dart
|
||||
globals.printStatus(
|
||||
logger.printStatus(
|
||||
'A summary of your Linux bundle analysis can be found at: ${outputFile.path}',
|
||||
);
|
||||
|
||||
// DevTools expects a file path relative to the .flutter-devtools/ dir.
|
||||
final String relativeAppSizePath = outputFile.path.split('.flutter-devtools/').last.trim();
|
||||
globals.printStatus(
|
||||
logger.printStatus(
|
||||
'\nTo analyze your app size in Dart DevTools, run the following command:\n'
|
||||
'dart devtools --appSizeBase=$relativeAppSizePath'
|
||||
);
|
||||
|
@ -25,6 +25,7 @@ class LinuxDevice extends DesktopDevice {
|
||||
required FileSystem fileSystem,
|
||||
required OperatingSystemUtils operatingSystemUtils,
|
||||
}) : _operatingSystemUtils = operatingSystemUtils,
|
||||
_logger = logger,
|
||||
super(
|
||||
'linux',
|
||||
platformType: PlatformType.linux,
|
||||
@ -36,6 +37,7 @@ class LinuxDevice extends DesktopDevice {
|
||||
);
|
||||
|
||||
final OperatingSystemUtils _operatingSystemUtils;
|
||||
final Logger _logger;
|
||||
|
||||
@override
|
||||
bool isSupported() => true;
|
||||
@ -66,6 +68,7 @@ class LinuxDevice extends DesktopDevice {
|
||||
buildInfo,
|
||||
target: mainPath,
|
||||
targetPlatform: await targetPlatform,
|
||||
logger: _logger,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,9 @@ class HotEvent extends UsageEvent {
|
||||
this.scannedSourcesCount,
|
||||
this.reassembleTimeInMs,
|
||||
this.reloadVMTimeInMs,
|
||||
}) : super('hot', parameter, flutterUsage: globals.flutterUsage);
|
||||
// TODO(fujino): make this required
|
||||
Usage? usage,
|
||||
}) : super('hot', parameter, flutterUsage: usage ?? globals.flutterUsage);
|
||||
|
||||
final String? reason;
|
||||
final String targetPlatform;
|
||||
|
@ -950,6 +950,7 @@ class HotRunner extends ResidentRunner {
|
||||
sdkName,
|
||||
emulator,
|
||||
reason,
|
||||
globals.flutterUsage,
|
||||
);
|
||||
if (result.code != 0) {
|
||||
return result;
|
||||
@ -1172,6 +1173,7 @@ typedef ReloadSourcesHelper = Future<OperationResult> Function(
|
||||
String? sdkName,
|
||||
bool? emulator,
|
||||
String? reason,
|
||||
Usage usage,
|
||||
);
|
||||
|
||||
@visibleForTesting
|
||||
@ -1184,6 +1186,7 @@ Future<OperationResult> defaultReloadSourcesHelper(
|
||||
String? sdkName,
|
||||
bool? emulator,
|
||||
String? reason,
|
||||
Usage usage,
|
||||
) async {
|
||||
final Stopwatch vmReloadTimer = Stopwatch()..start();
|
||||
const String entryPath = 'main.dart.incremental.dill';
|
||||
@ -1223,6 +1226,7 @@ Future<OperationResult> defaultReloadSourcesHelper(
|
||||
fullRestart: false,
|
||||
reason: reason,
|
||||
fastReassemble: false,
|
||||
usage: usage,
|
||||
).send();
|
||||
// Reset devFS lastCompileTime to ensure the file will still be marked
|
||||
// as dirty on subsequent reloads.
|
||||
|
@ -242,7 +242,7 @@ void _writeGeneratedFlutterConfig(
|
||||
environment['FLUTTER_ENGINE'] = globals.fs.path.dirname(globals.fs.path.dirname(engineOutPath));
|
||||
environment['LOCAL_ENGINE'] = localEngineInfo.localEngineName;
|
||||
}
|
||||
writeGeneratedCmakeConfig(Cache.flutterRoot!, windowsProject, buildInfo, environment);
|
||||
writeGeneratedCmakeConfig(Cache.flutterRoot!, windowsProject, buildInfo, environment, globals.logger);
|
||||
}
|
||||
|
||||
// Works around the Visual Studio 17.1.0 CMake bug described in
|
||||
|
@ -11,23 +11,20 @@ import 'package:flutter_tools/src/cmake.dart';
|
||||
import 'package:flutter_tools/src/project.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
|
||||
const String _kTestFlutterRoot = '/flutter';
|
||||
const String _kTestWindowsFlutterRoot = r'C:\flutter';
|
||||
|
||||
void main() {
|
||||
late FileSystem fileSystem;
|
||||
late ProcessManager processManager;
|
||||
late BufferLogger logger;
|
||||
|
||||
setUp(() {
|
||||
processManager = FakeProcessManager.any();
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
logger = BufferLogger.test();
|
||||
});
|
||||
|
||||
testUsingContext('parses executable name from cmake file', () async {
|
||||
testWithoutContext('parses executable name from cmake file', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
|
||||
|
||||
@ -38,24 +35,18 @@ void main() {
|
||||
final String? name = getCmakeExecutableName(cmakeProject);
|
||||
|
||||
expect(name, 'hello');
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('defaults executable name to null if cmake config does not exist', () async {
|
||||
testWithoutContext('defaults executable name to null if cmake config does not exist', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
|
||||
|
||||
final String? name = getCmakeExecutableName(cmakeProject);
|
||||
|
||||
expect(name, isNull);
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('generates config', () async {
|
||||
testWithoutContext('generates config', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
|
||||
const BuildInfo buildInfo = BuildInfo(BuildMode.release, null, treeShakeIcons: false);
|
||||
@ -66,6 +57,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
final File cmakeConfig = cmakeProject.generatedCmakeConfigFile;
|
||||
@ -91,12 +83,9 @@ void main() {
|
||||
r' "PROJECT_DIR=/"',
|
||||
r')',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('config escapes backslashes', () async {
|
||||
testWithoutContext('config escapes backslashes', () async {
|
||||
fileSystem = MemoryFileSystem.test(style: FileSystemStyle.windows);
|
||||
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
@ -112,6 +101,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
final File cmakeConfig = cmakeProject.generatedCmakeConfigFile;
|
||||
@ -138,12 +128,9 @@ void main() {
|
||||
r' "TEST=hello\\world"',
|
||||
r')',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('generated config uses pubspec version', () async {
|
||||
testWithoutContext('generated config uses pubspec version', () async {
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync('version: 1.2.3+4');
|
||||
@ -158,6 +145,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
final File cmakeConfig = cmakeProject.generatedCmakeConfigFile;
|
||||
@ -173,12 +161,9 @@ void main() {
|
||||
'set(FLUTTER_VERSION_PATCH 3 PARENT_SCOPE)',
|
||||
'set(FLUTTER_VERSION_BUILD 4 PARENT_SCOPE)',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('generated config uses build name', () async {
|
||||
testWithoutContext('generated config uses build name', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
|
||||
const BuildInfo buildInfo = BuildInfo(
|
||||
@ -194,6 +179,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
final File cmakeConfig = cmakeProject.generatedCmakeConfigFile;
|
||||
@ -209,12 +195,9 @@ void main() {
|
||||
'set(FLUTTER_VERSION_PATCH 3 PARENT_SCOPE)',
|
||||
'set(FLUTTER_VERSION_BUILD 0 PARENT_SCOPE)',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('generated config uses build number', () async {
|
||||
testWithoutContext('generated config uses build number', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
|
||||
const BuildInfo buildInfo = BuildInfo(
|
||||
@ -230,6 +213,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
final File cmakeConfig = cmakeProject.generatedCmakeConfigFile;
|
||||
@ -245,12 +229,9 @@ void main() {
|
||||
'set(FLUTTER_VERSION_PATCH 0 PARENT_SCOPE)',
|
||||
'set(FLUTTER_VERSION_BUILD 4 PARENT_SCOPE)',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('generated config uses build name and build number', () async {
|
||||
testWithoutContext('generated config uses build name and build number', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
|
||||
const BuildInfo buildInfo = BuildInfo(
|
||||
@ -267,6 +248,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
final File cmakeConfig = cmakeProject.generatedCmakeConfigFile;
|
||||
@ -282,12 +264,9 @@ void main() {
|
||||
'set(FLUTTER_VERSION_PATCH 3 PARENT_SCOPE)',
|
||||
'set(FLUTTER_VERSION_BUILD 4 PARENT_SCOPE)',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('generated config uses build name over pubspec version', () async {
|
||||
testWithoutContext('generated config uses build name over pubspec version', () async {
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync('version: 9.9.9+9');
|
||||
@ -307,6 +286,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
final File cmakeConfig = cmakeProject.generatedCmakeConfigFile;
|
||||
@ -322,12 +302,9 @@ void main() {
|
||||
'set(FLUTTER_VERSION_PATCH 3 PARENT_SCOPE)',
|
||||
'set(FLUTTER_VERSION_BUILD 0 PARENT_SCOPE)',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('generated config uses build number over pubspec version', () async {
|
||||
testWithoutContext('generated config uses build number over pubspec version', () async {
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync('version: 1.2.3+4');
|
||||
@ -347,6 +324,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
final File cmakeConfig = cmakeProject.generatedCmakeConfigFile;
|
||||
@ -362,12 +340,9 @@ void main() {
|
||||
'set(FLUTTER_VERSION_PATCH 3 PARENT_SCOPE)',
|
||||
'set(FLUTTER_VERSION_BUILD 5 PARENT_SCOPE)',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('generated config uses build name and build number over pubspec version', () async {
|
||||
testWithoutContext('generated config uses build name and build number over pubspec version', () async {
|
||||
fileSystem.file('pubspec.yaml')
|
||||
..createSync()
|
||||
..writeAsStringSync('version: 9.9.9+9');
|
||||
@ -388,6 +363,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
final File cmakeConfig = cmakeProject.generatedCmakeConfigFile;
|
||||
@ -403,12 +379,9 @@ void main() {
|
||||
'set(FLUTTER_VERSION_PATCH 3 PARENT_SCOPE)',
|
||||
'set(FLUTTER_VERSION_BUILD 4 PARENT_SCOPE)',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
});
|
||||
|
||||
testUsingContext('generated config ignores invalid build name', () async {
|
||||
testWithoutContext('generated config ignores invalid build name', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
|
||||
const BuildInfo buildInfo = BuildInfo(
|
||||
@ -424,6 +397,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
final File cmakeConfig = cmakeProject.generatedCmakeConfigFile;
|
||||
@ -441,13 +415,9 @@ void main() {
|
||||
]));
|
||||
|
||||
expect(logger.warningText, contains('Warning: could not parse version hello.world, defaulting to 1.0.0.'));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
Logger: () => logger,
|
||||
});
|
||||
|
||||
testUsingContext('generated config ignores invalid build number', () async {
|
||||
testWithoutContext('generated config ignores invalid build number', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
|
||||
const BuildInfo buildInfo = BuildInfo(
|
||||
@ -464,6 +434,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
final File cmakeConfig = cmakeProject.generatedCmakeConfigFile;
|
||||
@ -481,13 +452,9 @@ void main() {
|
||||
]));
|
||||
|
||||
expect(logger.warningText, contains('Warning: could not parse version 1.2.3+foo_bar, defaulting to 1.0.0.'));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
Logger: () => logger,
|
||||
});
|
||||
|
||||
testUsingContext('generated config handles non-numeric build number', () async {
|
||||
testWithoutContext('generated config handles non-numeric build number', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
|
||||
const BuildInfo buildInfo = BuildInfo(
|
||||
@ -504,6 +471,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
expect(logger.warningText, isEmpty);
|
||||
@ -521,13 +489,9 @@ void main() {
|
||||
'set(FLUTTER_VERSION_PATCH 3 PARENT_SCOPE)',
|
||||
'set(FLUTTER_VERSION_BUILD 0 PARENT_SCOPE)',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
Logger: () => logger,
|
||||
});
|
||||
|
||||
testUsingContext('generated config handles complex build number', () async {
|
||||
testWithoutContext('generated config handles complex build number', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = _FakeProject.fromFlutter(project);
|
||||
const BuildInfo buildInfo = BuildInfo(
|
||||
@ -544,6 +508,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
expect(logger.warningText, isEmpty);
|
||||
@ -561,13 +526,9 @@ void main() {
|
||||
'set(FLUTTER_VERSION_PATCH 3 PARENT_SCOPE)',
|
||||
'set(FLUTTER_VERSION_BUILD 0 PARENT_SCOPE)',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
Logger: () => logger,
|
||||
});
|
||||
|
||||
testUsingContext('generated config warns on Windows project with non-numeric build number', () async {
|
||||
testWithoutContext('generated config warns on Windows project with non-numeric build number', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = WindowsProject.fromFlutter(project);
|
||||
const BuildInfo buildInfo = BuildInfo(
|
||||
@ -584,6 +545,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
expect(logger.warningText, contains(
|
||||
@ -605,13 +567,9 @@ void main() {
|
||||
'set(FLUTTER_VERSION_PATCH 3 PARENT_SCOPE)',
|
||||
'set(FLUTTER_VERSION_BUILD 0 PARENT_SCOPE)',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
Logger: () => logger,
|
||||
});
|
||||
|
||||
testUsingContext('generated config warns on Windows project with complex build number', () async {
|
||||
testWithoutContext('generated config warns on Windows project with complex build number', () async {
|
||||
final FlutterProject project = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||
final CmakeBasedProject cmakeProject = WindowsProject.fromFlutter(project);
|
||||
const BuildInfo buildInfo = BuildInfo(
|
||||
@ -628,6 +586,7 @@ void main() {
|
||||
cmakeProject,
|
||||
buildInfo,
|
||||
environment,
|
||||
logger,
|
||||
);
|
||||
|
||||
expect(logger.warningText, contains(
|
||||
@ -649,10 +608,6 @@ void main() {
|
||||
'set(FLUTTER_VERSION_PATCH 3 PARENT_SCOPE)',
|
||||
'set(FLUTTER_VERSION_BUILD 0 PARENT_SCOPE)',
|
||||
]));
|
||||
}, overrides: <Type, Generator>{
|
||||
FileSystem: () => fileSystem,
|
||||
ProcessManager: () => processManager,
|
||||
Logger: () => logger,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -366,6 +366,7 @@ void main() {
|
||||
String? sdkName,
|
||||
bool? emulator,
|
||||
String? reason,
|
||||
Usage usage,
|
||||
) async {
|
||||
firstReloadDetails['finalLibraryCount'] = 2;
|
||||
firstReloadDetails['receivedLibraryCount'] = 3;
|
||||
|
@ -3,16 +3,18 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/devfs.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/resident_runner.dart';
|
||||
import 'package:flutter_tools/src/run_hot.dart';
|
||||
import 'package:flutter_tools/src/vmservice.dart';
|
||||
import 'package:test/fake.dart';
|
||||
import 'package:vm_service/vm_service.dart' as vm_service;
|
||||
|
||||
import '../src/context.dart';
|
||||
//import '../src/context.dart';
|
||||
import '../src/common.dart';
|
||||
|
||||
void main() {
|
||||
testUsingContext('defaultReloadSourcesHelper() handles empty DeviceReloadReports)', () {
|
||||
testWithoutContext('defaultReloadSourcesHelper() handles empty DeviceReloadReports)', () {
|
||||
defaultReloadSourcesHelper(
|
||||
_FakeHotRunner(),
|
||||
<FlutterDevice?>[_FakeFlutterDevice()],
|
||||
@ -22,6 +24,7 @@ void main() {
|
||||
'flutter-sdk',
|
||||
false,
|
||||
'test-reason',
|
||||
TestUsage(),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user