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
d921098d
Unverified
Commit
d921098d
authored
Aug 23, 2019
by
Mehmet Fidanboylu
Committed by
GitHub
Aug 23, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Break dependency of tools/lib/src from lib/src/commands/ (#39072)
parent
97df4033
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
24 deletions
+41
-24
doctor.dart
packages/flutter_tools/lib/src/doctor.dart
+9
-24
doctor_test.dart
...lutter_tools/test/general.shard/commands/doctor_test.dart
+5
-0
forbidden_imports_test.dart
...tter_tools/test/general.shard/forbidden_imports_test.dart
+27
-0
No files found.
packages/flutter_tools/lib/src/doctor.dart
View file @
d921098d
...
...
@@ -20,7 +20,6 @@ import 'base/user_messages.dart';
import
'base/utils.dart'
;
import
'base/version.dart'
;
import
'cache.dart'
;
import
'commands/doctor.dart'
;
import
'device.dart'
;
import
'fuchsia/fuchsia_workflow.dart'
;
import
'globals.dart'
;
...
...
@@ -34,7 +33,6 @@ import 'macos/macos_workflow.dart';
import
'macos/xcode_validator.dart'
;
import
'proxy_validator.dart'
;
import
'reporting/reporting.dart'
;
import
'runner/flutter_command.dart'
;
import
'tester/flutter_tester.dart'
;
import
'version.dart'
;
import
'vscode/vscode_validator.dart'
;
...
...
@@ -71,19 +69,12 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider {
...
VsCodeValidator
.
installedValidators
,
];
bool
verbose
=
false
;
if
(
FlutterCommand
.
current
is
DoctorCommand
)
{
verbose
=
(
FlutterCommand
.
current
as
DoctorCommand
).
verbose
;
}
_validators
=
<
DoctorValidator
>[
FlutterValidator
(),
if
(
androidWorkflow
.
appliesToHostPlatform
)
GroupedValidator
(<
DoctorValidator
>[
androidValidator
,
androidLicenseValidator
],
verbose:
verbose
),
GroupedValidator
(<
DoctorValidator
>[
androidValidator
,
androidLicenseValidator
]),
if
(
iosWorkflow
.
appliesToHostPlatform
||
macOSWorkflow
.
appliesToHostPlatform
)
GroupedValidator
(<
DoctorValidator
>[
xcodeValidator
,
cocoapodsValidator
],
verbose:
verbose
),
GroupedValidator
(<
DoctorValidator
>[
xcodeValidator
,
cocoapodsValidator
]),
if
(
webWorkflow
.
appliesToHostPlatform
)
const
WebValidator
(),
if
(
linuxWorkflow
.
appliesToHostPlatform
)
...
...
@@ -253,9 +244,7 @@ class Doctor {
try
{
result
=
await
validatorTask
.
result
;
}
catch
(
exception
,
stackTrace
)
{
// Only include the stacktrace in verbose mode.
result
=
ValidationResult
.
crash
(
exception
,
stackTrace:
verbose
?
stackTrace
:
null
);
result
=
ValidationResult
.
crash
(
exception
,
stackTrace
);
}
finally
{
status
.
stop
();
}
...
...
@@ -374,12 +363,9 @@ abstract class DoctorValidator {
/// passed to the constructor and reports the statusInfo of the first validator
/// that provides one. Other titles and statusInfo strings are discarded.
class
GroupedValidator
extends
DoctorValidator
{
GroupedValidator
(
this
.
subValidators
,
{
this
.
verbose
=
false
,
})
:
super
(
subValidators
[
0
].
title
);
GroupedValidator
(
this
.
subValidators
)
:
super
(
subValidators
[
0
].
title
);
final
List
<
DoctorValidator
>
subValidators
;
final
bool
verbose
;
List
<
ValidationResult
>
_subResults
;
...
...
@@ -409,8 +395,7 @@ class GroupedValidator extends DoctorValidator {
try
{
results
.
add
(
await
subValidator
.
result
);
}
catch
(
exception
,
stackTrace
)
{
results
.
add
(
ValidationResult
.
crash
(
exception
,
stackTrace:
verbose
?
stackTrace
:
null
));
results
.
add
(
ValidationResult
.
crash
(
exception
,
stackTrace
));
}
}
_currentSlowWarning
=
'Merging results...'
;
...
...
@@ -458,16 +443,16 @@ class ValidationResult {
/// if no [messages] are hints or errors.
ValidationResult
(
this
.
type
,
this
.
messages
,
{
this
.
statusInfo
});
factory
ValidationResult
.
crash
(
Object
error
,
{
StackTrace
stackTrace
}
)
{
factory
ValidationResult
.
crash
(
Object
error
,
[
StackTrace
stackTrace
]
)
{
return
ValidationResult
(
ValidationType
.
crash
,
<
ValidationMessage
>[
ValidationMessage
.
error
(
'Due to an error, the doctor check did not complete. '
'If the error message below is not helpful, '
'please let us know about this issue at https://github.com/flutter/flutter/issues.'
),
if
(
stackTrace
==
null
)
ValidationMessage
.
error
(
'
$error
'
),
ValidationMessage
.
error
(
'
$error
'
),
if
(
stackTrace
!=
null
)
ValidationMessage
.
error
(
'
$error
:
\n
$stackTrace
'
),
// Stacktrace is informational. Printed in verbose mode only.
ValidationMessage
(
'
$stackTrace
'
),
],
statusInfo:
'the doctor check crashed'
);
}
...
...
packages/flutter_tools/test/general.shard/commands/doctor_test.dart
View file @
d921098d
...
...
@@ -329,6 +329,11 @@ void main() {
));
},
overrides:
noColorTerminalOverride
);
testUsingContext
(
'validate verbose output format contains trace for run with crash'
,
()
async
{
expect
(
await
FakeCrashingDoctor
().
diagnose
(
verbose:
true
),
isFalse
);
expect
(
testLogger
.
statusText
,
contains
(
'#0 CrashingValidator.validate'
));
},
overrides:
noColorTerminalOverride
);
testUsingContext
(
'validate non-verbose output format when only one category fails'
,
()
async
{
expect
(
await
FakeSinglePassingDoctor
().
diagnose
(
verbose:
false
),
isTrue
);
expect
(
testLogger
.
statusText
,
equals
(
...
...
packages/flutter_tools/test/general.shard/forbidden_imports_test.dart
View file @
d921098d
...
...
@@ -9,6 +9,33 @@ import '../src/common.dart';
void
main
(
)
{
final
String
flutterTools
=
fs
.
path
.
join
(
getFlutterRoot
(),
'packages'
,
'flutter_tools'
);
test
(
'no imports of commands/* or test/* in lib/src/*'
,
()
{
final
List
<
String
>
skippedPaths
=
<
String
>
[
fs
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
,
'commands'
),
fs
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
,
'test'
)
];
bool
_isNotSkipped
(
FileSystemEntity
entity
)
=>
skippedPaths
.
every
((
String
path
)
=>
!
entity
.
path
.
startsWith
(
path
));
final
Iterable
<
File
>
files
=
fs
.
directory
(
fs
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
))
.
listSync
(
recursive:
true
)
.
where
(
_isDartFile
)
.
where
(
_isNotSkipped
)
.
map
(
_asFile
);
for
(
File
file
in
files
)
{
for
(
String
line
in
file
.
readAsLinesSync
())
{
if
(
line
.
startsWith
(
RegExp
(
r'import.*package:'
)))
{
continue
;
}
if
(
line
.
startsWith
(
RegExp
(
r'import.*commands/'
))
||
line
.
startsWith
(
RegExp
(
r'import.*test/'
)))
{
final
String
relativePath
=
fs
.
path
.
relative
(
file
.
path
,
from:
flutterTools
);
fail
(
'
$relativePath
imports
$line
. This import introduces a layering violation. '
'Please find another way to access the information you are using.'
);
}
}
}
});
test
(
'no unauthorized imports of dart:io'
,
()
{
final
List
<
String
>
whitelistedPaths
=
<
String
>[
fs
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
,
'base'
,
'io.dart'
),
...
...
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