Unverified Commit 0b882698 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove branch migration and standardize constructor style for...

[flutter_tools] remove branch migration and standardize constructor style for version interface (#70058)
parent d11859fe
...@@ -115,10 +115,7 @@ class ChannelCommand extends FlutterCommand { ...@@ -115,10 +115,7 @@ class ChannelCommand extends FlutterCommand {
Future<void> _switchChannel(String branchName) async { Future<void> _switchChannel(String branchName) async {
globals.printStatus("Switching to flutter channel '$branchName'..."); globals.printStatus("Switching to flutter channel '$branchName'...");
if (kObsoleteBranches.containsKey(branchName)) { if (!kOfficialChannels.contains(branchName)) {
final String alternative = kObsoleteBranches[branchName];
globals.printStatus("This channel is obsolete. Consider switching to the '$alternative' channel instead.");
} else if (!kOfficialChannels.contains(branchName)) {
globals.printStatus('This is not an official channel. For a list of available channels, try "flutter channel".'); globals.printStatus('This is not an official channel. For a list of available channels, try "flutter channel".');
} }
await _checkout(branchName); await _checkout(branchName);
...@@ -126,15 +123,6 @@ class ChannelCommand extends FlutterCommand { ...@@ -126,15 +123,6 @@ class ChannelCommand extends FlutterCommand {
globals.printStatus("To ensure that you're on the latest build from this channel, run 'flutter upgrade'"); globals.printStatus("To ensure that you're on the latest build from this channel, run 'flutter upgrade'");
} }
static Future<void> upgradeChannel() async {
final String channel = globals.flutterVersion.channel;
if (kObsoleteBranches.containsKey(channel)) {
final String alternative = kObsoleteBranches[channel];
globals.printStatus("Transitioning from '$channel' to '$alternative'...");
return _checkout(alternative);
}
}
static Future<void> _checkout(String branchName) async { static Future<void> _checkout(String branchName) async {
// Get latest refs from upstream. // Get latest refs from upstream.
int result = await globals.processUtils.stream( int result = await globals.processUtils.stream(
......
...@@ -10,7 +10,6 @@ import '../base/io.dart'; ...@@ -10,7 +10,6 @@ import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/terminal.dart'; import '../base/terminal.dart';
import '../base/time.dart';
import '../cache.dart'; import '../cache.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../persistent_tool_state.dart'; import '../persistent_tool_state.dart';
...@@ -87,7 +86,7 @@ class DowngradeCommand extends FlutterCommand { ...@@ -87,7 +86,7 @@ class DowngradeCommand extends FlutterCommand {
String workingDirectory = Cache.flutterRoot; String workingDirectory = Cache.flutterRoot;
if (argResults.wasParsed('working-directory')) { if (argResults.wasParsed('working-directory')) {
workingDirectory = stringArg('working-directory'); workingDirectory = stringArg('working-directory');
_flutterVersion = FlutterVersion(const SystemClock(), workingDirectory); _flutterVersion = FlutterVersion(workingDirectory: workingDirectory);
} }
final String currentChannel = _flutterVersion.channel; final String currentChannel = _flutterVersion.channel;
......
...@@ -14,7 +14,6 @@ import '../dart/pub.dart'; ...@@ -14,7 +14,6 @@ import '../dart/pub.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../runner/flutter_command.dart'; import '../runner/flutter_command.dart';
import '../version.dart'; import '../version.dart';
import 'channel.dart';
class UpgradeCommand extends FlutterCommand { class UpgradeCommand extends FlutterCommand {
UpgradeCommand([UpgradeCommandRunner commandRunner]) UpgradeCommand([UpgradeCommandRunner commandRunner])
...@@ -67,7 +66,7 @@ class UpgradeCommand extends FlutterCommand { ...@@ -67,7 +66,7 @@ class UpgradeCommand extends FlutterCommand {
gitTagVersion: GitTagVersion.determine(globals.processUtils), gitTagVersion: GitTagVersion.determine(globals.processUtils),
flutterVersion: stringArg('working-directory') == null flutterVersion: stringArg('working-directory') == null
? globals.flutterVersion ? globals.flutterVersion
: FlutterVersion(const SystemClock(), _commandRunner.workingDirectory), : FlutterVersion(clock: const SystemClock(), workingDirectory: _commandRunner.workingDirectory),
verifyOnly: boolArg('verify-only'), verifyOnly: boolArg('verify-only'),
); );
} }
...@@ -154,7 +153,6 @@ class UpgradeCommandRunner { ...@@ -154,7 +153,6 @@ class UpgradeCommandRunner {
); );
} }
recordState(flutterVersion); recordState(flutterVersion);
await upgradeChannel(flutterVersion);
await attemptReset(upstreamRevision); await attemptReset(upstreamRevision);
if (!testFlow) { if (!testFlow) {
await flutterUpgradeContinue(); await flutterUpgradeContinue();
...@@ -258,15 +256,6 @@ class UpgradeCommandRunner { ...@@ -258,15 +256,6 @@ class UpgradeCommandRunner {
return revision; return revision;
} }
/// Attempts to upgrade the channel.
///
/// If the user is on a deprecated channel, attempts to migrate them off of
/// it.
Future<void> upgradeChannel(FlutterVersion flutterVersion) async {
globals.printStatus('Upgrading Flutter from $workingDirectory...');
await ChannelCommand.upgradeChannel();
}
/// Attempts a hard reset to the given revision. /// Attempts a hard reset to the given revision.
/// ///
/// This is a reset instead of fast forward because if we are on a release /// This is a reset instead of fast forward because if we are on a release
......
...@@ -186,7 +186,7 @@ Future<T> runInContext<T>( ...@@ -186,7 +186,7 @@ Future<T> runInContext<T>(
androidWorkflow: androidWorkflow, androidWorkflow: androidWorkflow,
), ),
FeatureFlags: () => const FlutterFeatureFlags(), FeatureFlags: () => const FlutterFeatureFlags(),
FlutterVersion: () => FlutterVersion(const SystemClock()), FlutterVersion: () => FlutterVersion(clock: const SystemClock()),
FuchsiaArtifacts: () => FuchsiaArtifacts.find(), FuchsiaArtifacts: () => FuchsiaArtifacts.find(),
FuchsiaDeviceTools: () => FuchsiaDeviceTools(), FuchsiaDeviceTools: () => FuchsiaDeviceTools(),
FuchsiaSdk: () => FuchsiaSdk(), FuchsiaSdk: () => FuchsiaSdk(),
......
...@@ -423,8 +423,7 @@ class _DefaultUsage implements Usage { ...@@ -423,8 +423,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.
(!globals.flutterVersion.isMaster && (globals.persistentToolState.redisplayWelcomeMessage ?? true)) {
(globals.persistentToolState.redisplayWelcomeMessage ?? true))) {
_printWelcome(); _printWelcome();
_printedWelcome = true; _printedWelcome = true;
globals.persistentToolState.redisplayWelcomeMessage = false; globals.persistentToolState.redisplayWelcomeMessage = false;
......
...@@ -232,13 +232,7 @@ class FlutterCommandRunner extends CommandRunner<void> { ...@@ -232,13 +232,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
globals.flutterUsage.suppressAnalytics = true; globals.flutterUsage.suppressAnalytics = true;
} }
try { globals.flutterVersion.ensureVersionFile();
await globals.flutterVersion.ensureVersionFile();
} on FileSystemException catch (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.');
throwToolExit('Failed to write the version file');
}
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 globals.flutterVersion.checkFlutterVersionFreshness(); await globals.flutterVersion.checkFlutterVersionFreshness();
......
...@@ -16,17 +16,6 @@ import 'globals.dart' as globals; ...@@ -16,17 +16,6 @@ import 'globals.dart' as globals;
/// The flutter GitHub repository. /// The flutter GitHub repository.
String get _flutterGit => globals.platform.environment['FLUTTER_GIT_URL'] ?? 'https://github.com/flutter/flutter.git'; String get _flutterGit => globals.platform.environment['FLUTTER_GIT_URL'] ?? 'https://github.com/flutter/flutter.git';
/// This maps old branch names to the names of branches that replaced them.
///
/// For example, in early 2018 we changed from having an "alpha" branch to
/// having a "dev" branch, so anyone using "alpha" now gets transitioned to
/// "dev".
const Map<String, String> kObsoleteBranches = <String, String>{
'alpha': 'dev',
'hackathon': 'dev',
'codelab': 'dev',
};
/// The names of each channel/branch in order of increasing stability. /// The names of each channel/branch in order of increasing stability.
enum Channel { enum Channel {
master, master,
...@@ -67,7 +56,11 @@ class FlutterVersion { ...@@ -67,7 +56,11 @@ class FlutterVersion {
/// ///
/// Call [fetchTagsAndUpdate] to update the version based on the latest tags /// Call [fetchTagsAndUpdate] to update the version based on the latest tags
/// available upstream. /// available upstream.
FlutterVersion([this._clock = const SystemClock(), this._workingDirectory]) { FlutterVersion({
SystemClock clock = const SystemClock(),
String workingDirectory,
}) : _clock = clock,
_workingDirectory = workingDirectory {
_frameworkRevision = _runGit( _frameworkRevision = _runGit(
gitLog(<String>['-n', '1', '--pretty=format:%H']).join(' '), gitLog(<String>['-n', '1', '--pretty=format:%H']).join(' '),
globals.processUtils, globals.processUtils,
...@@ -77,6 +70,9 @@ class FlutterVersion { ...@@ -77,6 +70,9 @@ class FlutterVersion {
_frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision); _frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision);
} }
final SystemClock _clock;
final String _workingDirectory;
/// Fetches tags from the upstream Flutter repository and re-calculates the /// Fetches tags from the upstream Flutter repository and re-calculates the
/// version. /// version.
/// ///
...@@ -88,21 +84,12 @@ class FlutterVersion { ...@@ -88,21 +84,12 @@ class FlutterVersion {
_frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision); _frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision);
} }
final SystemClock _clock;
final String _workingDirectory;
String _repositoryUrl; String _repositoryUrl;
String get repositoryUrl { String get repositoryUrl {
final String _ = channel; final String _ = channel;
return _repositoryUrl; return _repositoryUrl;
} }
/// Whether we are currently on the master branch.
bool get isMaster {
final String branchName = getBranchName();
return !<String>['dev', 'beta', 'stable'].contains(branchName);
}
String _channel; String _channel;
/// The channel is the upstream branch. /// The channel is the upstream branch.
/// `master`, `dev`, `beta`, `stable`; or old ones, like `alpha`, `hackathon`, ... /// `master`, `dev`, `beta`, `stable`; or old ones, like `alpha`, `hackathon`, ...
...@@ -161,9 +148,8 @@ class FlutterVersion { ...@@ -161,9 +148,8 @@ class FlutterVersion {
String get engineRevision => globals.cache.engineRevision; String get engineRevision => globals.cache.engineRevision;
String get engineRevisionShort => _shortGitRevision(engineRevision); String get engineRevisionShort => _shortGitRevision(engineRevision);
Future<void> ensureVersionFile() { void ensureVersionFile() {
globals.fs.file(globals.fs.path.join(Cache.flutterRoot, 'version')).writeAsStringSync(_frameworkVersion); globals.fs.file(globals.fs.path.join(Cache.flutterRoot, 'version')).writeAsStringSync(_frameworkVersion);
return Future<void>.value();
} }
@override @override
...@@ -298,8 +284,7 @@ class FlutterVersion { ...@@ -298,8 +284,7 @@ class FlutterVersion {
}(); }();
if (redactUnknownBranches || _branch.isEmpty) { if (redactUnknownBranches || _branch.isEmpty) {
// Only return the branch names we know about; arbitrary branch names might contain PII. // Only return the branch names we know about; arbitrary branch names might contain PII.
if (!kOfficialChannels.contains(_branch) && if (!kOfficialChannels.contains(_branch)) {
!kObsoleteBranches.containsKey(_branch)) {
return '[user-branch]'; return '[user-branch]';
} }
} }
......
...@@ -40,7 +40,7 @@ void main() { ...@@ -40,7 +40,7 @@ void main() {
fakeCommandRunner = FakeUpgradeCommandRunner(); fakeCommandRunner = FakeUpgradeCommandRunner();
realCommandRunner = UpgradeCommandRunner(); realCommandRunner = UpgradeCommandRunner();
processManager = FakeProcessManager.list(<FakeCommand>[]); processManager = FakeProcessManager.list(<FakeCommand>[]);
fakeCommandRunner.willHaveUncomittedChanges = false; fakeCommandRunner.willHaveUncommittedChanges = false;
fakePlatform = FakePlatform()..environment = Map<String, String>.unmodifiable(<String, String>{ fakePlatform = FakePlatform()..environment = Map<String, String>.unmodifiable(<String, String>{
'ENV1': 'irrelevant', 'ENV1': 'irrelevant',
'ENV2': 'irrelevant', 'ENV2': 'irrelevant',
...@@ -63,7 +63,7 @@ void main() { ...@@ -63,7 +63,7 @@ void main() {
}); });
testUsingContext('throws tool exit with uncommitted changes', () async { testUsingContext('throws tool exit with uncommitted changes', () async {
fakeCommandRunner.willHaveUncomittedChanges = true; fakeCommandRunner.willHaveUncommittedChanges = true;
final Future<FlutterCommandResult> result = fakeCommandRunner.runCommand( final Future<FlutterCommandResult> result = fakeCommandRunner.runCommand(
force: false, force: false,
continueFlow: false, continueFlow: false,
...@@ -290,7 +290,7 @@ void main() { ...@@ -290,7 +290,7 @@ void main() {
}); });
testUsingContext('does not throw tool exit with uncommitted changes and force', () async { testUsingContext('does not throw tool exit with uncommitted changes and force', () async {
fakeCommandRunner.willHaveUncomittedChanges = true; fakeCommandRunner.willHaveUncommittedChanges = true;
final Future<FlutterCommandResult> result = fakeCommandRunner.runCommand( final Future<FlutterCommandResult> result = fakeCommandRunner.runCommand(
force: true, force: true,
...@@ -348,7 +348,7 @@ void main() { ...@@ -348,7 +348,7 @@ void main() {
]); ]);
tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_upgrade_test.'); tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_upgrade_test.');
flutterToolState = tempDir.childFile('.flutter_tool_state'); flutterToolState = tempDir.childFile('.flutter_tool_state');
mockFlutterVersion = MockFlutterVersion(isStable: true); mockFlutterVersion = MockFlutterVersion();
}); });
tearDown(() { tearDown(() {
...@@ -385,7 +385,7 @@ void main() { ...@@ -385,7 +385,7 @@ void main() {
} }
class FakeUpgradeCommandRunner extends UpgradeCommandRunner { class FakeUpgradeCommandRunner extends UpgradeCommandRunner {
bool willHaveUncomittedChanges = false; bool willHaveUncommittedChanges = false;
bool alreadyUpToDate = false; bool alreadyUpToDate = false;
...@@ -395,10 +395,7 @@ class FakeUpgradeCommandRunner extends UpgradeCommandRunner { ...@@ -395,10 +395,7 @@ class FakeUpgradeCommandRunner extends UpgradeCommandRunner {
Future<String> fetchRemoteRevision() async => remoteRevision; Future<String> fetchRemoteRevision() async => remoteRevision;
@override @override
Future<bool> hasUncommittedChanges() async => willHaveUncomittedChanges; Future<bool> hasUncommittedChanges() async => willHaveUncommittedChanges;
@override
Future<void> upgradeChannel(FlutterVersion flutterVersion) async {}
@override @override
Future<void> attemptReset(String newRevision) async {} Future<void> attemptReset(String newRevision) async {}
......
...@@ -70,7 +70,7 @@ void main() { ...@@ -70,7 +70,7 @@ void main() {
expect(count, 0); expect(count, 0);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(const SystemClock()), FlutterVersion: () => FlutterVersion(clock: const SystemClock()),
Usage: () => Usage( Usage: () => Usage(
configDirOverride: tempDir.path, configDirOverride: tempDir.path,
logFile: tempDir.childFile('analytics.log').path, logFile: tempDir.childFile('analytics.log').path,
...@@ -94,7 +94,7 @@ void main() { ...@@ -94,7 +94,7 @@ void main() {
expect(count, 0); expect(count, 0);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(const SystemClock()), FlutterVersion: () => FlutterVersion(clock: const SystemClock()),
Usage: () => Usage( Usage: () => Usage(
configDirOverride: tempDir.path, configDirOverride: tempDir.path,
logFile: tempDir.childFile('analytics.log').path, logFile: tempDir.childFile('analytics.log').path,
...@@ -112,7 +112,7 @@ void main() { ...@@ -112,7 +112,7 @@ void main() {
expect(globals.fs.file('test').readAsStringSync(), contains('$featuresKey: enable-web')); expect(globals.fs.file('test').readAsStringSync(), contains('$featuresKey: enable-web'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(const SystemClock()), FlutterVersion: () => FlutterVersion(clock: const SystemClock()),
Config: () => mockFlutterConfig, Config: () => mockFlutterConfig,
Platform: () => FakePlatform(environment: <String, String>{ Platform: () => FakePlatform(environment: <String, String>{
'FLUTTER_ANALYTICS_LOG_FILE': 'test', 'FLUTTER_ANALYTICS_LOG_FILE': 'test',
...@@ -138,7 +138,7 @@ void main() { ...@@ -138,7 +138,7 @@ void main() {
contains('$featuresKey: enable-web,enable-linux-desktop,enable-macos-desktop'), contains('$featuresKey: enable-web,enable-linux-desktop,enable-macos-desktop'),
); );
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(const SystemClock()), FlutterVersion: () => FlutterVersion(clock: const SystemClock()),
Config: () => mockFlutterConfig, Config: () => mockFlutterConfig,
Platform: () => FakePlatform(environment: <String, String>{ Platform: () => FakePlatform(environment: <String, String>{
'FLUTTER_ANALYTICS_LOG_FILE': 'test', 'FLUTTER_ANALYTICS_LOG_FILE': 'test',
......
...@@ -96,18 +96,6 @@ void main() { ...@@ -96,18 +96,6 @@ void main() {
Platform: () => platform, Platform: () => platform,
}, initializeFlutterRoot: false); }, initializeFlutterRoot: false);
testUsingContext('throw tool exit if the version file cannot be written', () async {
final MockFlutterVersion version = globals.flutterVersion as MockFlutterVersion;
when(version.ensureVersionFile()).thenThrow(const FileSystemException());
expect(() async => await runner.run(<String>['dummy']), throwsToolExit());
}, overrides: <Type, Generator>{
FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(),
Platform: () => platform,
}, initializeFlutterRoot: false);
testUsingContext('Doesnt crash on invalid .packages file', () async { testUsingContext('Doesnt crash on invalid .packages file', () async {
fs.file('pubspec.yaml').createSync(); fs.file('pubspec.yaml').createSync();
fs.file('.packages') fs.file('.packages')
......
...@@ -119,7 +119,7 @@ void main() { ...@@ -119,7 +119,7 @@ void main() {
_expectVersionMessage(''); _expectVersionMessage('');
expect(processManager.hasRemainingExpectations, isFalse); expect(processManager.hasRemainingExpectations, isFalse);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => processManager, ProcessManager: () => processManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -143,7 +143,7 @@ void main() { ...@@ -143,7 +143,7 @@ void main() {
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(''); _expectVersionMessage('');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -165,7 +165,7 @@ void main() { ...@@ -165,7 +165,7 @@ void main() {
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(FlutterVersion.newVersionAvailableMessage()); _expectVersionMessage(FlutterVersion.newVersionAvailableMessage());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -191,7 +191,7 @@ void main() { ...@@ -191,7 +191,7 @@ void main() {
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(''); _expectVersionMessage('');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -222,7 +222,7 @@ void main() { ...@@ -222,7 +222,7 @@ void main() {
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(''); _expectVersionMessage('');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -246,7 +246,7 @@ void main() { ...@@ -246,7 +246,7 @@ void main() {
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(FlutterVersion.newVersionAvailableMessage()); _expectVersionMessage(FlutterVersion.newVersionAvailableMessage());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -266,7 +266,7 @@ void main() { ...@@ -266,7 +266,7 @@ void main() {
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(''); _expectVersionMessage('');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -286,7 +286,7 @@ void main() { ...@@ -286,7 +286,7 @@ void main() {
await version.checkFlutterVersionFreshness(); await version.checkFlutterVersionFreshness();
_expectVersionMessage(FlutterVersion.versionOutOfDateMessage(_testClock.now().difference(getChannelOutOfDateVersion()))); _expectVersionMessage(FlutterVersion.versionOutOfDateMessage(_testClock.now().difference(getChannelOutOfDateVersion())));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -320,7 +320,7 @@ void main() { ...@@ -320,7 +320,7 @@ void main() {
workingDirectory: anyNamed('workingDirectory'), workingDirectory: anyNamed('workingDirectory'),
)); ));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
}); });
}); });
...@@ -336,7 +336,7 @@ void main() { ...@@ -336,7 +336,7 @@ void main() {
fakeData(mockProcessManager, mockCache, channel: channel); fakeData(mockProcessManager, mockCache, channel: channel);
_expectDefault(await VersionCheckStamp.load()); _expectDefault(await VersionCheckStamp.load());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -345,7 +345,7 @@ void main() { ...@@ -345,7 +345,7 @@ void main() {
fakeData(mockProcessManager, mockCache, stampJson: '<', channel: channel); fakeData(mockProcessManager, mockCache, stampJson: '<', channel: channel);
_expectDefault(await VersionCheckStamp.load()); _expectDefault(await VersionCheckStamp.load());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -359,7 +359,7 @@ void main() { ...@@ -359,7 +359,7 @@ void main() {
); );
_expectDefault(await VersionCheckStamp.load()); _expectDefault(await VersionCheckStamp.load());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -383,7 +383,7 @@ void main() { ...@@ -383,7 +383,7 @@ void main() {
expect(stamp.lastTimeVersionWasChecked, _testClock.ago(const Duration(days: 2))); expect(stamp.lastTimeVersionWasChecked, _testClock.ago(const Duration(days: 2)));
expect(stamp.lastTimeWarningWasPrinted, _testClock.now()); expect(stamp.lastTimeWarningWasPrinted, _testClock.now());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -410,7 +410,7 @@ void main() { ...@@ -410,7 +410,7 @@ void main() {
expect(storedStamp.lastTimeVersionWasChecked, _testClock.ago(const Duration(days: 2))); expect(storedStamp.lastTimeVersionWasChecked, _testClock.ago(const Duration(days: 2)));
expect(storedStamp.lastTimeWarningWasPrinted, _testClock.now()); expect(storedStamp.lastTimeWarningWasPrinted, _testClock.now());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
...@@ -441,7 +441,7 @@ void main() { ...@@ -441,7 +441,7 @@ void main() {
expect(storedStamp.lastTimeVersionWasChecked, _testClock.ago(const Duration(days: 2))); expect(storedStamp.lastTimeVersionWasChecked, _testClock.ago(const Duration(days: 2)));
expect(storedStamp.lastTimeWarningWasPrinted, _testClock.now()); expect(storedStamp.lastTimeWarningWasPrinted, _testClock.now());
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
FlutterVersion: () => FlutterVersion(_testClock), FlutterVersion: () => FlutterVersion(clock: _testClock),
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
Cache: () => mockCache, Cache: () => mockCache,
}); });
......
...@@ -419,14 +419,7 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter { ...@@ -419,14 +419,7 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
List<String> xcrunCommand() => <String>['xcrun']; List<String> xcrunCommand() => <String>['xcrun'];
} }
class MockFlutterVersion extends Mock implements FlutterVersion { class MockFlutterVersion extends Mock implements FlutterVersion {}
MockFlutterVersion({bool isStable = false}) : _isStable = isStable;
final bool _isStable;
@override
bool get isMaster => !_isStable;
}
class MockClock extends Mock implements SystemClock {} class MockClock extends Mock implements SystemClock {}
......
...@@ -709,9 +709,6 @@ class FakeFlutterVersion implements FlutterVersion { ...@@ -709,9 +709,6 @@ class FakeFlutterVersion implements FlutterVersion {
return 'v0.0.0'; return 'v0.0.0';
} }
@override
bool get isMaster => true;
@override @override
String get repositoryUrl => null; String get repositoryUrl => null;
......
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