Commit 7f715628 authored by Jenn Magder's avatar Jenn Magder Committed by Flutter GitHub Bot

Replace FlutterVersion.instance with FlutterVersion context fetch in global.dart (#49462)

parent 7539826d
...@@ -24,7 +24,6 @@ import 'src/reporting/github_template.dart'; ...@@ -24,7 +24,6 @@ import 'src/reporting/github_template.dart';
import 'src/reporting/reporting.dart'; import 'src/reporting/reporting.dart';
import 'src/runner/flutter_command.dart'; import 'src/runner/flutter_command.dart';
import 'src/runner/flutter_command_runner.dart'; import 'src/runner/flutter_command_runner.dart';
import 'src/version.dart';
/// Runs the Flutter tool with support for the specified list of [commands]. /// Runs the Flutter tool with support for the specified list of [commands].
Future<int> run( Future<int> run(
...@@ -57,7 +56,7 @@ Future<int> run( ...@@ -57,7 +56,7 @@ Future<int> run(
onFailure: (String _) => 'en_US', onFailure: (String _) => 'en_US',
); );
String getVersion() => flutterVersion ?? FlutterVersion.instance.getVersionString(redactUnknownBranches: true); String getVersion() => flutterVersion ?? globals.flutterVersion.getVersionString(redactUnknownBranches: true);
Object firstError; Object firstError;
StackTrace firstStackTrace; StackTrace firstStackTrace;
return await runZoned<Future<int>>(() async { return await runZoned<Future<int>>(() async {
......
...@@ -8,7 +8,6 @@ import 'package:quiver/core.dart' show hash2; ...@@ -8,7 +8,6 @@ import 'package:quiver/core.dart' show hash2;
import '../convert.dart' show json; import '../convert.dart' show json;
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../version.dart';
import 'file_system.dart'; import 'file_system.dart';
import 'utils.dart'; import 'utils.dart';
...@@ -123,7 +122,7 @@ class Fingerprint { ...@@ -123,7 +122,7 @@ class Fingerprint {
final Map<String, dynamic> content = castStringKeyedMap(json.decode(jsonData)); final Map<String, dynamic> content = castStringKeyedMap(json.decode(jsonData));
final String version = content['version'] as String; final String version = content['version'] as String;
if (version != FlutterVersion.instance.frameworkRevision) { if (version != globals.flutterVersion.frameworkRevision) {
throw ArgumentError('Incompatible fingerprint version: $version'); throw ArgumentError('Incompatible fingerprint version: $version');
} }
_checksums = castStringKeyedMap(content['files'])?.cast<String,String>() ?? <String, String>{}; _checksums = castStringKeyedMap(content['files'])?.cast<String,String>() ?? <String, String>{};
...@@ -134,7 +133,7 @@ class Fingerprint { ...@@ -134,7 +133,7 @@ class Fingerprint {
Map<String, String> _properties; Map<String, String> _properties;
String toJson() => json.encode(<String, dynamic>{ String toJson() => json.encode(<String, dynamic>{
'version': FlutterVersion.instance.frameworkRevision, 'version': globals.flutterVersion.frameworkRevision,
'properties': _properties, 'properties': _properties,
'files': _checksums, 'files': _checksums,
}); });
......
...@@ -180,7 +180,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand { ...@@ -180,7 +180,7 @@ class BuildIOSFrameworkCommand extends BuildSubCommand {
if (boolArg('cocoapods')) { if (boolArg('cocoapods')) {
// FlutterVersion.instance kicks off git processing which can sometimes fail, so don't try it until needed. // FlutterVersion.instance kicks off git processing which can sometimes fail, so don't try it until needed.
_flutterVersion ??= FlutterVersion.instance; _flutterVersion ??= globals.flutterVersion;
produceFlutterPodspec(mode, modeDirectory); produceFlutterPodspec(mode, modeDirectory);
} else { } else {
// Copy Flutter.framework. // Copy Flutter.framework.
......
...@@ -53,8 +53,8 @@ class ChannelCommand extends FlutterCommand { ...@@ -53,8 +53,8 @@ class ChannelCommand extends FlutterCommand {
Future<void> _listChannels({ bool showAll, bool verbose }) async { Future<void> _listChannels({ bool showAll, bool verbose }) async {
// Beware: currentBranch could contain PII. See getBranchName(). // Beware: currentBranch could contain PII. See getBranchName().
final String currentChannel = FlutterVersion.instance.channel; final String currentChannel = globals.flutterVersion.channel;
final String currentBranch = FlutterVersion.instance.getBranchName(); final String currentBranch = globals.flutterVersion.getBranchName();
final Set<String> seenUnofficialChannels = <String>{}; final Set<String> seenUnofficialChannels = <String>{};
final List<String> rawOutput = <String>[]; final List<String> rawOutput = <String>[];
...@@ -128,7 +128,7 @@ class ChannelCommand extends FlutterCommand { ...@@ -128,7 +128,7 @@ class ChannelCommand extends FlutterCommand {
} }
static Future<void> upgradeChannel() async { static Future<void> upgradeChannel() async {
final String channel = FlutterVersion.instance.channel; final String channel = globals.flutterVersion.channel;
if (FlutterVersion.obsoleteBranches.containsKey(channel)) { if (FlutterVersion.obsoleteBranches.containsKey(channel)) {
final String alternative = FlutterVersion.obsoleteBranches[channel]; final String alternative = FlutterVersion.obsoleteBranches[channel];
globals.printStatus("Transitioning from '$channel' to '$alternative'..."); globals.printStatus("Transitioning from '$channel' to '$alternative'...");
......
...@@ -12,7 +12,6 @@ import '../features.dart'; ...@@ -12,7 +12,6 @@ import '../features.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../reporting/reporting.dart'; import '../reporting/reporting.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
import '../version.dart';
class ConfigCommand extends FlutterCommand { class ConfigCommand extends FlutterCommand {
ConfigCommand({ bool verboseHelp = false }) { ConfigCommand({ bool verboseHelp = false }) {
...@@ -68,7 +67,7 @@ class ConfigCommand extends FlutterCommand { ...@@ -68,7 +67,7 @@ class ConfigCommand extends FlutterCommand {
// List all config settings. for feature flags, include whether they // List all config settings. for feature flags, include whether they
// are available. // are available.
final Map<String, Feature> featuresByName = <String, Feature>{}; final Map<String, Feature> featuresByName = <String, Feature>{};
final String channel = FlutterVersion.instance.channel; final String channel = globals.flutterVersion.channel;
for (final Feature feature in allFeatures) { for (final Feature feature in allFeatures) {
if (feature.configSetting != null) { if (feature.configSetting != null) {
featuresByName[feature.configSetting] = feature; featuresByName[feature.configSetting] = feature;
......
...@@ -25,7 +25,6 @@ import '../project.dart'; ...@@ -25,7 +25,6 @@ import '../project.dart';
import '../reporting/reporting.dart'; import '../reporting/reporting.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
import '../template.dart'; import '../template.dart';
import '../version.dart';
enum _ProjectType { enum _ProjectType {
/// This is the default project with the user-managed host code. /// This is the default project with the user-managed host code.
...@@ -219,7 +218,7 @@ class CreateCommand extends FlutterCommand { ...@@ -219,7 +218,7 @@ class CreateCommand extends FlutterCommand {
} }
/// The hostname for the Flutter docs for the current channel. /// The hostname for the Flutter docs for the current channel.
String get _snippetsHost => FlutterVersion.instance.channel == 'stable' String get _snippetsHost => globals.flutterVersion.channel == 'stable'
? 'docs.flutter.io' ? 'docs.flutter.io'
: 'master-docs.flutter.io'; : 'master-docs.flutter.io';
...@@ -628,8 +627,8 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi ...@@ -628,8 +627,8 @@ To edit platform code in an IDE see https://flutter.dev/developing-packages/#edi
'withPluginHook': withPluginHook, 'withPluginHook': withPluginHook,
'androidLanguage': androidLanguage, 'androidLanguage': androidLanguage,
'iosLanguage': iosLanguage, 'iosLanguage': iosLanguage,
'flutterRevision': FlutterVersion.instance.frameworkRevision, 'flutterRevision': globals.flutterVersion.frameworkRevision,
'flutterChannel': FlutterVersion.instance.channel, 'flutterChannel': globals.flutterVersion.channel,
'web': web, 'web': web,
'macos': macos, 'macos': macos,
'year': DateTime.now().year, 'year': DateTime.now().year,
......
...@@ -9,7 +9,6 @@ import '../cache.dart'; ...@@ -9,7 +9,6 @@ import '../cache.dart';
import '../features.dart'; import '../features.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
import '../version.dart';
class PrecacheCommand extends FlutterCommand { class PrecacheCommand extends FlutterCommand {
PrecacheCommand({bool verboseHelp = false}) { PrecacheCommand({bool verboseHelp = false}) {
...@@ -94,7 +93,7 @@ class PrecacheCommand extends FlutterCommand { ...@@ -94,7 +93,7 @@ class PrecacheCommand extends FlutterCommand {
final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{}; final Set<DevelopmentArtifact> requiredArtifacts = <DevelopmentArtifact>{};
for (final DevelopmentArtifact artifact in DevelopmentArtifact.values) { for (final DevelopmentArtifact artifact in DevelopmentArtifact.values) {
// Don't include unstable artifacts on stable branches. // Don't include unstable artifacts on stable branches.
if (!FlutterVersion.instance.isMaster && artifact.unstable) { if (!globals.flutterVersion.isMaster && artifact.unstable) {
continue; continue;
} }
if (artifact.feature != null && !featureFlags.isEnabled(artifact.feature)) { if (artifact.feature != null && !featureFlags.isEnabled(artifact.feature)) {
......
...@@ -23,7 +23,6 @@ import '../run_cold.dart'; ...@@ -23,7 +23,6 @@ import '../run_cold.dart';
import '../run_hot.dart'; import '../run_hot.dart';
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
import '../tracing.dart'; import '../tracing.dart';
import '../version.dart';
import '../web/web_runner.dart'; import '../web/web_runner.dart';
import 'daemon.dart'; import 'daemon.dart';
...@@ -422,7 +421,7 @@ class RunCommand extends RunCommandBase { ...@@ -422,7 +421,7 @@ class RunCommand extends RunCommandBase {
} }
globals.terminal.usesTerminalUi = true; globals.terminal.usesTerminalUi = true;
if (argResults['dart-flags'] != null && !FlutterVersion.instance.isMaster) { if (argResults['dart-flags'] != null && !globals.flutterVersion.isMaster) {
throw UsageException('--dart-flags is not available on the stable ' throw UsageException('--dart-flags is not available on the stable '
'channel.', null); 'channel.', null);
} }
......
...@@ -55,7 +55,7 @@ class UpgradeCommand extends FlutterCommand { ...@@ -55,7 +55,7 @@ class UpgradeCommand extends FlutterCommand {
boolArg('force'), boolArg('force'),
boolArg('continue'), boolArg('continue'),
GitTagVersion.determine(), GitTagVersion.determine(),
FlutterVersion.instance, globals.flutterVersion,
); );
} }
} }
......
...@@ -603,7 +603,7 @@ class FlutterValidator extends DoctorValidator { ...@@ -603,7 +603,7 @@ class FlutterValidator extends DoctorValidator {
String frameworkVersion; String frameworkVersion;
try { try {
final FlutterVersion version = FlutterVersion.instance; final FlutterVersion version = globals.flutterVersion;
versionChannel = version.channel; versionChannel = version.channel;
frameworkVersion = version.frameworkVersion; frameworkVersion = version.frameworkVersion;
messages.add(ValidationMessage(userMessages.flutterVersion( messages.add(ValidationMessage(userMessages.flutterVersion(
......
...@@ -6,7 +6,6 @@ import 'package:meta/meta.dart'; ...@@ -6,7 +6,6 @@ import 'package:meta/meta.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
import 'version.dart';
/// The current [FeatureFlags] implementation. /// The current [FeatureFlags] implementation.
/// ///
...@@ -45,7 +44,7 @@ class FeatureFlags { ...@@ -45,7 +44,7 @@ class FeatureFlags {
/// ///
/// Prefer using one of the specific getters above instead of this API. /// Prefer using one of the specific getters above instead of this API.
bool isEnabled(Feature feature) { bool isEnabled(Feature feature) {
final String currentChannel = FlutterVersion.instance.channel; final String currentChannel = globals.flutterVersion.channel;
final FeatureChannelSetting featureSetting = feature.getSettingForChannel(currentChannel); final FeatureChannelSetting featureSetting = feature.getSettingForChannel(currentChannel);
if (!featureSetting.available) { if (!featureSetting.available) {
return false; return false;
......
...@@ -15,6 +15,7 @@ import 'base/logger.dart'; ...@@ -15,6 +15,7 @@ import 'base/logger.dart';
import 'base/terminal.dart'; import 'base/terminal.dart';
import 'cache.dart'; import 'cache.dart';
import 'macos/xcode.dart'; import 'macos/xcode.dart';
import 'version.dart';
Logger get logger => context.get<Logger>(); Logger get logger => context.get<Logger>();
Cache get cache => context.get<Cache>(); Cache get cache => context.get<Cache>();
...@@ -42,6 +43,7 @@ const Platform _kLocalPlatform = LocalPlatform(); ...@@ -42,6 +43,7 @@ const Platform _kLocalPlatform = LocalPlatform();
Platform get platform => context.get<Platform>() ?? _kLocalPlatform; Platform get platform => context.get<Platform>() ?? _kLocalPlatform;
Xcode get xcode => context.get<Xcode>(); Xcode get xcode => context.get<Xcode>();
FlutterVersion get flutterVersion => context.get<FlutterVersion>();
/// Display an error level message to the user. Commands should use this if they /// Display an error level message to the user. Commands should use this if they
/// fail in some way. /// fail in some way.
......
...@@ -19,7 +19,6 @@ import 'globals.dart' as globals; ...@@ -19,7 +19,6 @@ import 'globals.dart' as globals;
import 'macos/cocoapods.dart'; import 'macos/cocoapods.dart';
import 'platform_plugins.dart'; import 'platform_plugins.dart';
import 'project.dart'; import 'project.dart';
import 'version.dart';
void _renderTemplateToFile(String template, dynamic context, String filePath) { void _renderTemplateToFile(String template, dynamic context, String filePath) {
final String renderedTemplate = final String renderedTemplate =
...@@ -418,7 +417,7 @@ bool _writeFlutterPluginsList(FlutterProject project, List<Plugin> plugins) { ...@@ -418,7 +417,7 @@ bool _writeFlutterPluginsList(FlutterProject project, List<Plugin> plugins) {
/// https://github.com/flutter/flutter/issues/48918 /// https://github.com/flutter/flutter/issues/48918
result['dependencyGraph'] = _createPluginLegacyDependencyGraph(plugins); result['dependencyGraph'] = _createPluginLegacyDependencyGraph(plugins);
result['date_created'] = systemClock.now().toString(); result['date_created'] = systemClock.now().toString();
result['version'] = flutterVersion.frameworkVersion; result['version'] = globals.flutterVersion.frameworkVersion;
// Only notify if the plugins list has changed. [date_created] will always be different, // Only notify if the plugins list has changed. [date_created] will always be different,
// [version] is not relevant for this check. // [version] is not relevant for this check.
......
...@@ -162,7 +162,7 @@ class _DefaultUsage implements Usage { ...@@ -162,7 +162,7 @@ class _DefaultUsage implements Usage {
String configDirOverride, String configDirOverride,
String logFile, String logFile,
}) { }) {
final FlutterVersion flutterVersion = FlutterVersion.instance; final FlutterVersion flutterVersion = globals.flutterVersion;
final String version = versionOverride ?? flutterVersion.getVersionString(redactUnknownBranches: true); final String version = versionOverride ?? flutterVersion.getVersionString(redactUnknownBranches: true);
final bool suppressEnvFlag = globals.platform.environment['FLUTTER_SUPPRESS_ANALYTICS'] == 'true'; final bool suppressEnvFlag = globals.platform.environment['FLUTTER_SUPPRESS_ANALYTICS'] == 'true';
final String logFilePath = logFile ?? globals.platform.environment['FLUTTER_ANALYTICS_LOG_FILE']; final String logFilePath = logFile ?? globals.platform.environment['FLUTTER_ANALYTICS_LOG_FILE'];
...@@ -367,7 +367,7 @@ class _DefaultUsage implements Usage { ...@@ -367,7 +367,7 @@ class _DefaultUsage implements Usage {
isFirstRun || isFirstRun ||
// Display the welcome message if we are not on master, and if the // Display the welcome message if we are not on master, and if the
// persistent tool state instructs that we should. // persistent tool state instructs that we should.
(!FlutterVersion.instance.isMaster && (!globals.flutterVersion.isMaster &&
(persistentToolState.redisplayWelcomeMessage ?? true))) { (persistentToolState.redisplayWelcomeMessage ?? true))) {
_printWelcome(); _printWelcome();
_printedWelcome = true; _printedWelcome = true;
......
...@@ -24,7 +24,6 @@ import '../device.dart'; ...@@ -24,7 +24,6 @@ import '../device.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../reporting/reporting.dart'; import '../reporting/reporting.dart';
import '../tester/flutter_tester.dart'; import '../tester/flutter_tester.dart';
import '../version.dart';
const String kFlutterRootEnvironmentVariableName = 'FLUTTER_ROOT'; // should point to //flutter/ (root of flutter/flutter repo) const String kFlutterRootEnvironmentVariableName = 'FLUTTER_ROOT'; // should point to //flutter/ (root of flutter/flutter repo)
const String kFlutterEngineEnvironmentVariableName = 'FLUTTER_ENGINE'; // should point to //engine/src/ (root of flutter/engine repo) const String kFlutterEngineEnvironmentVariableName = 'FLUTTER_ENGINE'; // should point to //engine/src/ (root of flutter/engine repo)
...@@ -303,7 +302,7 @@ class FlutterCommandRunner extends CommandRunner<void> { ...@@ -303,7 +302,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
_checkFlutterCopy(); _checkFlutterCopy();
try { try {
await FlutterVersion.instance.ensureVersionFile(); await globals.flutterVersion.ensureVersionFile();
} on FileSystemException catch (e) { } on FileSystemException catch (e) {
globals.printError('Failed to write the version file to the artifact cache: "$e".'); globals.printError('Failed to write the version file to the artifact cache: "$e".');
globals.printError('Please ensure you have permissions in the artifact cache directory.'); globals.printError('Please ensure you have permissions in the artifact cache directory.');
...@@ -311,7 +310,7 @@ class FlutterCommandRunner extends CommandRunner<void> { ...@@ -311,7 +310,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
} }
final bool machineFlag = topLevelResults['machine'] as bool; final bool machineFlag = topLevelResults['machine'] as bool;
if (topLevelResults.command?.name != 'upgrade' && topLevelResults['version-check'] as bool && !machineFlag) { if (topLevelResults.command?.name != 'upgrade' && topLevelResults['version-check'] as bool && !machineFlag) {
await FlutterVersion.instance.checkFlutterVersionFreshness(); await globals.flutterVersion.checkFlutterVersionFreshness();
} }
if (topLevelResults.wasParsed('packages')) { if (topLevelResults.wasParsed('packages')) {
...@@ -325,9 +324,9 @@ class FlutterCommandRunner extends CommandRunner<void> { ...@@ -325,9 +324,9 @@ class FlutterCommandRunner extends CommandRunner<void> {
flutterUsage.sendCommand('version'); flutterUsage.sendCommand('version');
String status; String status;
if (machineFlag) { if (machineFlag) {
status = const JsonEncoder.withIndent(' ').convert(FlutterVersion.instance.toJson()); status = const JsonEncoder.withIndent(' ').convert(globals.flutterVersion.toJson());
} else { } else {
status = FlutterVersion.instance.toString(); status = globals.flutterVersion.toString();
} }
globals.printStatus(status); globals.printStatus(status);
return; return;
......
...@@ -65,7 +65,7 @@ class FlutterTesterDevice extends Device { ...@@ -65,7 +65,7 @@ class FlutterTesterDevice extends Device {
@override @override
Future<String> get sdkNameAndVersion async { Future<String> get sdkNameAndVersion async {
final FlutterVersion flutterVersion = FlutterVersion.instance; final FlutterVersion flutterVersion = globals.flutterVersion;
return 'Flutter ${flutterVersion.frameworkRevisionShort}'; return 'Flutter ${flutterVersion.frameworkRevisionShort}';
} }
......
...@@ -7,7 +7,6 @@ import 'dart:async'; ...@@ -7,7 +7,6 @@ import 'dart:async';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'base/common.dart'; import 'base/common.dart';
import 'base/context.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/io.dart'; import 'base/io.dart';
import 'base/process.dart'; import 'base/process.dart';
...@@ -16,8 +15,6 @@ import 'cache.dart'; ...@@ -16,8 +15,6 @@ import 'cache.dart';
import 'convert.dart'; import 'convert.dart';
import 'globals.dart' as globals; import 'globals.dart' as globals;
FlutterVersion get flutterVersion => context.get<FlutterVersion>();
class FlutterVersion { class FlutterVersion {
FlutterVersion([this._clock = const SystemClock()]) { FlutterVersion([this._clock = const SystemClock()]) {
_frameworkRevision = _runGit(gitLog(<String>['-n', '1', '--pretty=format:%H']).join(' ')); _frameworkRevision = _runGit(gitLog(<String>['-n', '1', '--pretty=format:%H']).join(' '));
...@@ -215,8 +212,6 @@ class FlutterVersion { ...@@ -215,8 +212,6 @@ class FlutterVersion {
} }
} }
static FlutterVersion get instance => context.get<FlutterVersion>();
/// Return a short string for the version (e.g. `master/0.0.59-pre.92`, `scroll_refactor/a76bc8e22b`). /// Return a short string for the version (e.g. `master/0.0.59-pre.92`, `scroll_refactor/a76bc8e22b`).
String getVersionString({ bool redactUnknownBranches = false }) { String getVersionString({ bool redactUnknownBranches = false }) {
if (frameworkVersion != 'unknown') { if (frameworkVersion != 'unknown') {
......
...@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; ...@@ -8,6 +8,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/base/terminal.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/runner/flutter_command.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart';
import 'package:flutter_tools/src/runner/flutter_command_runner.dart'; import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
import 'package:flutter_tools/src/version.dart'; import 'package:flutter_tools/src/version.dart';
...@@ -56,7 +57,7 @@ void main() { ...@@ -56,7 +57,7 @@ void main() {
group('run', () { group('run', () {
testUsingContext('checks that Flutter installation is up-to-date', () async { testUsingContext('checks that Flutter installation is up-to-date', () async {
final MockFlutterVersion version = FlutterVersion.instance as MockFlutterVersion; final MockFlutterVersion version = globals.flutterVersion as MockFlutterVersion;
bool versionChecked = false; bool versionChecked = false;
when(version.checkFlutterVersionFreshness()).thenAnswer((_) async { when(version.checkFlutterVersionFreshness()).thenAnswer((_) async {
versionChecked = true; versionChecked = true;
...@@ -72,7 +73,7 @@ void main() { ...@@ -72,7 +73,7 @@ void main() {
}, initializeFlutterRoot: false); }, initializeFlutterRoot: false);
testUsingContext('does not check that Flutter installation is up-to-date with --machine flag', () async { testUsingContext('does not check that Flutter installation is up-to-date with --machine flag', () async {
final MockFlutterVersion version = FlutterVersion.instance as MockFlutterVersion; final MockFlutterVersion version = globals.flutterVersion as MockFlutterVersion;
bool versionChecked = false; bool versionChecked = false;
when(version.checkFlutterVersionFreshness()).thenAnswer((_) async { when(version.checkFlutterVersionFreshness()).thenAnswer((_) async {
versionChecked = true; versionChecked = true;
...@@ -88,7 +89,7 @@ void main() { ...@@ -88,7 +89,7 @@ void main() {
}, initializeFlutterRoot: false); }, initializeFlutterRoot: false);
testUsingContext('throw tool exit if the version file cannot be written', () async { testUsingContext('throw tool exit if the version file cannot be written', () async {
final MockFlutterVersion version = FlutterVersion.instance as MockFlutterVersion; final MockFlutterVersion version = globals.flutterVersion as MockFlutterVersion;
when(version.ensureVersionFile()).thenThrow(const FileSystemException()); when(version.ensureVersionFile()).thenThrow(const FileSystemException());
expect(() async => await runner.run(<String>['dummy']), throwsToolExit()); expect(() async => await runner.run(<String>['dummy']), throwsToolExit());
......
...@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/io.dart'; ...@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/io.dart';
import 'package:flutter_tools/src/base/time.dart'; import 'package:flutter_tools/src/base/time.dart';
import 'package:flutter_tools/src/base/utils.dart'; import 'package:flutter_tools/src/base/utils.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/version.dart'; import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
...@@ -56,7 +57,7 @@ void main() { ...@@ -56,7 +57,7 @@ void main() {
expectSetStamp: true, expectSetStamp: true,
channel: channel, channel: channel,
); );
await FlutterVersion.instance.checkFlutterVersionFreshness(); await globals.flutterVersion.checkFlutterVersionFreshness();
_expectVersionMessage(''); _expectVersionMessage('');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(_testClock),
...@@ -78,7 +79,7 @@ void main() { ...@@ -78,7 +79,7 @@ void main() {
expectServerPing: true, expectServerPing: true,
channel: channel, channel: channel,
); );
final FlutterVersion version = FlutterVersion.instance; final FlutterVersion version = globals.flutterVersion;
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(''); _expectVersionMessage('');
...@@ -101,7 +102,7 @@ void main() { ...@@ -101,7 +102,7 @@ void main() {
channel: channel, channel: channel,
); );
final FlutterVersion version = FlutterVersion.instance; final FlutterVersion version = globals.flutterVersion;
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(FlutterVersion.newVersionAvailableMessage()); _expectVersionMessage(FlutterVersion.newVersionAvailableMessage());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -123,7 +124,7 @@ void main() { ...@@ -123,7 +124,7 @@ void main() {
channel: channel, channel: channel,
); );
final FlutterVersion version = FlutterVersion.instance; final FlutterVersion version = globals.flutterVersion;
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(FlutterVersion.newVersionAvailableMessage()); _expectVersionMessage(FlutterVersion.newVersionAvailableMessage());
expect((await VersionCheckStamp.load()).lastTimeWarningWasPrinted, _testClock.now()); expect((await VersionCheckStamp.load()).lastTimeWarningWasPrinted, _testClock.now());
...@@ -146,7 +147,7 @@ void main() { ...@@ -146,7 +147,7 @@ void main() {
expectServerPing: true, expectServerPing: true,
channel: channel, channel: channel,
); );
final FlutterVersion version = FlutterVersion.instance; final FlutterVersion version = globals.flutterVersion;
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(FlutterVersion.newVersionAvailableMessage()); _expectVersionMessage(FlutterVersion.newVersionAvailableMessage());
...@@ -181,7 +182,7 @@ void main() { ...@@ -181,7 +182,7 @@ void main() {
expectServerPing: true, expectServerPing: true,
channel: channel, channel: channel,
); );
final FlutterVersion version = FlutterVersion.instance; final FlutterVersion version = globals.flutterVersion;
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(FlutterVersion.newVersionAvailableMessage()); _expectVersionMessage(FlutterVersion.newVersionAvailableMessage());
...@@ -201,7 +202,7 @@ void main() { ...@@ -201,7 +202,7 @@ void main() {
expectSetStamp: true, expectSetStamp: true,
channel: channel, channel: channel,
); );
final FlutterVersion version = FlutterVersion.instance; final FlutterVersion version = globals.flutterVersion;
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(''); _expectVersionMessage('');
...@@ -221,7 +222,7 @@ void main() { ...@@ -221,7 +222,7 @@ void main() {
expectSetStamp: true, expectSetStamp: true,
channel: channel, channel: channel,
); );
final FlutterVersion version = FlutterVersion.instance; final FlutterVersion version = globals.flutterVersion;
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(FlutterVersion.versionOutOfDateMessage(_testClock.now().difference(getChannelOutOfDateVersion()))); _expectVersionMessage(FlutterVersion.versionOutOfDateMessage(_testClock.now().difference(getChannelOutOfDateVersion())));
...@@ -241,7 +242,7 @@ void main() { ...@@ -241,7 +242,7 @@ void main() {
expectSetStamp: true, expectSetStamp: true,
channel: channel, channel: channel,
); );
final FlutterVersion version = FlutterVersion.instance; final FlutterVersion version = globals.flutterVersion;
when(mockProcessManager.runSync( when(mockProcessManager.runSync(
<String>['git', 'merge-base', '--is-ancestor', 'abcdef', '123456'], <String>['git', 'merge-base', '--is-ancestor', 'abcdef', '123456'],
......
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