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
2fb53d83
Unverified
Commit
2fb53d83
authored
Nov 06, 2020
by
Jonah Williams
Committed by
GitHub
Nov 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] remove all globals from cache and cache_test (#69505)
parent
9b201dd0
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
603 additions
and
537 deletions
+603
-537
cache.dart
packages/flutter_tools/lib/src/cache.dart
+291
-198
precache.dart
packages/flutter_tools/lib/src/commands/precache.dart
+1
-1
context_runner.dart
packages/flutter_tools/lib/src/context_runner.dart
+1
-0
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+2
-2
flutter_command_runner.dart
.../flutter_tools/lib/src/runner/flutter_command_runner.dart
+1
-1
version.dart
packages/flutter_tools/lib/src/version.dart
+1
-1
precache_test.dart
...ter_tools/test/commands.shard/hermetic/precache_test.dart
+3
-4
gradle_test.dart
...flutter_tools/test/general.shard/android/gradle_test.dart
+1
-1
gradle_utils_test.dart
...r_tools/test/general.shard/android/gradle_utils_test.dart
+2
-2
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+268
-317
project_test.dart
packages/flutter_tools/test/general.shard/project_test.dart
+12
-2
flutter_command_test.dart
...tools/test/general.shard/runner/flutter_command_test.dart
+5
-5
fakes.dart
packages/flutter_tools/test/src/fakes.dart
+5
-2
testbed.dart
packages/flutter_tools/test/src/testbed.dart
+10
-1
No files found.
packages/flutter_tools/lib/src/cache.dart
View file @
2fb53d83
This diff is collapsed.
Click to expand it.
packages/flutter_tools/lib/src/commands/precache.dart
View file @
2fb53d83
...
...
@@ -130,7 +130,7 @@ class PrecacheCommand extends FlutterCommand {
Future
<
FlutterCommandResult
>
runCommand
()
async
{
// Re-lock the cache.
if
(
_platform
.
environment
[
'FLUTTER_ALREADY_LOCKED'
]
!=
'true'
)
{
await
C
ache
.
lock
();
await
_c
ache
.
lock
();
}
if
(
boolArg
(
'force'
))
{
_cache
.
clearStampFiles
();
...
...
packages/flutter_tools/lib/src/context_runner.dart
View file @
2fb53d83
...
...
@@ -120,6 +120,7 @@ Future<T> runInContext<T>(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
platform:
globals
.
platform
,
osUtils:
globals
.
os
,
),
CocoaPods:
()
=>
CocoaPods
(
fileSystem:
globals
.
fs
,
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
2fb53d83
...
...
@@ -962,7 +962,7 @@ abstract class FlutterCommand extends Command<void> {
void
_registerSignalHandlers
(
String
commandPath
,
DateTime
startTime
)
{
final
SignalHandler
handler
=
(
io
.
ProcessSignal
s
)
{
C
ache
.
releaseLock
();
globals
.
c
ache
.
releaseLock
();
_sendPostUsage
(
commandPath
,
const
FlutterCommandResult
(
ExitStatus
.
killed
),
...
...
@@ -1035,7 +1035,7 @@ abstract class FlutterCommand extends Command<void> {
await
globals
.
cache
.
updateAll
(<
DevelopmentArtifact
>{
DevelopmentArtifact
.
universal
});
await
globals
.
cache
.
updateAll
(
await
requiredArtifacts
);
}
C
ache
.
releaseLock
();
globals
.
c
ache
.
releaseLock
();
await
validateCommand
();
...
...
packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
View file @
2fb53d83
...
...
@@ -235,7 +235,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
globals
.
logger
.
quiet
=
topLevelResults
[
'quiet'
]
as
bool
;
if
(
globals
.
platform
.
environment
[
'FLUTTER_ALREADY_LOCKED'
]
!=
'true'
)
{
await
C
ache
.
lock
();
await
globals
.
c
ache
.
lock
();
}
if
(
topLevelResults
[
'suppress-analytics'
]
as
bool
)
{
...
...
packages/flutter_tools/lib/src/version.dart
View file @
2fb53d83
...
...
@@ -484,7 +484,7 @@ class FlutterVersion {
/// Returns null if the cached version is out-of-date or missing, and we are
/// unable to reach the server to get the latest version.
Future
<
DateTime
>
_getLatestAvailableFlutterDate
()
async
{
C
ache
.
checkLockAcquired
();
globals
.
c
ache
.
checkLockAcquired
();
final
VersionCheckStamp
versionCheckStamp
=
await
VersionCheckStamp
.
load
();
if
(
versionCheckStamp
.
lastTimeVersionWasChecked
!=
null
)
{
...
...
packages/flutter_tools/test/commands.shard/hermetic/precache_test.dart
View file @
2fb53d83
...
...
@@ -20,7 +20,7 @@ void main() {
setUp
(()
{
cache
=
MockCache
();
// Release lock between test cases.
C
ache
.
releaseLock
();
c
ache
.
releaseLock
();
when
(
cache
.
isUpToDate
()).
thenAnswer
((
Invocation
_
)
=>
Future
<
bool
>.
value
(
false
));
when
(
cache
.
updateAll
(
any
)).
thenAnswer
((
Invocation
invocation
)
{
...
...
@@ -39,9 +39,8 @@ void main() {
);
await
createTestCommandRunner
(
command
).
run
(
const
<
String
>[
'precache'
]);
expect
(
Cache
.
isLocked
(),
isTrue
);
// Do not throw StateError, lock is acquired.
expect
(()
=>
Cache
.
checkLockAcquired
(
platform
),
returnsNormally
);
expect
(()
=>
cache
.
checkLockAcquired
(
),
returnsNormally
);
});
testUsingContext
(
'precache should not re-entrantly acquire lock'
,
()
async
{
...
...
@@ -62,7 +61,7 @@ void main() {
expect
(
Cache
.
isLocked
(),
isFalse
);
// Do not throw StateError, acquired reentrantly with FLUTTER_ALREADY_LOCKED.
expect
(()
=>
Cache
.
checkLockAcquired
(
platform
),
returnsNormally
);
expect
(()
=>
cache
.
checkLockAcquired
(
),
returnsNormally
);
});
testUsingContext
(
'precache downloads web artifacts on dev branch when feature is enabled.'
,
()
async
{
...
...
packages/flutter_tools/test/general.shard/android/gradle_test.dart
View file @
2fb53d83
...
...
@@ -1024,7 +1024,7 @@ plugin1=${plugin1.path}
when
(
mockAndroidSdk
.
directory
).
thenReturn
(
'irrelevant'
);
final
Directory
rootDirectory
=
fileSystem
.
currentDirectory
;
cache
=
Cache
(
cache
=
Cache
.
test
(
rootOverride:
rootDirectory
,
fileSystem:
fileSystem
,
);
...
...
packages/flutter_tools/test/general.shard/android/gradle_utils_test.dart
View file @
2fb53d83
...
...
@@ -72,7 +72,7 @@ void main() {
'zipStorePath=wrapper/dists
\n
'
'distributionUrl=https
\\
://services.gradle.org/distributions/gradle-5.6.2-all.zip
\n
'
);
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
Cache
(
rootOverride:
tempDir
),
Cache:
()
=>
Cache
.
test
(
rootOverride:
tempDir
,
fileSystem:
memoryFileSystem
),
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
...
...
@@ -113,7 +113,7 @@ void main() {
'zipStorePath=wrapper/dists
\n
'
'distributionUrl=https
\\
://services.gradle.org/distributions/gradle-5.6.2-all.zip
\n
'
);
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
Cache
(
rootOverride:
tempDir
),
Cache:
()
=>
Cache
.
test
(
rootOverride:
tempDir
,
fileSystem:
memoryFileSystem
),
FileSystem:
()
=>
memoryFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
});
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
2fb53d83
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/project_test.dart
View file @
2fb53d83
...
...
@@ -771,7 +771,12 @@ void _testInMemory(String description, Future<void> testMethod()) {
testFileSystem
.
file
(
'.packages'
).
writeAsStringSync
(
'
\n
'
);
// Transfer needed parts of the Flutter installation folder
// to the in-memory file system used during testing.
transfer
(
Cache
().
getArtifactDirectory
(
'gradle_wrapper'
),
testFileSystem
);
transfer
(
Cache
(
fileSystem:
globals
.
fs
,
logger:
globals
.
logger
,
osUtils:
globals
.
os
,
platform:
globals
.
platform
,
).
getArtifactDirectory
(
'gradle_wrapper'
),
testFileSystem
);
transfer
(
globals
.
fs
.
directory
(
Cache
.
flutterRoot
)
.
childDirectory
(
'packages'
)
.
childDirectory
(
'flutter_tools'
)
...
...
@@ -801,7 +806,12 @@ void _testInMemory(String description, Future<void> testMethod()) {
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
testFileSystem
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
Cache:
()
=>
Cache
(),
Cache:
()
=>
Cache
(
logger:
globals
.
logger
,
fileSystem:
globals
.
fs
,
osUtils:
globals
.
os
,
platform:
globals
.
platform
,
),
FlutterProjectFactory:
()
=>
flutterProjectFactory
,
},
);
...
...
packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
View file @
2fb53d83
...
...
@@ -57,7 +57,7 @@ void main() {
testUsingContext
(
'honors shouldUpdateCache false'
,
()
async
{
final
DummyFlutterCommand
flutterCommand
=
DummyFlutterCommand
(
shouldUpdateCache:
false
);
await
flutterCommand
.
run
();
verify
ZeroInteractions
(
cache
);
verify
Never
(
cache
.
updateAll
(
any
)
);
expect
(
flutterCommand
.
deprecated
,
isFalse
);
expect
(
flutterCommand
.
hidden
,
isFalse
);
},
...
...
@@ -352,7 +352,7 @@ void main() {
final
Completer
<
void
>
checkLockCompleter
=
Completer
<
void
>();
final
DummyFlutterCommand
flutterCommand
=
DummyFlutterCommand
(
commandFunction:
()
async
{
await
C
ache
.
lock
();
await
globals
.
c
ache
.
lock
();
checkLockCompleter
.
complete
();
final
Completer
<
void
>
c
=
Completer
<
void
>();
await
c
.
future
;
...
...
@@ -362,13 +362,13 @@ void main() {
unawaited
(
flutterCommand
.
run
());
await
checkLockCompleter
.
future
;
C
ache
.
checkLockAcquired
();
globals
.
c
ache
.
checkLockAcquired
();
signalController
.
add
(
mockSignal
);
await
completer
.
future
;
await
C
ache
.
lock
();
C
ache
.
releaseLock
();
await
globals
.
c
ache
.
lock
();
globals
.
c
ache
.
releaseLock
();
},
overrides:
<
Type
,
Generator
>{
ProcessInfo:
()
=>
mockProcessInfo
,
Signals:
()
=>
FakeSignals
(
...
...
packages/flutter_tools/test/src/fakes.dart
View file @
2fb53d83
...
...
@@ -4,6 +4,9 @@
import
'dart:async'
;
import
'package:flutter_tools/src/base/file_system.dart'
;
import
'package:flutter_tools/src/base/logger.dart'
;
import
'package:flutter_tools/src/base/os.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/device.dart'
;
...
...
@@ -51,12 +54,12 @@ class FakeDyldEnvironmentArtifact extends ArtifactSet {
};
@override
Future
<
bool
>
isUpToDate
()
=>
Future
<
bool
>.
value
(
true
);
Future
<
bool
>
isUpToDate
(
FileSystem
fileSystem
)
=>
Future
<
bool
>.
value
(
true
);
@override
String
get
name
=>
'fake'
;
@override
Future
<
void
>
update
(
ArtifactUpdater
artifactUpdater
)
async
{
Future
<
void
>
update
(
ArtifactUpdater
artifactUpdater
,
Logger
logger
,
FileSystem
fileSystem
,
OperatingSystemUtils
operatingSystemUtils
)
async
{
}
}
packages/flutter_tools/test/src/testbed.dart
View file @
2fb53d83
...
...
@@ -897,5 +897,14 @@ class FakeCache implements Cache {
}
@override
void
clearStampFiles
()
{}
void
clearStampFiles
()
{
}
@override
void
checkLockAcquired
()
{
}
@override
Future
<
void
>
lock
()
async
{
}
@override
void
releaseLock
()
{
}
}
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