Parse engine src path from an absolute --local-engine (#78496)
This commit is contained in:
@@ -96,6 +96,79 @@ void main() {
|
||||
expect(logger.traceText, contains('Local engine source at /arbitrary/engine/src'));
|
||||
});
|
||||
|
||||
testWithoutContext('works if --local-engine is specified and --local-engine-src-path '
|
||||
'is determined by --local-engine', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final Directory localEngine = fileSystem
|
||||
.directory('$kArbitraryEngineRoot/src/out/ios_debug/')
|
||||
..createSync(recursive: true);
|
||||
fileSystem.directory('$kArbitraryEngineRoot/src/out/host_debug/').createSync(recursive: true);
|
||||
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final LocalEngineLocator localEngineLocator = LocalEngineLocator(
|
||||
fileSystem: fileSystem,
|
||||
flutterRoot: 'flutter/flutter',
|
||||
logger: logger,
|
||||
userMessages: UserMessages(),
|
||||
platform: FakePlatform(environment: <String, String>{}),
|
||||
);
|
||||
|
||||
expect(
|
||||
await localEngineLocator.findEnginePath(null, localEngine.path, null),
|
||||
matchesEngineBuildPaths(
|
||||
hostEngine: '/arbitrary/engine/src/out/host_debug',
|
||||
targetEngine: '/arbitrary/engine/src/out/ios_debug',
|
||||
),
|
||||
);
|
||||
expect(logger.traceText, contains('Parsed engine source from local engine as /arbitrary/engine/src'));
|
||||
expect(logger.traceText, contains('Local engine source at /arbitrary/engine/src'));
|
||||
});
|
||||
|
||||
testWithoutContext('works if local engine is host engine', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final Directory localEngine = fileSystem
|
||||
.directory('$kArbitraryEngineRoot/src/out/host_debug/')
|
||||
..createSync(recursive: true);
|
||||
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final LocalEngineLocator localEngineLocator = LocalEngineLocator(
|
||||
fileSystem: fileSystem,
|
||||
flutterRoot: 'flutter/flutter',
|
||||
logger: logger,
|
||||
userMessages: UserMessages(),
|
||||
platform: FakePlatform(environment: <String, String>{}),
|
||||
);
|
||||
|
||||
expect(
|
||||
await localEngineLocator.findEnginePath(null, localEngine.path, null),
|
||||
matchesEngineBuildPaths(
|
||||
hostEngine: '/arbitrary/engine/src/out/host_debug',
|
||||
targetEngine: '/arbitrary/engine/src/out/host_debug',
|
||||
),
|
||||
);
|
||||
expect(logger.traceText, contains('Local engine source at /arbitrary/engine/src'));
|
||||
});
|
||||
|
||||
testWithoutContext('fails if host_debug does not exist', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final Directory localEngine = fileSystem
|
||||
.directory('$kArbitraryEngineRoot/src/out/ios_debug/')
|
||||
..createSync(recursive: true);
|
||||
|
||||
final LocalEngineLocator localEngineLocator = LocalEngineLocator(
|
||||
fileSystem: fileSystem,
|
||||
flutterRoot: 'flutter/flutter',
|
||||
logger: BufferLogger.test(),
|
||||
userMessages: UserMessages(),
|
||||
platform: FakePlatform(environment: <String, String>{}),
|
||||
);
|
||||
|
||||
await expectToolExitLater(
|
||||
localEngineLocator.findEnginePath(null, localEngine.path, null),
|
||||
contains('No Flutter engine build found at /arbitrary/engine/src/out/host_debug'),
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('works if --local-engine is specified and --local-engine-src-path '
|
||||
'is determined by flutter root', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
@@ -128,6 +201,24 @@ void main() {
|
||||
);
|
||||
expect(logger.traceText, contains('Local engine source at flutter/engine/src'));
|
||||
});
|
||||
|
||||
testWithoutContext('fails if --local-engine is specified and --local-engine-src-path '
|
||||
'cannot be determined', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
|
||||
final LocalEngineLocator localEngineLocator = LocalEngineLocator(
|
||||
fileSystem: fileSystem,
|
||||
flutterRoot: 'flutter/flutter',
|
||||
logger: BufferLogger.test(),
|
||||
userMessages: UserMessages(),
|
||||
platform: FakePlatform(environment: <String, String>{}),
|
||||
);
|
||||
|
||||
await expectToolExitLater(
|
||||
localEngineLocator.findEnginePath(null, '/path/to/nothing', null),
|
||||
contains('Unable to detect local Flutter engine src directory'),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Matcher matchesEngineBuildPaths({
|
||||
|
||||
Reference in New Issue
Block a user