Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_releases] Flutter Dev 2.2.0-10.1.pre Framework Cherrypicks #80459

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/internal/engine.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
56b13559807bf4cb83d16c659757d6ae4f209490
d2a2e93510ad6cfc3d62a90d903b7056e4da8264
7 changes: 4 additions & 3 deletions packages/flutter_tools/lib/src/base/bot_detector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ class BotDetector {
final PersistentToolState _persistentToolState;

Future<bool> get isRunningOnBot async {
if (_persistentToolState.isRunningOnBot != null) {
return _persistentToolState.isRunningOnBot;
}
if (
// Explicitly stated to not be a bot.
_platform.environment['BOT'] == 'false'
Expand All @@ -45,6 +42,10 @@ class BotDetector {
return _persistentToolState.isRunningOnBot = false;
}

if (_persistentToolState.isRunningOnBot != null) {
return _persistentToolState.isRunningOnBot;
}

return _persistentToolState.isRunningOnBot = _platform.environment['BOT'] == 'true'

// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
Expand Down
11 changes: 11 additions & 0 deletions packages/flutter_tools/lib/src/commands/update_packages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ class UpdatePackagesCommand extends FlutterCommand {
help: 'Use cached packages instead of accessing the network.',
defaultsTo: false,
negatable: false,
)
..addFlag(
'crash',
help: 'For Flutter CLI testing only, forces this command to throw an unhandled exception.',
defaultsTo: false,
negatable: false,
);
}

Expand Down Expand Up @@ -179,6 +185,11 @@ class UpdatePackagesCommand extends FlutterCommand {
final bool isVerifyOnly = boolArg('verify-only');
final bool isConsumerOnly = boolArg('consumer-only');
final bool offline = boolArg('offline');
final bool crash = boolArg('crash');

if (crash) {
throw StateError('test crash please ignore.');
}

if (upgrade && offline) {
throwToolExit(
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter_tools/lib/src/globals_null_migrated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import 'ios/plist_parser.dart';

Cache get cache => context.get<Cache>()!;
Config get config => context.get<Config>()!;
HttpClientFactory get httpClientFactory => context.get<HttpClientFactory>()!;
HttpClientFactory? get httpClientFactory => context.get<HttpClientFactory>();
Logger get logger => context.get<Logger>()!;
OperatingSystemUtils get os => context.get<OperatingSystemUtils>()!;
Signals get signals => context.get<Signals>() ?? LocalSignals.instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ void main() {
expect(persistentToolState.isRunningOnBot, isFalse);
});

testWithoutContext('does not cache BOT environment variable', () async {
fakePlatform.environment['BOT'] = 'true';

final BotDetector botDetector = BotDetector(
platform: fakePlatform,
httpClientFactory: () => FakeHttpClient.any(),
persistentToolState: persistentToolState,
);

expect(await botDetector.isRunningOnBot, isTrue);
expect(persistentToolState.isRunningOnBot, isTrue);

fakePlatform.environment['BOT'] = 'false';

expect(await botDetector.isRunningOnBot, isFalse);
expect(persistentToolState.isRunningOnBot, isFalse);
});

testWithoutContext('returns false unconditionally if FLUTTER_HOST is set', () async {
fakePlatform.environment['FLUTTER_HOST'] = 'foo';
fakePlatform.environment['TRAVIS'] = 'true';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,22 @@ void main() {
expect(result.exitCode, isNot(0));
expect(result.stderr, contains('Could not find an option named "release"'));
});

testWithoutContext('flutter can report crashes', () async {
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
final ProcessResult result = await processManager.run(<String>[
flutterBin,
...getLocalEngineArguments(),
'update-packages',
'--crash',
], environment: <String, String>{
'BOT': 'false',
});

expect(result.exitCode, isNot(0));
expect(result.stderr, contains(
'Oops; flutter has exited unexpectedly: "Bad state: test crash please ignore.".\n'
'A crash report has been written to',
));
});
}