2019-11-27 23:04:02 +00:00
|
|
|
// Copyright 2014 The Flutter Authors. All rights reserved.
|
2017-02-17 07:10:11 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-01-27 23:17:53 +00:00
|
|
|
// @dart = 2.8
|
|
|
|
|
2019-07-18 22:29:06 +00:00
|
|
|
import 'package:file/memory.dart';
|
2019-07-29 14:24:02 +00:00
|
|
|
import 'package:flutter_tools/src/artifacts.dart';
|
2017-02-17 07:10:11 +00:00
|
|
|
import 'package:flutter_tools/src/base/file_system.dart';
|
2020-05-06 15:15:39 +00:00
|
|
|
import 'package:flutter_tools/src/base/logger.dart';
|
|
|
|
import 'package:flutter_tools/src/base/platform.dart';
|
2017-02-17 07:10:11 +00:00
|
|
|
import 'package:flutter_tools/src/build_info.dart';
|
|
|
|
import 'package:flutter_tools/src/cache.dart';
|
|
|
|
|
2019-07-13 18:51:44 +00:00
|
|
|
import '../src/common.dart';
|
2021-04-22 17:44:02 +00:00
|
|
|
import '../src/fake_process_manager.dart';
|
|
|
|
import '../src/fakes.dart';
|
2017-02-17 07:10:11 +00:00
|
|
|
|
|
|
|
void main() {
|
2020-01-15 00:47:34 +00:00
|
|
|
group('CachedArtifacts', () {
|
|
|
|
CachedArtifacts artifacts;
|
|
|
|
Cache cache;
|
|
|
|
FileSystem fileSystem;
|
|
|
|
Platform platform;
|
2017-02-17 07:10:11 +00:00
|
|
|
|
|
|
|
setUp(() {
|
2020-09-30 00:50:33 +00:00
|
|
|
fileSystem = MemoryFileSystem.test();
|
2020-01-15 00:47:34 +00:00
|
|
|
final Directory cacheRoot = fileSystem.directory('root')
|
|
|
|
..createSync();
|
|
|
|
platform = FakePlatform(operatingSystem: 'linux');
|
|
|
|
cache = Cache(
|
|
|
|
rootOverride: cacheRoot,
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
platform: platform,
|
2020-03-03 00:23:56 +00:00
|
|
|
logger: BufferLogger.test(),
|
2021-02-12 22:25:30 +00:00
|
|
|
osUtils: FakeOperatingSystemUtils(),
|
2021-04-05 21:26:02 +00:00
|
|
|
artifacts: <ArtifactSet>[],
|
2020-01-15 00:47:34 +00:00
|
|
|
);
|
|
|
|
artifacts = CachedArtifacts(
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
cache: cache,
|
|
|
|
platform: platform,
|
2021-02-12 22:25:30 +00:00
|
|
|
operatingSystemUtils: FakeOperatingSystemUtils(),
|
2020-01-15 00:47:34 +00:00
|
|
|
);
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('getArtifactPath', () {
|
2020-12-04 21:57:11 +00:00
|
|
|
final String xcframeworkPath = artifacts.getArtifactPath(
|
|
|
|
Artifact.flutterXcframework,
|
|
|
|
platform: TargetPlatform.ios,
|
|
|
|
mode: BuildMode.release,
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
xcframeworkPath,
|
|
|
|
fileSystem.path.join(
|
|
|
|
'root',
|
|
|
|
'bin',
|
|
|
|
'cache',
|
|
|
|
'artifacts',
|
|
|
|
'engine',
|
|
|
|
'ios-release',
|
|
|
|
'Flutter.xcframework',
|
|
|
|
),
|
|
|
|
);
|
2020-01-15 00:47:34 +00:00
|
|
|
expect(
|
2020-12-04 21:57:11 +00:00
|
|
|
() => artifacts.getArtifactPath(
|
|
|
|
Artifact.flutterFramework,
|
|
|
|
platform: TargetPlatform.ios,
|
|
|
|
mode: BuildMode.release,
|
|
|
|
environmentType: EnvironmentType.simulator,
|
|
|
|
),
|
|
|
|
throwsToolExit(
|
|
|
|
message:
|
2021-02-03 21:14:38 +00:00
|
|
|
'No xcframework found at $xcframeworkPath.'),
|
2020-12-04 21:57:11 +00:00
|
|
|
);
|
|
|
|
fileSystem.directory(xcframeworkPath).createSync(recursive: true);
|
|
|
|
expect(
|
|
|
|
() => artifacts.getArtifactPath(
|
|
|
|
Artifact.flutterFramework,
|
|
|
|
platform: TargetPlatform.ios,
|
|
|
|
mode: BuildMode.release,
|
|
|
|
environmentType: EnvironmentType.simulator,
|
|
|
|
),
|
|
|
|
throwsToolExit(message: 'No iOS frameworks found in $xcframeworkPath'),
|
|
|
|
);
|
|
|
|
|
|
|
|
fileSystem
|
|
|
|
.directory(xcframeworkPath)
|
|
|
|
.childDirectory('ios-x86_64-simulator')
|
|
|
|
.childDirectory('Flutter.framework')
|
|
|
|
.createSync(recursive: true);
|
|
|
|
fileSystem
|
|
|
|
.directory(xcframeworkPath)
|
|
|
|
.childDirectory('ios-armv7_arm64')
|
|
|
|
.childDirectory('Flutter.framework')
|
|
|
|
.createSync(recursive: true);
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterFramework,
|
|
|
|
platform: TargetPlatform.ios,
|
|
|
|
mode: BuildMode.release,
|
|
|
|
environmentType: EnvironmentType.simulator),
|
|
|
|
fileSystem.path
|
|
|
|
.join(xcframeworkPath, 'ios-x86_64-simulator', 'Flutter.framework'),
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterFramework,
|
|
|
|
platform: TargetPlatform.ios, mode: BuildMode.release, environmentType: EnvironmentType.physical),
|
|
|
|
fileSystem.path.join(xcframeworkPath, 'ios-armv7_arm64', 'Flutter.framework'),
|
2020-01-15 00:47:34 +00:00
|
|
|
);
|
2020-12-01 18:00:16 +00:00
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterXcframework, platform: TargetPlatform.ios, mode: BuildMode.release),
|
|
|
|
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.xcframework'),
|
|
|
|
);
|
2020-01-15 00:47:34 +00:00
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterTester),
|
|
|
|
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester'),
|
|
|
|
);
|
2021-02-12 22:25:30 +00:00
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterTester, platform: TargetPlatform.linux_arm64),
|
|
|
|
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'linux-arm64', 'flutter_tester'),
|
|
|
|
);
|
2021-04-09 17:59:01 +00:00
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.windowsUwpDesktopPath, platform: TargetPlatform.windows_uwp_x64, mode: BuildMode.debug),
|
|
|
|
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'windows-uwp-x64-debug'),
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.windowsUwpDesktopPath, platform: TargetPlatform.windows_uwp_x64, mode: BuildMode.profile),
|
|
|
|
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'windows-uwp-x64-profile'),
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.windowsUwpDesktopPath, platform: TargetPlatform.windows_uwp_x64, mode: BuildMode.release),
|
|
|
|
fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'windows-uwp-x64-release'),
|
|
|
|
);
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
2020-06-30 19:29:42 +00:00
|
|
|
testWithoutContext('precompiled web artifact paths are correct', () {
|
|
|
|
expect(
|
2021-04-23 02:29:02 +00:00
|
|
|
artifacts.getHostArtifact(HostArtifact.webPrecompiledSdk).path,
|
2020-06-30 19:29:42 +00:00
|
|
|
'root/bin/cache/flutter_web_sdk/kernel/amd/dart_sdk.js',
|
|
|
|
);
|
|
|
|
expect(
|
2021-04-23 02:29:02 +00:00
|
|
|
artifacts.getHostArtifact(HostArtifact.webPrecompiledSdkSourcemaps).path,
|
2020-06-30 19:29:42 +00:00
|
|
|
'root/bin/cache/flutter_web_sdk/kernel/amd/dart_sdk.js.map',
|
|
|
|
);
|
|
|
|
expect(
|
2021-04-23 02:29:02 +00:00
|
|
|
artifacts.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSdk).path,
|
2020-06-30 19:29:42 +00:00
|
|
|
'root/bin/cache/flutter_web_sdk/kernel/amd-canvaskit/dart_sdk.js',
|
|
|
|
);
|
|
|
|
expect(
|
2021-04-23 02:29:02 +00:00
|
|
|
artifacts.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSdkSourcemaps).path,
|
2020-06-30 19:29:42 +00:00
|
|
|
'root/bin/cache/flutter_web_sdk/kernel/amd-canvaskit/dart_sdk.js.map',
|
|
|
|
);
|
|
|
|
expect(
|
2021-04-23 02:29:02 +00:00
|
|
|
artifacts.getHostArtifact(HostArtifact.webPrecompiledSoundSdk).path,
|
2020-06-30 19:29:42 +00:00
|
|
|
'root/bin/cache/flutter_web_sdk/kernel/amd-sound/dart_sdk.js',
|
|
|
|
);
|
|
|
|
expect(
|
2021-04-23 02:29:02 +00:00
|
|
|
artifacts.getHostArtifact(HostArtifact.webPrecompiledSoundSdkSourcemaps).path,
|
2020-06-30 19:29:42 +00:00
|
|
|
'root/bin/cache/flutter_web_sdk/kernel/amd-sound/dart_sdk.js.map',
|
|
|
|
);
|
|
|
|
expect(
|
2021-04-23 02:29:02 +00:00
|
|
|
artifacts.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSoundSdk).path,
|
2020-06-30 19:29:42 +00:00
|
|
|
'root/bin/cache/flutter_web_sdk/kernel/amd-canvaskit-sound/dart_sdk.js',
|
|
|
|
);
|
|
|
|
expect(
|
2021-04-23 02:29:02 +00:00
|
|
|
artifacts.getHostArtifact(HostArtifact.webPrecompiledCanvaskitSoundSdkSourcemaps).path,
|
2020-06-30 19:29:42 +00:00
|
|
|
'root/bin/cache/flutter_web_sdk/kernel/amd-canvaskit-sound/dart_sdk.js.map',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('getEngineType', () {
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
|
|
|
|
'android-arm',
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
|
|
|
|
'ios-release',
|
|
|
|
);
|
|
|
|
expect(
|
2021-04-28 18:33:36 +00:00
|
|
|
artifacts.getEngineType(TargetPlatform.darwin),
|
2020-01-15 00:47:34 +00:00
|
|
|
'darwin-x64',
|
|
|
|
);
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
2020-01-15 00:47:34 +00:00
|
|
|
});
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
group('LocalEngineArtifacts', () {
|
|
|
|
LocalEngineArtifacts artifacts;
|
|
|
|
Cache cache;
|
|
|
|
FileSystem fileSystem;
|
|
|
|
Platform platform;
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
setUp(() {
|
2020-09-30 00:50:33 +00:00
|
|
|
fileSystem = MemoryFileSystem.test();
|
2020-01-15 00:47:34 +00:00
|
|
|
final Directory cacheRoot = fileSystem.directory('root')
|
|
|
|
..createSync();
|
|
|
|
platform = FakePlatform(operatingSystem: 'linux');
|
|
|
|
cache = Cache(
|
|
|
|
rootOverride: cacheRoot,
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
platform: platform,
|
2020-03-03 00:23:56 +00:00
|
|
|
logger: BufferLogger.test(),
|
2021-02-12 22:25:30 +00:00
|
|
|
osUtils: FakeOperatingSystemUtils(),
|
2021-04-05 21:26:02 +00:00
|
|
|
artifacts: <ArtifactSet>[],
|
2020-01-15 00:47:34 +00:00
|
|
|
);
|
2020-03-18 16:18:41 +00:00
|
|
|
artifacts = LocalEngineArtifacts(
|
2020-01-15 00:47:34 +00:00
|
|
|
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
|
|
|
|
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
|
|
|
|
cache: cache,
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
platform: platform,
|
|
|
|
processManager: FakeProcessManager.any(),
|
2021-02-12 22:25:30 +00:00
|
|
|
operatingSystemUtils: FakeOperatingSystemUtils(),
|
2020-01-15 00:47:34 +00:00
|
|
|
);
|
|
|
|
});
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('getArtifactPath', () {
|
2020-12-04 21:57:11 +00:00
|
|
|
final String xcframeworkPath = artifacts.getArtifactPath(
|
|
|
|
Artifact.flutterXcframework,
|
|
|
|
platform: TargetPlatform.ios,
|
|
|
|
mode: BuildMode.release,
|
|
|
|
);
|
2020-01-15 00:47:34 +00:00
|
|
|
expect(
|
2020-12-04 21:57:11 +00:00
|
|
|
xcframeworkPath,
|
|
|
|
fileSystem.path
|
|
|
|
.join('/out', 'android_debug_unopt', 'Flutter.xcframework'),
|
2020-01-15 00:47:34 +00:00
|
|
|
);
|
2020-12-01 18:00:16 +00:00
|
|
|
expect(
|
2020-12-04 21:57:11 +00:00
|
|
|
() => artifacts.getArtifactPath(
|
|
|
|
Artifact.flutterFramework,
|
|
|
|
platform: TargetPlatform.ios,
|
|
|
|
mode: BuildMode.release,
|
|
|
|
environmentType: EnvironmentType.simulator,
|
|
|
|
),
|
|
|
|
throwsToolExit(
|
|
|
|
message:
|
2021-02-03 21:14:38 +00:00
|
|
|
'No xcframework found at /out/android_debug_unopt/Flutter.xcframework'),
|
2020-12-04 21:57:11 +00:00
|
|
|
);
|
|
|
|
fileSystem.directory(xcframeworkPath).createSync(recursive: true);
|
|
|
|
expect(
|
|
|
|
() => artifacts.getArtifactPath(
|
|
|
|
Artifact.flutterFramework,
|
|
|
|
platform: TargetPlatform.ios,
|
|
|
|
mode: BuildMode.release,
|
|
|
|
environmentType: EnvironmentType.simulator,
|
|
|
|
),
|
|
|
|
throwsToolExit(
|
|
|
|
message:
|
|
|
|
'No iOS frameworks found in /out/android_debug_unopt/Flutter.xcframework'),
|
|
|
|
);
|
|
|
|
|
|
|
|
fileSystem
|
|
|
|
.directory(xcframeworkPath)
|
|
|
|
.childDirectory('ios-x86_64-simulator')
|
|
|
|
.childDirectory('Flutter.framework')
|
|
|
|
.createSync(recursive: true);
|
|
|
|
fileSystem
|
|
|
|
.directory(xcframeworkPath)
|
|
|
|
.childDirectory('ios-armv7_arm64')
|
|
|
|
.childDirectory('Flutter.framework')
|
|
|
|
.createSync(recursive: true);
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(
|
|
|
|
Artifact.flutterFramework,
|
|
|
|
platform: TargetPlatform.ios,
|
|
|
|
mode: BuildMode.release,
|
|
|
|
environmentType: EnvironmentType.simulator,
|
|
|
|
),
|
|
|
|
fileSystem.path
|
|
|
|
.join(xcframeworkPath, 'ios-x86_64-simulator', 'Flutter.framework'),
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(
|
|
|
|
Artifact.flutterFramework,
|
|
|
|
platform: TargetPlatform.ios,
|
|
|
|
mode: BuildMode.release,
|
|
|
|
environmentType: EnvironmentType.physical,
|
|
|
|
),
|
|
|
|
fileSystem.path
|
|
|
|
.join(xcframeworkPath, 'ios-armv7_arm64', 'Flutter.framework'),
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(
|
|
|
|
Artifact.flutterXcframework,
|
|
|
|
platform: TargetPlatform.ios,
|
|
|
|
mode: BuildMode.release,
|
|
|
|
),
|
|
|
|
fileSystem.path
|
|
|
|
.join('/out', 'android_debug_unopt', 'Flutter.xcframework'),
|
2020-12-01 18:00:16 +00:00
|
|
|
);
|
2020-01-15 00:47:34 +00:00
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.flutterTester),
|
|
|
|
fileSystem.path.join('/out', 'android_debug_unopt', 'flutter_tester'),
|
|
|
|
);
|
|
|
|
expect(
|
2021-04-23 02:29:02 +00:00
|
|
|
artifacts.getHostArtifact(HostArtifact.engineDartSdkPath).path,
|
2020-01-15 00:47:34 +00:00
|
|
|
fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk'),
|
|
|
|
);
|
|
|
|
});
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('getEngineType', () {
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
|
|
|
|
'android_debug_unopt',
|
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
|
|
|
|
'android_debug_unopt',
|
|
|
|
);
|
|
|
|
expect(
|
2021-04-28 18:33:36 +00:00
|
|
|
artifacts.getEngineType(TargetPlatform.darwin),
|
2020-01-15 00:47:34 +00:00
|
|
|
'android_debug_unopt',
|
|
|
|
);
|
|
|
|
});
|
2019-09-28 01:54:24 +00:00
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('Looks up dart.exe on windows platforms', () async {
|
2020-03-18 16:18:41 +00:00
|
|
|
artifacts = LocalEngineArtifacts(
|
2020-01-15 00:47:34 +00:00
|
|
|
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'android_debug_unopt'),
|
|
|
|
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'host_debug_unopt'),
|
|
|
|
cache: cache,
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
platform: FakePlatform(operatingSystem: 'windows'),
|
|
|
|
processManager: FakeProcessManager.any(),
|
2021-02-12 22:25:30 +00:00
|
|
|
operatingSystemUtils: FakeOperatingSystemUtils(),
|
2020-01-15 00:47:34 +00:00
|
|
|
);
|
|
|
|
|
2021-04-23 02:29:02 +00:00
|
|
|
expect(artifacts.getHostArtifact(HostArtifact.engineDartBinary).path, contains('.exe'));
|
2020-01-15 00:47:34 +00:00
|
|
|
});
|
2019-09-28 01:54:24 +00:00
|
|
|
|
2021-04-09 17:59:01 +00:00
|
|
|
testWithoutContext('Looks up windows UWP artifacts in host engine', () async {
|
|
|
|
artifacts = LocalEngineArtifacts(
|
|
|
|
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'winuwp_debug_unopt'),
|
|
|
|
fileSystem.path.join(fileSystem.currentDirectory.path, 'out', 'winuwp_debug_unopt'),
|
|
|
|
cache: cache,
|
|
|
|
fileSystem: fileSystem,
|
|
|
|
platform: FakePlatform(operatingSystem: 'windows'),
|
|
|
|
processManager: FakeProcessManager.any(),
|
|
|
|
operatingSystemUtils: FakeOperatingSystemUtils(),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(artifacts.getArtifactPath(Artifact.windowsUwpDesktopPath), '/out/winuwp_debug_unopt');
|
|
|
|
});
|
|
|
|
|
2020-01-15 00:47:34 +00:00
|
|
|
testWithoutContext('Looks up dart on linux platforms', () async {
|
2021-04-23 02:29:02 +00:00
|
|
|
expect(artifacts.getHostArtifact(HostArtifact.engineDartBinary).path, isNot(contains('.exe')));
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
});
|
2018-07-27 15:44:39 +00:00
|
|
|
}
|