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
e0c51480
Commit
e0c51480
authored
Mar 04, 2017
by
Michael Goderbauer
Committed by
GitHub
Mar 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
canonicalize paths in devfs (#8565)
parent
6c97dd2c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
8 deletions
+46
-8
dependencies.dart
packages/flutter_tools/lib/src/dart/dependencies.dart
+9
-3
devfs.dart
packages/flutter_tools/lib/src/devfs.dart
+2
-1
dart_dependencies_test.dart
packages/flutter_tools/test/dart_dependencies_test.dart
+2
-2
devfs_test.dart
packages/flutter_tools/test/devfs_test.dart
+33
-2
No files found.
packages/flutter_tools/lib/src/dart/dependencies.dart
View file @
e0c51480
...
...
@@ -24,6 +24,9 @@ class DartDependencySetBuilder {
final
String
projectRootPath
;
final
String
packagesFilePath
;
/// Returns a set of canonicalize paths.
///
/// The paths have been canonicalize with `fs.path.canonicalize`.
Set
<
String
>
build
()
{
final
String
skySnapshotPath
=
Artifacts
.
instance
.
getArtifactPath
(
Artifact
.
skySnapshot
);
...
...
@@ -37,7 +40,9 @@ class DartDependencySetBuilder {
final
String
output
=
runSyncAndThrowStdErrOnError
(
args
);
return
new
Set
<
String
>.
from
(
LineSplitter
.
split
(
output
));
return
new
Set
<
String
>.
from
(
LineSplitter
.
split
(
output
).
map
(
(
String
path
)
=>
fs
.
path
.
canonicalize
(
path
))
);
}
}
...
...
@@ -91,7 +96,8 @@ class _GenSnapshotDartDependencySetBuilder implements DartDependencySetBuilder {
output
=
output
.
substring
(
splitIndex
+
1
);
// Note: next line means we cannot process anything with spaces in the path
// because Makefiles don't support spaces in paths :(
final
List
<
String
>
depsList
=
output
.
trim
().
split
(
' '
);
return
new
Set
<
String
>.
from
(
depsList
);
return
new
Set
<
String
>.
from
(
output
.
trim
().
split
(
' '
).
map
(
(
String
path
)
=>
fs
.
path
.
canonicalize
(
path
)
));
}
}
packages/flutter_tools/lib/src/devfs.dart
View file @
e0c51480
...
...
@@ -512,7 +512,8 @@ class DevFS {
final
String
relativePath
=
fs
.
path
.
relative
(
file
.
path
,
from:
directory
.
path
);
final
Uri
deviceUri
=
directoryUriOnDevice
.
resolveUri
(
fs
.
path
.
toUri
(
relativePath
));
if
((
fileFilter
!=
null
)
&&
!
fileFilter
.
contains
(
file
.
absolute
.
path
))
{
final
String
canonicalizeFilePath
=
fs
.
path
.
canonicalize
(
file
.
absolute
.
path
);
if
((
fileFilter
!=
null
)
&&
!
fileFilter
.
contains
(
canonicalizeFilePath
))
{
// Skip files that are not included in the filter.
continue
;
}
...
...
packages/flutter_tools/test/dart_dependencies_test.dart
View file @
e0c51480
...
...
@@ -19,8 +19,8 @@ void main() {
final
DartDependencySetBuilder
builder
=
new
DartDependencySetBuilder
(
mainPath
,
testPath
,
packagesPath
);
final
Set
<
String
>
dependencies
=
builder
.
build
();
expect
(
dependencies
.
contains
(
mainPath
),
isTrue
);
expect
(
dependencies
.
contains
(
fs
.
path
.
join
(
testPath
,
'foo.dart'
)),
isTrue
);
expect
(
dependencies
.
contains
(
fs
.
path
.
canonicalize
(
mainPath
)
),
isTrue
);
expect
(
dependencies
.
contains
(
fs
.
path
.
canonicalize
(
fs
.
path
.
join
(
testPath
,
'foo.dart'
)
)),
isTrue
);
});
testUsingContext
(
'syntax_error'
,
()
{
final
String
testPath
=
fs
.
path
.
join
(
dataPath
,
'syntax_error'
);
...
...
packages/flutter_tools/test/devfs_test.dart
View file @
e0c51480
...
...
@@ -144,6 +144,31 @@ void main() {
expect
(
devFS
.
assetPathsToEvict
,
isEmpty
);
expect
(
bytes
,
69
);
});
testUsingContext
(
'add new package with double slashes in URI'
,
()
async
{
String
packageName
=
'doubleslashpkg'
;
await
_createPackage
(
packageName
,
'somefile.txt'
,
doubleSlash:
true
);
Set
<
String
>
fileFilter
=
new
Set
<
String
>();
List
<
Uri
>
pkgUris
=
<
Uri
>[
fs
.
path
.
toUri
(
basePath
)]..
addAll
(
_packages
.
values
);
for
(
Uri
pkgUri
in
pkgUris
)
{
if
(!
pkgUri
.
isAbsolute
)
{
pkgUri
=
fs
.
path
.
toUri
(
fs
.
path
.
join
(
basePath
,
pkgUri
.
path
));
}
fileFilter
.
addAll
(
fs
.
directory
(
pkgUri
)
.
listSync
(
recursive:
true
)
.
where
((
FileSystemEntity
file
)
=>
file
is
File
)
.
map
((
FileSystemEntity
file
)
=>
fs
.
path
.
canonicalize
(
file
.
path
))
.
toList
());
}
int
bytes
=
await
devFS
.
update
(
fileFilter:
fileFilter
);
devFSOperations
.
expectMessages
(<
String
>[
'writeFile test .packages'
,
'writeFile test packages/doubleslashpkg/somefile.txt'
,
]);
expect
(
devFS
.
assetPathsToEvict
,
isEmpty
);
expect
(
bytes
,
109
);
});
testUsingContext
(
'add an asset bundle'
,
()
async
{
assetBundle
.
entries
[
'a.txt'
]
=
new
DevFSStringContent
(
'abc'
);
final
int
bytes
=
await
devFS
.
update
(
bundle:
assetBundle
,
bundleDirty:
true
);
...
...
@@ -334,9 +359,15 @@ void _cleanupTempDirs() {
}
}
Future
<
Null
>
_createPackage
(
String
pkgName
,
String
pkgFileName
)
async
{
Future
<
Null
>
_createPackage
(
String
pkgName
,
String
pkgFileName
,
{
bool
doubleSlash:
false
}
)
async
{
final
Directory
pkgTempDir
=
_newTempDir
();
final
File
pkgFile
=
fs
.
file
(
fs
.
path
.
join
(
pkgTempDir
.
path
,
pkgName
,
'lib'
,
pkgFileName
));
String
pkgFilePath
=
fs
.
path
.
join
(
pkgTempDir
.
path
,
pkgName
,
'lib'
,
pkgFileName
);
if
(
doubleSlash
)
{
// Force two separators into the path.
String
doubleSlash
=
fs
.
path
.
separator
+
fs
.
path
.
separator
;
pkgFilePath
=
pkgTempDir
.
path
+
doubleSlash
+
fs
.
path
.
join
(
pkgName
,
'lib'
,
pkgFileName
);
}
final
File
pkgFile
=
fs
.
file
(
pkgFilePath
);
await
pkgFile
.
parent
.
create
(
recursive:
true
);
pkgFile
.
writeAsBytesSync
(<
int
>[
11
,
12
,
13
]);
_packages
[
pkgName
]
=
fs
.
path
.
toUri
(
pkgFile
.
parent
.
path
);
...
...
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