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
87d6e93c
Commit
87d6e93c
authored
Jan 09, 2019
by
KyleWong
Committed by
xster
Jan 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve the intergrity checking for "gradle wrapper". (#26069)
parent
6412f35c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
cache.dart
packages/flutter_tools/lib/src/cache.dart
+20
-0
cache_test.dart
packages/flutter_tools/test/cache_test.dart
+31
-0
No files found.
packages/flutter_tools/lib/src/cache.dart
View file @
87d6e93c
...
@@ -576,6 +576,10 @@ class FlutterEngine extends CachedArtifact {
...
@@ -576,6 +576,10 @@ class FlutterEngine extends CachedArtifact {
class
GradleWrapper
extends
CachedArtifact
{
class
GradleWrapper
extends
CachedArtifact
{
GradleWrapper
(
Cache
cache
):
super
(
'gradle_wrapper'
,
cache
);
GradleWrapper
(
Cache
cache
):
super
(
'gradle_wrapper'
,
cache
);
List
<
String
>
get
_gradleScripts
=>
<
String
>[
'gradlew'
,
'gradlew.bat'
];
String
get
_gradleWrapper
=>
fs
.
path
.
join
(
'gradle'
,
'wrapper'
,
'gradle-wrapper.jar'
);
@override
@override
Future
<
void
>
updateInner
()
{
Future
<
void
>
updateInner
()
{
final
Uri
archiveUri
=
_toStorageUri
(
version
);
final
Uri
archiveUri
=
_toStorageUri
(
version
);
...
@@ -586,6 +590,22 @@ class GradleWrapper extends CachedArtifact {
...
@@ -586,6 +590,22 @@ class GradleWrapper extends CachedArtifact {
fs
.
file
(
fs
.
path
.
join
(
location
.
path
,
'NOTICE'
)).
deleteSync
();
fs
.
file
(
fs
.
path
.
join
(
location
.
path
,
'NOTICE'
)).
deleteSync
();
});
});
}
}
@override
bool
isUpToDateInner
()
{
final
Directory
wrapperDir
=
cache
.
getCacheDir
(
fs
.
path
.
join
(
'artifacts'
,
'gradle_wrapper'
));
if
(!
fs
.
directory
(
wrapperDir
).
existsSync
())
return
false
;
for
(
String
scriptName
in
_gradleScripts
)
{
final
File
scriptFile
=
fs
.
file
(
fs
.
path
.
join
(
wrapperDir
.
path
,
scriptName
));
if
(!
scriptFile
.
existsSync
())
return
false
;
}
final
File
gradleWrapperJar
=
fs
.
file
(
fs
.
path
.
join
(
wrapperDir
.
path
,
_gradleWrapper
));
if
(!
gradleWrapperJar
.
existsSync
())
return
false
;
return
true
;
}
}
}
// Many characters are problematic in filenames, especially on Windows.
// Many characters are problematic in filenames, especially on Windows.
...
...
packages/flutter_tools/test/cache_test.dart
View file @
87d6e93c
...
@@ -51,6 +51,36 @@ void main() {
...
@@ -51,6 +51,36 @@ void main() {
});
});
group
(
'Cache'
,
()
{
group
(
'Cache'
,
()
{
final
MockCache
mockCache
=
MockCache
();
final
MemoryFileSystem
fs
=
MemoryFileSystem
();
testUsingContext
(
'Gradle wrapper should not be up to date, if some cached artifact is not available'
,
()
{
final
GradleWrapper
gradleWrapper
=
GradleWrapper
(
mockCache
);
final
Directory
directory
=
fs
.
directory
(
'/Applications/flutter/bin/cache'
);
directory
.
createSync
(
recursive:
true
);
fs
.
file
(
fs
.
path
.
join
(
directory
.
path
,
'artifacts'
,
'gradle_wrapper'
,
'gradle'
,
'wrapper'
,
'gradle-wrapper.jar'
)).
createSync
(
recursive:
true
);
when
(
mockCache
.
getCacheDir
(
fs
.
path
.
join
(
'artifacts'
,
'gradle_wrapper'
))).
thenReturn
(
fs
.
directory
(
fs
.
path
.
join
(
directory
.
path
,
'artifacts'
,
'gradle_wrapper'
)));
expect
(
gradleWrapper
.
isUpToDateInner
(),
false
);
},
overrides:
<
Type
,
Generator
>{
Cache:
()=>
mockCache
,
FileSystem:
()
=>
fs
});
testUsingContext
(
'Gradle wrapper should be up to date, only if all cached artifact are available'
,
()
{
final
GradleWrapper
gradleWrapper
=
GradleWrapper
(
mockCache
);
final
Directory
directory
=
fs
.
directory
(
'/Applications/flutter/bin/cache'
);
directory
.
createSync
(
recursive:
true
);
fs
.
file
(
fs
.
path
.
join
(
directory
.
path
,
'artifacts'
,
'gradle_wrapper'
,
'gradle'
,
'wrapper'
,
'gradle-wrapper.jar'
)).
createSync
(
recursive:
true
);
fs
.
file
(
fs
.
path
.
join
(
directory
.
path
,
'artifacts'
,
'gradle_wrapper'
,
'gradlew'
)).
createSync
(
recursive:
true
);
fs
.
file
(
fs
.
path
.
join
(
directory
.
path
,
'artifacts'
,
'gradle_wrapper'
,
'gradlew.bat'
)).
createSync
(
recursive:
true
);
when
(
mockCache
.
getCacheDir
(
fs
.
path
.
join
(
'artifacts'
,
'gradle_wrapper'
))).
thenReturn
(
fs
.
directory
(
fs
.
path
.
join
(
directory
.
path
,
'artifacts'
,
'gradle_wrapper'
)));
expect
(
gradleWrapper
.
isUpToDateInner
(),
true
);
},
overrides:
<
Type
,
Generator
>{
Cache:
()=>
mockCache
,
FileSystem:
()
=>
fs
});
test
(
'should not be up to date, if some cached artifact is not'
,
()
{
test
(
'should not be up to date, if some cached artifact is not'
,
()
{
final
CachedArtifact
artifact1
=
MockCachedArtifact
();
final
CachedArtifact
artifact1
=
MockCachedArtifact
();
final
CachedArtifact
artifact2
=
MockCachedArtifact
();
final
CachedArtifact
artifact2
=
MockCachedArtifact
();
...
@@ -132,3 +162,4 @@ class MockFile extends Mock implements File {
...
@@ -132,3 +162,4 @@ class MockFile extends Mock implements File {
class
MockRandomAccessFile
extends
Mock
implements
RandomAccessFile
{}
class
MockRandomAccessFile
extends
Mock
implements
RandomAccessFile
{}
class
MockCachedArtifact
extends
Mock
implements
CachedArtifact
{}
class
MockCachedArtifact
extends
Mock
implements
CachedArtifact
{}
class
MockInternetAddress
extends
Mock
implements
InternetAddress
{}
class
MockInternetAddress
extends
Mock
implements
InternetAddress
{}
class
MockCache
extends
Mock
implements
Cache
{}
\ No newline at end of file
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