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
bba6bff6
Commit
bba6bff6
authored
Jan 11, 2017
by
Todd Volkert
Committed by
GitHub
Jan 11, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move forbidden dart:io import test from Bash to Dart (#7427)
parent
ef25a203
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
26 deletions
+47
-26
test.sh
dev/bots/test.sh
+0
-22
all.dart
packages/flutter_tools/test/all.dart
+6
-4
forbid_dart_io_test.dart
packages/flutter_tools/test/forbid_dart_io_test.dart
+41
-0
No files found.
dev/bots/test.sh
View file @
bba6bff6
...
...
@@ -14,27 +14,6 @@ detect_error_on_exit() {
fi
}
check_for_dart_io
()
{
{
set
+x
;
}
2>/dev/null
(
cd
packages/flutter_tools
for
f
in
$(
grep
-Erl
'^import.*dart:io'
lib bin
test
)
;
do
if
[[
"
$f
"
==
"lib/src/base/io.dart"
]]
;
then
continue
fi
IFS
=
$'
\n
'
matches
=(
$(
grep
-E
'^import.*dart:io'
$f
)
)
for
match
in
"
${
matches
[@]
}
"
;
do
if
[[
"
$match
"
!=
*
"ignore: dart_io_import"
*
]]
;
then
echo
-e
"
\x
1B[31mError:
$f
imports 'dart:io'; import 'lib/src/base/io.dart' instead
\x
1B[0m"
exit
1
fi
done
done
)
set
-ex
}
set
-ex
# analyze all the Dart code in the repo
...
...
@@ -61,7 +40,6 @@ SRC_ROOT=$PWD
(
cd
packages/flutter_driver
;
dart
-c
test
/all.dart
)
(
cd
packages/flutter_test
;
flutter
test
)
(
cd
packages/flutter_tools
;
FLUTTER_ROOT
=
$SRC_ROOT
dart
-c
test
/all.dart
)
check_for_dart_io
(
cd
dev/devicelab
;
dart
-c
test
/all.dart
)
(
cd
dev/manual_tests
;
flutter
test
)
...
...
packages/flutter_tools/test/all.dart
View file @
bba6bff6
...
...
@@ -15,21 +15,22 @@ import 'analyze_duplicate_names_test.dart' as analyze_duplicate_names_test;
import
'analyze_test.dart'
as
analyze_test
;
import
'android_device_test.dart'
as
android_device_test
;
import
'android_sdk_test.dart'
as
android_sdk_test
;
import
'asset_bundle_test.dart'
as
asset_bundle_test
;
import
'application_package_test.dart'
as
application_package_test
;
import
'asset_bundle_test.dart'
as
asset_bundle_test
;
import
'base_utils_test.dart'
as
base_utils_test
;
import
'dart_dependencies_test.dart'
as
dart_dependencies_test
;
import
'dependency_checker_test.dart'
as
dependency_checker_test
;
import
'channel_test.dart'
as
channel_test
;
import
'config_test.dart'
as
config_test
;
import
'context_test.dart'
as
context_test
;
import
'create_test.dart'
as
create_test
;
import
'daemon_test.dart'
as
daemon_test
;
import
'dart_dependencies_test.dart'
as
dart_dependencies_test
;
import
'dependency_checker_test.dart'
as
dependency_checker_test
;
import
'devfs_test.dart'
as
devfs_test
;
import
'device_test.dart'
as
device_test
;
import
'devices_test.dart'
as
devices_test
;
import
'doctor_test.dart'
as
doctor_test
;
import
'drive_test.dart'
as
drive_test
;
import
'forbid_dart_io_test.dart'
as
forbid_dart_io_test
;
import
'format_test.dart'
as
format_test
;
import
'hot_test.dart'
as
hot_test
;
import
'install_test.dart'
as
install_test
;
...
...
@@ -57,18 +58,19 @@ void main() {
application_package_test
.
main
();
asset_bundle_test
.
main
();
base_utils_test
.
main
();
dart_dependencies_test
.
main
();
channel_test
.
main
();
config_test
.
main
();
context_test
.
main
();
create_test
.
main
();
daemon_test
.
main
();
dart_dependencies_test
.
main
();
dependency_checker_test
.
main
();
devfs_test
.
main
();
device_test
.
main
();
devices_test
.
main
();
doctor_test
.
main
();
drive_test
.
main
();
forbid_dart_io_test
.
main
();
format_test
.
main
();
hot_test
.
main
();
install_test
.
main
();
...
...
packages/flutter_tools/test/forbid_dart_io_test.dart
0 → 100644
View file @
bba6bff6
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/io.dart'
;
import
'package:test/test.dart'
;
void
main
(
)
{
setUp
(()
{
String
flutterRoot
=
Platform
.
environment
[
'FLUTTER_ROOT'
];
assert
(
fs
.
currentDirectory
.
path
==
'
$flutterRoot
/packages/flutter_tools'
);
});
test
(
'no unauthorized imports of dart:io'
,
()
{
for
(
String
path
in
<
String
>[
'lib'
,
'bin'
,
'test'
])
{
fs
.
directory
(
path
)
.
listSync
(
recursive:
true
)
.
where
(
_isDartFile
)
.
where
(
_isNotWhitelisted
)
.
map
(
_asFile
)
.
forEach
((
File
file
)
{
for
(
String
line
in
file
.
readAsLinesSync
())
{
if
(
line
.
startsWith
(
new
RegExp
(
'import.*dart:io'
))
&&
!
line
.
contains
(
'ignore: dart_io_import'
))
{
fail
(
"
${file.path}
imports 'dart:io'; import 'lib/src/base/io.dart' instead"
);
}
}
}
);
}
});
}
bool
_isDartFile
(
FileSystemEntity
entity
)
=>
entity
is
File
&&
entity
.
path
.
endsWith
(
'.dart'
);
bool
_isNotWhitelisted
(
FileSystemEntity
entity
)
=>
entity
.
path
!=
'lib/src/base/io.dart'
;
File
_asFile
(
FileSystemEntity
entity
)
=>
entity
;
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