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.
|
|
|
|
|
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';
|
|
|
|
import 'package:flutter_tools/src/base/platform.dart';
|
|
|
|
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';
|
|
|
|
import '../src/context.dart';
|
2017-02-17 07:10:11 +00:00
|
|
|
|
|
|
|
void main() {
|
2019-07-18 22:29:06 +00:00
|
|
|
group('Artifacts', () {
|
|
|
|
MemoryFileSystem memoryFileSystem;
|
2017-02-17 07:10:11 +00:00
|
|
|
Directory tempDir;
|
|
|
|
|
|
|
|
setUp(() {
|
2019-07-18 22:29:06 +00:00
|
|
|
memoryFileSystem = MemoryFileSystem();
|
2019-10-07 23:43:04 +00:00
|
|
|
tempDir = memoryFileSystem.systemTempDirectory.createTempSync('flutter_artifacts_test.');
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
tearDown(() {
|
2018-08-17 20:17:23 +00:00
|
|
|
tryToDelete(tempDir);
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
2019-07-18 22:29:06 +00:00
|
|
|
group('CachedArtifacts', () {
|
|
|
|
CachedArtifacts artifacts;
|
|
|
|
|
|
|
|
setUp(() {
|
|
|
|
artifacts = CachedArtifacts();
|
|
|
|
});
|
|
|
|
|
|
|
|
testUsingContext('getArtifactPath', () {
|
|
|
|
expect(
|
2019-04-16 04:02:20 +00:00
|
|
|
artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release),
|
2019-03-01 07:17:55 +00:00
|
|
|
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework'),
|
2019-07-18 22:29:06 +00:00
|
|
|
);
|
|
|
|
expect(
|
2017-03-29 23:30:41 +00:00
|
|
|
artifacts.getArtifactPath(Artifact.flutterTester),
|
2019-03-01 07:17:55 +00:00
|
|
|
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester'),
|
2019-07-18 22:29:06 +00:00
|
|
|
);
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
Cache: () => Cache(rootOverride: tempDir),
|
|
|
|
FileSystem: () => memoryFileSystem,
|
2019-10-23 05:05:00 +00:00
|
|
|
ProcessManager: () => FakeProcessManager.any(),
|
2019-07-18 22:29:06 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
|
|
|
});
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2019-07-18 22:29:06 +00:00
|
|
|
testUsingContext('getEngineType', () {
|
|
|
|
expect(
|
2017-02-17 07:10:11 +00:00
|
|
|
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
|
2019-03-01 07:17:55 +00:00
|
|
|
'android-arm',
|
2019-07-18 22:29:06 +00:00
|
|
|
);
|
|
|
|
expect(
|
2017-02-17 07:10:11 +00:00
|
|
|
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
|
2019-03-01 07:17:55 +00:00
|
|
|
'ios-release',
|
2019-07-18 22:29:06 +00:00
|
|
|
);
|
|
|
|
expect(
|
2017-02-17 07:10:11 +00:00
|
|
|
artifacts.getEngineType(TargetPlatform.darwin_x64),
|
2019-03-01 07:17:55 +00:00
|
|
|
'darwin-x64',
|
2019-07-18 22:29:06 +00:00
|
|
|
);
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
Cache: () => Cache(rootOverride: tempDir),
|
|
|
|
FileSystem: () => memoryFileSystem,
|
2019-10-23 05:05:00 +00:00
|
|
|
ProcessManager: () => FakeProcessManager.any(),
|
2019-07-18 22:29:06 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
|
|
|
});
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
|
2019-07-18 22:29:06 +00:00
|
|
|
group('LocalEngineArtifacts', () {
|
|
|
|
LocalEngineArtifacts artifacts;
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2019-07-18 22:29:06 +00:00
|
|
|
setUp(() {
|
|
|
|
artifacts = LocalEngineArtifacts(tempDir.path,
|
|
|
|
memoryFileSystem.path.join(tempDir.path, 'out', 'android_debug_unopt'),
|
|
|
|
memoryFileSystem.path.join(tempDir.path, 'out', 'host_debug_unopt'),
|
|
|
|
);
|
|
|
|
});
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2019-07-18 22:29:06 +00:00
|
|
|
testUsingContext('getArtifactPath', () {
|
|
|
|
expect(
|
2019-04-16 04:02:20 +00:00
|
|
|
artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release),
|
2019-03-01 07:17:55 +00:00
|
|
|
fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework'),
|
2019-07-18 22:29:06 +00:00
|
|
|
);
|
|
|
|
expect(
|
2017-03-29 23:30:41 +00:00
|
|
|
artifacts.getArtifactPath(Artifact.flutterTester),
|
2019-03-01 07:17:55 +00:00
|
|
|
fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'flutter_tester'),
|
2019-07-18 22:29:06 +00:00
|
|
|
);
|
|
|
|
expect(
|
|
|
|
artifacts.getArtifactPath(Artifact.engineDartSdkPath),
|
|
|
|
fs.path.join(tempDir.path, 'out', 'host_debug_unopt', 'dart-sdk'),
|
|
|
|
);
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
FileSystem: () => memoryFileSystem,
|
2019-10-23 05:05:00 +00:00
|
|
|
ProcessManager: () => FakeProcessManager.any(),
|
2019-07-18 22:29:06 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
|
|
|
});
|
2017-02-17 07:10:11 +00:00
|
|
|
|
2019-07-18 22:29:06 +00:00
|
|
|
testUsingContext('getEngineType', () {
|
|
|
|
expect(
|
2017-02-17 07:10:11 +00:00
|
|
|
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
|
2019-03-01 07:17:55 +00:00
|
|
|
'android_debug_unopt',
|
2019-07-18 22:29:06 +00:00
|
|
|
);
|
|
|
|
expect(
|
2017-02-17 07:10:11 +00:00
|
|
|
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
|
2019-03-01 07:17:55 +00:00
|
|
|
'android_debug_unopt',
|
2019-07-18 22:29:06 +00:00
|
|
|
);
|
|
|
|
expect(
|
2017-02-17 07:10:11 +00:00
|
|
|
artifacts.getEngineType(TargetPlatform.darwin_x64),
|
2019-03-01 07:17:55 +00:00
|
|
|
'android_debug_unopt',
|
2019-07-18 22:29:06 +00:00
|
|
|
);
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
FileSystem: () => memoryFileSystem,
|
2019-10-23 05:05:00 +00:00
|
|
|
ProcessManager: () => FakeProcessManager.any(),
|
2019-07-18 22:29:06 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
|
|
|
});
|
2019-09-28 01:54:24 +00:00
|
|
|
|
|
|
|
testUsingContext('Looks up dart.exe on windows platforms', () async {
|
|
|
|
expect(artifacts.getArtifactPath(Artifact.engineDartBinary), contains('.exe'));
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
FileSystem: () => memoryFileSystem,
|
2019-10-23 05:05:00 +00:00
|
|
|
ProcessManager: () => FakeProcessManager.any(),
|
2019-09-28 01:54:24 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'windows'),
|
|
|
|
});
|
|
|
|
|
|
|
|
testUsingContext('Looks up dart on linux platforms', () async {
|
|
|
|
expect(artifacts.getArtifactPath(Artifact.engineDartBinary), isNot(contains('.exe')));
|
|
|
|
}, overrides: <Type, Generator>{
|
|
|
|
FileSystem: () => memoryFileSystem,
|
2019-10-23 05:05:00 +00:00
|
|
|
ProcessManager: () => FakeProcessManager.any(),
|
2019-09-28 01:54:24 +00:00
|
|
|
Platform: () => FakePlatform(operatingSystem: 'linux'),
|
|
|
|
});
|
2017-02-17 07:10:11 +00:00
|
|
|
});
|
|
|
|
});
|
2018-07-27 15:44:39 +00:00
|
|
|
}
|