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
0a59698e
Unverified
Commit
0a59698e
authored
Apr 06, 2021
by
Jonah Williams
Committed by
GitHub
Apr 06, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] migrate cache to null safety (#79864)
parent
4d1b74a0
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
140 additions
and
95 deletions
+140
-95
cache.dart
packages/flutter_tools/lib/src/cache.dart
+82
-67
build_ios_framework_test.dart
...est/commands.shard/hermetic/build_ios_framework_test.dart
+1
-0
devices_test.dart
...tter_tools/test/commands.shard/hermetic/devices_test.dart
+1
-1
install_test.dart
...tter_tools/test/commands.shard/hermetic/install_test.dart
+3
-3
run_test.dart
.../flutter_tools/test/commands.shard/hermetic/run_test.dart
+1
-1
cache_test.dart
packages/flutter_tools/test/general.shard/cache_test.dart
+37
-16
devices_test.dart
...es/flutter_tools/test/general.shard/ios/devices_test.dart
+5
-3
ios_deploy_test.dart
...flutter_tools/test/general.shard/ios/ios_deploy_test.dart
+1
-0
ios_device_install_test.dart
...tools/test/general.shard/ios/ios_device_install_test.dart
+1
-0
ios_device_logger_test.dart
..._tools/test/general.shard/ios/ios_device_logger_test.dart
+1
-1
ios_device_start_nonprebuilt_test.dart
.../general.shard/ios/ios_device_start_nonprebuilt_test.dart
+1
-0
ios_device_start_prebuilt_test.dart
...est/general.shard/ios/ios_device_start_prebuilt_test.dart
+1
-0
mac_test.dart
packages/flutter_tools/test/general.shard/ios/mac_test.dart
+3
-1
xcode_test.dart
...es/flutter_tools/test/general.shard/macos/xcode_test.dart
+2
-2
No files found.
packages/flutter_tools/lib/src/cache.dart
View file @
0a59698e
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/commands.shard/hermetic/build_ios_framework_test.dart
View file @
0a59698e
...
...
@@ -53,6 +53,7 @@ void main() {
rootOverride:
rootOverride
,
platform:
fakePlatform
,
fileSystem:
memoryFileSystem
,
processManager:
FakeProcessManager
.
any
(),
);
rootOverride
.
childDirectory
(
'bin'
).
childDirectory
(
'internal'
).
childFile
(
'engine.version'
)
..
createSync
(
recursive:
true
)
...
...
packages/flutter_tools/test/commands.shard/hermetic/devices_test.dart
View file @
0a59698e
...
...
@@ -26,7 +26,7 @@ void main() {
Cache
cache
;
setUp
(()
{
cache
=
Cache
.
test
();
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
});
testUsingContext
(
'returns 0 when called'
,
()
async
{
...
...
packages/flutter_tools/test/commands.shard/hermetic/install_test.dart
View file @
0a59698e
...
...
@@ -37,7 +37,7 @@ void main() {
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'install'
]);
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
Cache
.
test
(),
Cache:
()
=>
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
),
});
testUsingContext
(
'returns 1 when targeted device is not Android with --device-user'
,
()
async
{
...
...
@@ -54,7 +54,7 @@ void main() {
expect
(()
async
=>
createTestCommandRunner
(
command
).
run
(<
String
>[
'install'
,
'--device-user'
,
'10'
]),
throwsToolExit
(
message:
'--device-user is only supported for Android'
));
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
Cache
.
test
(),
Cache:
()
=>
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
),
});
testUsingContext
(
'returns 0 when iOS is connected and ready for an install'
,
()
async
{
...
...
@@ -68,7 +68,7 @@ void main() {
await
createTestCommandRunner
(
command
).
run
(<
String
>[
'install'
]);
},
overrides:
<
Type
,
Generator
>{
Cache:
()
=>
Cache
.
test
(),
Cache:
()
=>
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
),
});
});
}
...
...
packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
View file @
0a59698e
...
...
@@ -382,7 +382,7 @@ void main() {
)));
},
overrides:
<
Type
,
Generator
>{
Artifacts:
()
=>
artifacts
,
Cache:
()
=>
Cache
.
test
(),
Cache:
()
=>
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
),
DeviceManager:
()
=>
mockDeviceManager
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
...
packages/flutter_tools/test/general.shard/cache_test.dart
View file @
0a59698e
...
...
@@ -65,13 +65,13 @@ void main() {
});
testWithoutContext
(
'should throw when locking is not acquired'
,
()
{
final
Cache
cache
=
Cache
.
test
();
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
expect
(
cache
.
checkLockAcquired
,
throwsStateError
);
});
testWithoutContext
(
'should not throw when locking is disabled'
,
()
{
final
Cache
cache
=
Cache
.
test
();
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
Cache
.
disableLocking
();
expect
(
cache
.
checkLockAcquired
,
returnsNormally
);
...
...
@@ -80,7 +80,7 @@ void main() {
testWithoutContext
(
'should not throw when lock is acquired'
,
()
async
{
Cache
.
flutterRoot
=
''
;
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Cache
cache
=
Cache
.
test
(
fileSystem:
fileSystem
);
final
Cache
cache
=
Cache
.
test
(
fileSystem:
fileSystem
,
processManager:
FakeProcessManager
.
any
()
);
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'lockfile'
))
.
createSync
(
recursive:
true
);
...
...
@@ -92,7 +92,7 @@ void main() {
testWithoutContext
(
'throws tool exit when lockfile open fails'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Cache
cache
=
Cache
.
test
(
fileSystem:
fileSystem
);
final
Cache
cache
=
Cache
.
test
(
fileSystem:
fileSystem
,
processManager:
FakeProcessManager
.
any
()
);
fileSystem
.
file
(
fileSystem
.
path
.
join
(
'bin'
,
'cache'
,
'lockfile'
))
.
createSync
(
recursive:
true
);
...
...
@@ -100,9 +100,12 @@ void main() {
},
skip:
true
);
// TODO(jonahwilliams): implement support for lock so this can be tested with the memory file system.
testWithoutContext
(
'should not throw when FLUTTER_ALREADY_LOCKED is set'
,
()
{
final
Cache
cache
=
Cache
.
test
(
platform:
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ALREADY_LOCKED'
:
'true'
,
}));
final
Cache
cache
=
Cache
.
test
(
platform:
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_ALREADY_LOCKED'
:
'true'
,
}),
processManager:
FakeProcessManager
.
any
(),
);
expect
(
cache
.
checkLockAcquired
,
returnsNormally
);
});
...
...
@@ -116,6 +119,7 @@ void main() {
final
Directory
artifactDir
=
fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_artifact.'
);
final
Directory
downloadDir
=
fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_download.'
);
when
(
mockCache
.
getVersionFor
(
any
)).
thenReturn
(
'asdasd'
);
when
(
mockCache
.
getArtifactDirectory
(
any
)).
thenReturn
(
artifactDir
);
when
(
mockCache
.
getDownloadDir
()).
thenReturn
(
downloadDir
);
when
(
mockCache
.
setStampFor
(
any
,
any
)).
thenAnswer
((
_
)
{
...
...
@@ -127,6 +131,22 @@ void main() {
expect
(
logger
.
errorText
,
contains
(
'stamp write failed'
));
});
testWithoutContext
(
'Continues on missing version file'
,
()
async
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
BufferLogger
logger
=
BufferLogger
.
test
();
final
Cache
mockCache
=
MockCache
();
final
Directory
artifactDir
=
fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_artifact.'
);
final
Directory
downloadDir
=
fileSystem
.
systemTempDirectory
.
createTempSync
(
'flutter_cache_test_download.'
);
when
(
mockCache
.
getVersionFor
(
any
)).
thenReturn
(
null
);
// version is missing.
when
(
mockCache
.
getArtifactDirectory
(
any
)).
thenReturn
(
artifactDir
);
when
(
mockCache
.
getDownloadDir
()).
thenReturn
(
downloadDir
);
final
FakeSimpleArtifact
artifact
=
FakeSimpleArtifact
(
mockCache
);
await
artifact
.
update
(
MockArtifactUpdater
(),
logger
,
fileSystem
,
MockOperatingSystemUtils
());
expect
(
logger
.
errorText
,
contains
(
'No known version for the artifact name "fake"'
));
});
testWithoutContext
(
'Gradle wrapper should not be up to date, if some cached artifact is not available'
,
()
{
final
FileSystem
fileSystem
=
MemoryFileSystem
.
test
();
final
Cache
cache
=
Cache
.
test
(
fileSystem:
fileSystem
,
processManager:
FakeProcessManager
.
any
());
...
...
@@ -287,9 +307,10 @@ void main() {
testWithoutContext
(
'Invalid URI for FLUTTER_STORAGE_BASE_URL throws ToolExit'
,
()
async
{
final
Cache
cache
=
Cache
.
test
(
platform:
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_STORAGE_BASE_URL'
:
' http://foo'
,
},
));
'FLUTTER_STORAGE_BASE_URL'
:
' http://foo'
,
}),
processManager:
FakeProcessManager
.
any
(),
);
expect
(()
=>
cache
.
storageBaseUrl
,
throwsToolExit
());
});
...
...
@@ -400,7 +421,7 @@ void main() {
});
testWithoutContext
(
'IosUsbArtifacts uses unsigned when specified'
,
()
async
{
final
Cache
cache
=
Cache
.
test
();
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
cache
.
useUnsignedMacBinaries
=
true
;
final
IosUsbArtifacts
iosUsbArtifacts
=
IosUsbArtifacts
(
'name'
,
cache
,
platform:
FakePlatform
(
operatingSystem:
'macos'
));
...
...
@@ -408,7 +429,7 @@ void main() {
});
testWithoutContext
(
'IosUsbArtifacts does not use unsigned when not specified'
,
()
async
{
final
Cache
cache
=
Cache
.
test
();
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
final
IosUsbArtifacts
iosUsbArtifacts
=
IosUsbArtifacts
(
'name'
,
cache
,
platform:
FakePlatform
(
operatingSystem:
'macos'
));
expect
(
iosUsbArtifacts
.
archiveUri
.
toString
(),
isNot
(
contains
(
'/unsigned/'
)));
...
...
@@ -437,7 +458,7 @@ void main() {
});
testWithoutContext
(
'FontSubset in universal artifacts'
,
()
{
final
Cache
cache
=
Cache
.
test
();
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
final
FontSubsetArtifacts
artifacts
=
FontSubsetArtifacts
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
));
expect
(
artifacts
.
developmentArtifact
,
DevelopmentArtifact
.
universal
);
...
...
@@ -535,7 +556,7 @@ void main() {
});
testWithoutContext
(
'macOS desktop artifacts ignore filtering when requested'
,
()
{
final
Cache
cache
=
Cache
.
test
();
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
final
MacOSEngineArtifacts
artifacts
=
MacOSEngineArtifacts
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
));
cache
.
includeAllPlatforms
=
false
;
cache
.
platformOverrideArtifacts
=
<
String
>{
'macos'
};
...
...
@@ -544,7 +565,7 @@ void main() {
});
testWithoutContext
(
'Windows desktop artifacts ignore filtering when requested'
,
()
{
final
Cache
cache
=
Cache
.
test
();
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
final
WindowsEngineArtifacts
artifacts
=
WindowsEngineArtifacts
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'linux'
),
...
...
@@ -556,7 +577,7 @@ void main() {
});
testWithoutContext
(
'Windows desktop artifacts include profile and release artifacts'
,
()
{
final
Cache
cache
=
Cache
.
test
();
final
Cache
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
final
WindowsEngineArtifacts
artifacts
=
WindowsEngineArtifacts
(
cache
,
platform:
FakePlatform
(
operatingSystem:
'windows'
),
...
...
packages/flutter_tools/test/general.shard/ios/devices_test.dart
View file @
0a59698e
...
...
@@ -45,7 +45,7 @@ void main() {
setUp
(()
{
final
Artifacts
artifacts
=
Artifacts
.
test
();
cache
=
Cache
.
test
();
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
logger
=
BufferLogger
.
test
();
iosDeploy
=
IOSDeploy
(
artifacts:
artifacts
,
...
...
@@ -248,7 +248,9 @@ void main() {
mockProcess2
=
MockProcess
();
mockProcess3
=
MockProcess
();
forwardedPort
=
ForwardedPort
.
withContext
(
123
,
456
,
mockProcess3
);
cache
=
Cache
.
test
();
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
(),
);
iosDeploy
=
IOSDeploy
(
artifacts:
Artifacts
.
test
(),
cache:
cache
,
...
...
@@ -302,7 +304,7 @@ void main() {
setUp
(()
{
mockXcdevice
=
MockXcdevice
();
final
Artifacts
artifacts
=
Artifacts
.
test
();
cache
=
Cache
.
test
();
cache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
logger
=
BufferLogger
.
test
();
mockIosWorkflow
=
MockIOSWorkflow
();
fakeProcessManager
=
FakeProcessManager
.
any
();
...
...
packages/flutter_tools/test/general.shard/ios/ios_deploy_test.dart
View file @
0a59698e
...
...
@@ -336,6 +336,7 @@ IOSDeploy setUpIOSDeploy(ProcessManager processManager, {
artifacts:
<
ArtifactSet
>[
FakeDyldEnvironmentArtifact
(),
],
processManager:
FakeProcessManager
.
any
(),
);
return
IOSDeploy
(
...
...
packages/flutter_tools/test/general.shard/ios/ios_device_install_test.dart
View file @
0a59698e
...
...
@@ -288,6 +288,7 @@ IOSDevice setUpIOSDevice({
artifacts:
<
ArtifactSet
>[
FakeDyldEnvironmentArtifact
(),
],
processManager:
FakeProcessManager
.
any
(),
);
return
IOSDevice
(
'1234'
,
...
...
packages/flutter_tools/test/general.shard/ios/ios_device_logger_test.dart
View file @
0a59698e
...
...
@@ -31,7 +31,7 @@ void main() {
setUp
(()
{
processManager
=
FakeProcessManager
.
list
(<
FakeCommand
>[]);
fakeCache
=
Cache
.
test
();
fakeCache
=
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
);
artifacts
=
Artifacts
.
test
();
logger
=
BufferLogger
.
test
();
ideviceSyslogPath
=
artifacts
.
getArtifactPath
(
Artifact
.
idevicesyslog
,
platform:
TargetPlatform
.
ios
);
...
...
packages/flutter_tools/test/general.shard/ios/ios_device_start_nonprebuilt_test.dart
View file @
0a59698e
...
...
@@ -351,6 +351,7 @@ IOSDevice setUpIOSDevice({
artifacts:
<
ArtifactSet
>[
FakeDyldEnvironmentArtifact
(),
],
processManager:
FakeProcessManager
.
any
(),
);
logger
??=
BufferLogger
.
test
();
...
...
packages/flutter_tools/test/general.shard/ios/ios_device_start_prebuilt_test.dart
View file @
0a59698e
...
...
@@ -313,6 +313,7 @@ IOSDevice setUpIOSDevice({
artifacts:
<
ArtifactSet
>[
FakeDyldEnvironmentArtifact
(),
],
processManager:
FakeProcessManager
.
any
(),
);
return
IOSDevice
(
'123'
,
...
...
packages/flutter_tools/test/general.shard/ios/mac_test.dart
View file @
0a59698e
...
...
@@ -46,7 +46,9 @@ void main() {
cache
=
Cache
.
test
(
artifacts:
<
ArtifactSet
>[
FakeDyldEnvironmentArtifact
(),
]);
],
processManager:
FakeProcessManager
.
any
(),
);
});
group
(
'screenshot'
,
()
{
...
...
packages/flutter_tools/test/general.shard/macos/xcode_test.dart
View file @
0a59698e
...
...
@@ -354,7 +354,7 @@ void main() {
xcode:
xcode
,
platform:
null
,
artifacts:
Artifacts
.
test
(),
cache:
Cache
.
test
(),
cache:
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
),
iproxy:
IProxy
.
test
(
logger:
logger
,
processManager:
fakeProcessManager
),
);
});
...
...
@@ -382,7 +382,7 @@ void main() {
xcode:
xcode
,
platform:
null
,
artifacts:
Artifacts
.
test
(),
cache:
Cache
.
test
(),
cache:
Cache
.
test
(
processManager:
FakeProcessManager
.
any
()
),
iproxy:
IProxy
.
test
(
logger:
logger
,
processManager:
fakeProcessManager
),
);
});
...
...
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