Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b7214a9a
Unverified
Commit
b7214a9a
authored
Apr 13, 2021
by
Jonah Williams
Committed by
GitHub
Apr 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] fix null check in crash reporter (#80382)
parent
ce3c3d2a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
4 deletions
+52
-4
bot_detector.dart
packages/flutter_tools/lib/src/base/bot_detector.dart
+4
-3
update_packages.dart
packages/flutter_tools/lib/src/commands/update_packages.dart
+11
-0
globals_null_migrated.dart
packages/flutter_tools/lib/src/globals_null_migrated.dart
+1
-1
bot_detector_test.dart
...tter_tools/test/general.shard/base/bot_detector_test.dart
+18
-0
command_output_test.dart
...ter_tools/test/integration.shard/command_output_test.dart
+18
-0
No files found.
packages/flutter_tools/lib/src/base/bot_detector.dart
View file @
b7214a9a
...
...
@@ -28,9 +28,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'
...
...
@@ -43,6 +40,10 @@ class BotDetector {
return
_persistentToolState
.
runningOnBot
=
false
;
}
if
(
_persistentToolState
.
isRunningOnBot
!=
null
)
{
return
_persistentToolState
.
isRunningOnBot
!;
}
return
_persistentToolState
.
runningOnBot
=
_platform
.
environment
[
'BOT'
]
==
'true'
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
...
...
packages/flutter_tools/lib/src/commands/update_packages.dart
View file @
b7214a9a
...
...
@@ -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
,
);
}
...
...
@@ -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
(
...
...
packages/flutter_tools/lib/src/globals_null_migrated.dart
View file @
b7214a9a
...
...
@@ -29,7 +29,7 @@ import 'version.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
;
...
...
packages/flutter_tools/test/general.shard/base/bot_detector_test.dart
View file @
b7214a9a
...
...
@@ -45,6 +45,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'
;
...
...
packages/flutter_tools/test/integration.shard/command_output_test.dart
View file @
b7214a9a
...
...
@@ -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'
,
));
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment