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
8b88c829
Unverified
Commit
8b88c829
authored
Dec 11, 2019
by
Jonah Williams
Committed by
GitHub
Dec 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove test_api dependency from flutter_tools/base/io (#46796)
parent
d0e58240
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
8 deletions
+32
-8
io.dart
packages/flutter_tools/lib/src/base/io.dart
+1
-8
io_test.dart
packages/flutter_tools/test/general.shard/base/io_test.dart
+4
-0
forbidden_imports_test.dart
...tter_tools/test/general.shard/forbidden_imports_test.dart
+27
-0
No files found.
packages/flutter_tools/lib/src/base/io.dart
View file @
8b88c829
...
...
@@ -30,7 +30,6 @@ import 'dart:io' as io show exit, IOSink, Process, ProcessInfo, ProcessSignal,
stderr
,
stdin
,
Stdin
,
StdinException
,
Stdout
,
stdout
;
import
'package:meta/meta.dart'
;
import
'package:test_api/test_api.dart'
;
// ignore: deprecated_member_use
import
'context.dart'
;
import
'platform.dart'
;
...
...
@@ -112,13 +111,7 @@ ExitFunction get exit {
// Whether the tool is executing in a unit test.
bool
_inUnitTest
(
)
{
try
{
expect
(
true
,
true
);
}
on
StateError
{
// If a StateError is caught, then this is not a unit test.
return
false
;
}
return
true
;
return
Zone
.
current
[
#test
.
declarer
]
!=
null
;
}
/// Sets the [exit] function to a function that throws an exception rather
...
...
packages/flutter_tools/test/general.shard/base/io_test.dart
View file @
8b88c829
...
...
@@ -78,6 +78,10 @@ void main() {
expect
(()
=>
exit
(
0
),
returnsNormally
);
});
test
(
'test_api defines the Declarer in a known place'
,
()
{
expect
(
Zone
.
current
[
#test
.
declarer
],
isNotNull
);
});
}
class
MockIoProcessSignal
extends
Mock
implements
io
.
ProcessSignal
{}
packages/flutter_tools/test/general.shard/forbidden_imports_test.dart
View file @
8b88c829
...
...
@@ -61,6 +61,33 @@ void main() {
}
});
test
(
'no unauthorized imports of test_api'
,
()
{
final
List
<
String
>
whitelistedPaths
=
<
String
>[
fs
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
,
'build_runner'
,
'build_script.dart'
),
fs
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
,
'test'
,
'flutter_platform.dart'
),
fs
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
,
'test'
,
'flutter_web_platform.dart'
),
fs
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
,
'test'
,
'runner.dart'
),
];
bool
_isNotWhitelisted
(
FileSystemEntity
entity
)
=>
whitelistedPaths
.
every
((
String
path
)
=>
path
!=
entity
.
path
);
for
(
String
dirName
in
<
String
>[
'lib'
])
{
final
Iterable
<
File
>
files
=
fs
.
directory
(
fs
.
path
.
join
(
flutterTools
,
dirName
))
.
listSync
(
recursive:
true
)
.
where
(
_isDartFile
)
.
where
(
_isNotWhitelisted
)
.
map
(
_asFile
);
for
(
File
file
in
files
)
{
for
(
String
line
in
file
.
readAsLinesSync
())
{
if
(
line
.
startsWith
(
RegExp
(
r'import.*package:test_api'
))
&&
!
line
.
contains
(
'ignore: test_api_import'
))
{
final
String
relativePath
=
fs
.
path
.
relative
(
file
.
path
,
from:
flutterTools
);
fail
(
"
$relativePath
imports 'package:test_api/test_api.dart';"
);
}
}
}
}
});
test
(
'no unauthorized imports of package:path'
,
()
{
final
String
whitelistedPath
=
fs
.
path
.
join
(
flutterTools
,
'lib'
,
'src'
,
'build_runner'
,
'web_compilation_delegate.dart'
);
for
(
String
dirName
in
<
String
>[
'lib'
,
'bin'
,
'test'
])
{
...
...
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