Unverified Commit b948bc07 authored by Sigurd Meldgaard's avatar Sigurd Meldgaard Committed by GitHub

Flutter tool - Don't check for updates when run on a bot (#76107)

parent f4c3662b
...@@ -253,7 +253,12 @@ class FlutterCommandRunner extends CommandRunner<void> { ...@@ -253,7 +253,12 @@ class FlutterCommandRunner extends CommandRunner<void> {
globals.flutterVersion.ensureVersionFile(); globals.flutterVersion.ensureVersionFile();
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) { final bool ci = await globals.botDetector.isRunningOnBot;
final bool versionCheckFlag = topLevelResults['version-check'] as bool;
final bool explicitVersionCheckPassed = topLevelResults.wasParsed('version-check') && versionCheckFlag;
if (topLevelResults.command?.name != 'upgrade' &&
(explicitVersionCheckPassed || (versionCheckFlag && !ci && !machineFlag))) {
await globals.flutterVersion.checkFlutterVersionFreshness(); await globals.flutterVersion.checkFlutterVersionFreshness();
} }
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
// @dart = 2.8 // @dart = 2.8
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/bot_detector.dart';
import 'package:flutter_tools/src/base/context.dart';
import 'package:flutter_tools/src/base/file_system.dart'; 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/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
...@@ -59,6 +61,7 @@ void main() { ...@@ -59,6 +61,7 @@ void main() {
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
Platform: () => platform, Platform: () => platform,
FlutterVersion: () => FakeFlutterVersion(), FlutterVersion: () => FakeFlutterVersion(),
BotDetector: () => const FakeBotDetector(false),
OutputPreferences: () => OutputPreferences.test(), OutputPreferences: () => OutputPreferences.test(),
}); });
...@@ -77,6 +80,34 @@ void main() { ...@@ -77,6 +80,34 @@ void main() {
OutputPreferences: () => OutputPreferences.test(), OutputPreferences: () => OutputPreferences.test(),
}); });
testUsingContext('does not check that Flutter installation is up-to-date with CI=true in environment', () async {
final FlutterCommandRunner runner = createTestCommandRunner(DummyFlutterCommand()) as FlutterCommandRunner;
final FakeFlutterVersion version = globals.flutterVersion as FakeFlutterVersion;
await runner.run(<String>['dummy', '--version']);
expect(version.didCheckFlutterVersionFreshness, false);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
Platform: () => platform,
BotDetector: () => const FakeBotDetector(true),
}, initializeFlutterRoot: false);
testUsingContext('checks that Flutter installation is up-to-date with CI=true and --machine when explicit --version-check', () async {
final FlutterCommandRunner runner = createTestCommandRunner(DummyFlutterCommand()) as FlutterCommandRunner;
final FakeFlutterVersion version = globals.flutterVersion as FakeFlutterVersion;
await runner.run(<String>['dummy', '--version', '--machine', '--version-check']);
expect(version.didCheckFlutterVersionFreshness, true);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
Platform: () => platform,
BotDetector: () => const FakeBotDetector(true),
}, initializeFlutterRoot: false);
testUsingContext('Fetches tags when --version is used', () async { testUsingContext('Fetches tags when --version is used', () async {
final FlutterCommandRunner runner = createTestCommandRunner(DummyFlutterCommand()) as FlutterCommandRunner; final FlutterCommandRunner runner = createTestCommandRunner(DummyFlutterCommand()) as FlutterCommandRunner;
final FakeFlutterVersion version = globals.flutterVersion as FakeFlutterVersion; final FakeFlutterVersion version = globals.flutterVersion as FakeFlutterVersion;
......
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