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
6498f643
Unverified
Commit
6498f643
authored
Nov 14, 2019
by
Jenn Magder
Committed by
GitHub
Nov 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Catch and display version check errors during doctor (#44868)
parent
dfffb15c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
7 deletions
+48
-7
user_messages.dart
packages/flutter_tools/lib/src/base/user_messages.dart
+1
-1
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+15
-6
doctor_test.dart
...utter_tools/test/commands.shard/hermetic/doctor_test.dart
+32
-0
No files found.
packages/flutter_tools/lib/src/base/user_messages.dart
View file @
6498f643
...
...
@@ -10,7 +10,7 @@ UserMessages get userMessages => context.get<UserMessages>();
class
UserMessages
{
// Messages used in FlutterValidator
String
flutterStatusInfo
(
String
channel
,
String
version
,
String
os
,
String
locale
)
=>
'Channel
$
channel
, v
$version
, on
$os
, locale
$locale
'
;
'Channel
$
{channel ?? 'unknown'}
, v
${version ?? 'Unknown'}
, on
$os
, locale
$locale
'
;
String
flutterVersion
(
String
version
,
String
flutterRoot
)
=>
'Flutter version
$version
at
$flutterRoot
'
;
String
flutterRevision
(
String
revision
,
String
age
,
String
date
)
=>
...
...
packages/flutter_tools/lib/src/doctor.dart
View file @
6498f643
...
...
@@ -587,13 +587,22 @@ class FlutterValidator extends DoctorValidator {
Future
<
ValidationResult
>
validate
()
async
{
final
List
<
ValidationMessage
>
messages
=
<
ValidationMessage
>[];
ValidationType
valid
=
ValidationType
.
installed
;
String
versionChannel
;
String
frameworkVersion
;
final
FlutterVersion
version
=
FlutterVersion
.
instance
;
try
{
final
FlutterVersion
version
=
FlutterVersion
.
instance
;
versionChannel
=
version
.
channel
;
frameworkVersion
=
version
.
frameworkVersion
;
messages
.
add
(
ValidationMessage
(
userMessages
.
flutterVersion
(
frameworkVersion
,
Cache
.
flutterRoot
)));
messages
.
add
(
ValidationMessage
(
userMessages
.
flutterRevision
(
version
.
frameworkRevisionShort
,
version
.
frameworkAge
,
version
.
frameworkDate
)));
messages
.
add
(
ValidationMessage
(
userMessages
.
engineRevision
(
version
.
engineRevisionShort
)));
messages
.
add
(
ValidationMessage
(
userMessages
.
dartRevision
(
version
.
dartSdkVersion
)));
}
on
VersionCheckError
catch
(
e
)
{
messages
.
add
(
ValidationMessage
.
error
(
e
.
message
));
valid
=
ValidationType
.
partial
;
}
messages
.
add
(
ValidationMessage
(
userMessages
.
flutterVersion
(
version
.
frameworkVersion
,
Cache
.
flutterRoot
)));
messages
.
add
(
ValidationMessage
(
userMessages
.
flutterRevision
(
version
.
frameworkRevisionShort
,
version
.
frameworkAge
,
version
.
frameworkDate
)));
messages
.
add
(
ValidationMessage
(
userMessages
.
engineRevision
(
version
.
engineRevisionShort
)));
messages
.
add
(
ValidationMessage
(
userMessages
.
dartRevision
(
version
.
dartSdkVersion
)));
final
String
genSnapshotPath
=
artifacts
.
getArtifactPath
(
Artifact
.
genSnapshot
);
...
...
@@ -609,7 +618,7 @@ class FlutterValidator extends DoctorValidator {
}
return
ValidationResult
(
valid
,
messages
,
statusInfo:
userMessages
.
flutterStatusInfo
(
version
.
channel
,
version
.
frameworkVersion
,
os
.
name
,
platform
.
localeName
),
statusInfo:
userMessages
.
flutterStatusInfo
(
version
Channel
,
frameworkVersion
,
os
.
name
,
platform
.
localeName
),
);
}
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
View file @
6498f643
...
...
@@ -20,6 +20,7 @@ import 'package:flutter_tools/src/reporting/reporting.dart';
import
'package:flutter_tools/src/vscode/vscode.dart'
;
import
'package:flutter_tools/src/vscode/vscode_validator.dart'
;
import
'package:flutter_tools/src/web/workflow.dart'
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
import
'package:process/process.dart'
;
import
'package:quiver/testing/async.dart'
;
...
...
@@ -35,9 +36,11 @@ final Map<Type, Generator> noColorTerminalOverride = <Type, Generator>{
void
main
(
)
{
MockProcessManager
mockProcessManager
;
MockFlutterVersion
mockFlutterVersion
;
setUp
(()
{
mockProcessManager
=
MockProcessManager
();
mockFlutterVersion
=
MockFlutterVersion
();
});
group
(
'doctor'
,
()
{
...
...
@@ -507,6 +510,34 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Platform:
_kNoColorOutputPlatform
,
});
testUsingContext
(
'version checking does not work'
,
()
async
{
final
VersionCheckError
versionCheckError
=
VersionCheckError
(
'version error'
);
when
(
mockFlutterVersion
.
channel
).
thenReturn
(
'unknown'
);
when
(
mockFlutterVersion
.
frameworkVersion
).
thenReturn
(
'0.0.0'
);
when
(
mockFlutterVersion
.
frameworkDate
).
thenThrow
(
versionCheckError
);
when
(
mockProcessManager
.
runSync
(
<
String
>[
artifacts
.
getArtifactPath
(
Artifact
.
genSnapshot
)],
workingDirectory:
anyNamed
(
'workingDirectory'
),
environment:
anyNamed
(
'environment'
),
)).
thenReturn
(
ProcessResult
(
101
,
255
,
''
,
''
));
expect
(
await
FlutterValidatorDoctor
().
diagnose
(
verbose:
false
),
isTrue
);
expect
(
testLogger
.
statusText
,
equals
(
'Doctor summary (to see all details, run flutter doctor -v):
\n
'
'[!] Flutter (Channel unknown, v0.0.0, on fake OS name and version, locale en-US)
\n
'
' ✗ version error
\n\n
'
'! Doctor found issues in 1 category.
\n
'
));
},
overrides:
<
Type
,
Generator
>{
OutputPreferences:
()
=>
OutputPreferences
(
wrapText:
false
),
ProcessManager:
()
=>
mockProcessManager
,
Platform:
_kNoColorOutputPlatform
,
FlutterVersion:
()
=>
mockFlutterVersion
,
});
});
testUsingContext
(
'validate non-verbose output wrapping'
,
()
async
{
...
...
@@ -1018,3 +1049,4 @@ class VsCodeValidatorTestTargets extends VsCodeValidator {
}
class
MockProcessManager
extends
Mock
implements
ProcessManager
{}
class
MockFlutterVersion
extends
Mock
implements
FlutterVersion
{}
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