[flutter_tools] migrate cache to null safety (#79864)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -26,7 +26,7 @@ void main() {
|
||||
Cache cache;
|
||||
|
||||
setUp(() {
|
||||
cache = Cache.test();
|
||||
cache = Cache.test(processManager: FakeProcessManager.any());
|
||||
});
|
||||
|
||||
testUsingContext('returns 0 when called', () async {
|
||||
|
||||
@@ -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()),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -336,6 +336,7 @@ IOSDeploy setUpIOSDeploy(ProcessManager processManager, {
|
||||
artifacts: <ArtifactSet>[
|
||||
FakeDyldEnvironmentArtifact(),
|
||||
],
|
||||
processManager: FakeProcessManager.any(),
|
||||
);
|
||||
|
||||
return IOSDeploy(
|
||||
|
||||
@@ -288,6 +288,7 @@ IOSDevice setUpIOSDevice({
|
||||
artifacts: <ArtifactSet>[
|
||||
FakeDyldEnvironmentArtifact(),
|
||||
],
|
||||
processManager: FakeProcessManager.any(),
|
||||
);
|
||||
return IOSDevice(
|
||||
'1234',
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -351,6 +351,7 @@ IOSDevice setUpIOSDevice({
|
||||
artifacts: <ArtifactSet>[
|
||||
FakeDyldEnvironmentArtifact(),
|
||||
],
|
||||
processManager: FakeProcessManager.any(),
|
||||
);
|
||||
|
||||
logger ??= BufferLogger.test();
|
||||
|
||||
@@ -313,6 +313,7 @@ IOSDevice setUpIOSDevice({
|
||||
artifacts: <ArtifactSet>[
|
||||
FakeDyldEnvironmentArtifact(),
|
||||
],
|
||||
processManager: FakeProcessManager.any(),
|
||||
);
|
||||
|
||||
return IOSDevice('123',
|
||||
|
||||
@@ -46,7 +46,9 @@ void main() {
|
||||
cache = Cache.test(
|
||||
artifacts: <ArtifactSet>[
|
||||
FakeDyldEnvironmentArtifact(),
|
||||
]);
|
||||
],
|
||||
processManager: FakeProcessManager.any(),
|
||||
);
|
||||
});
|
||||
|
||||
group('screenshot', () {
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user