Refactor how Artifacts are located (#8234)
Artifacts are now located in a central place. This will enable us to downlaod artifacts when we need them (instead of downloading them all upfront). This also makes replacing sky_snapshot with gen_snapshot easier.
This commit is contained in:
committed by
GitHub
parent
cc808cda5c
commit
cd8434d931
@@ -16,6 +16,7 @@ import 'analyze_test.dart' as analyze_test;
|
||||
import 'android_device_test.dart' as android_device_test;
|
||||
import 'android_sdk_test.dart' as android_sdk_test;
|
||||
import 'application_package_test.dart' as application_package_test;
|
||||
import 'artifacts_test.dart' as artifacts_test;
|
||||
import 'asset_bundle_test.dart' as asset_bundle_test;
|
||||
import 'base_utils_test.dart' as base_utils_test;
|
||||
import 'channel_test.dart' as channel_test;
|
||||
@@ -41,7 +42,6 @@ import 'protocol_discovery_test.dart' as protocol_discovery_test;
|
||||
import 'run_test.dart' as run_test;
|
||||
import 'stop_test.dart' as stop_test;
|
||||
import 'test_test.dart' as test_test;
|
||||
import 'toolchain_test.dart' as toolchain_test;
|
||||
import 'trace_test.dart' as trace_test;
|
||||
import 'upgrade_test.dart' as upgrade_test;
|
||||
import 'utils_test.dart' as utils_test;
|
||||
@@ -55,6 +55,7 @@ void main() {
|
||||
android_device_test.main();
|
||||
android_sdk_test.main();
|
||||
application_package_test.main();
|
||||
artifacts_test.main();
|
||||
asset_bundle_test.main();
|
||||
base_utils_test.main();
|
||||
channel_test.main();
|
||||
@@ -80,7 +81,6 @@ void main() {
|
||||
run_test.main();
|
||||
stop_test.main();
|
||||
test_test.main();
|
||||
toolchain_test.main();
|
||||
trace_test.main();
|
||||
upgrade_test.main();
|
||||
utils_test.main();
|
||||
|
||||
118
packages/flutter_tools/test/artifacts_test.dart
Normal file
118
packages/flutter_tools/test/artifacts_test.dart
Normal file
@@ -0,0 +1,118 @@
|
||||
// Copyright 2017 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
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';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'src/context.dart';
|
||||
|
||||
void main() {
|
||||
group('CachedArtifacts', () {
|
||||
|
||||
Directory tempDir;
|
||||
CachedArtifacts artifacts;
|
||||
|
||||
setUp(() {
|
||||
tempDir = fs.systemTempDirectory.createTempSync('flutter_temp');
|
||||
artifacts = new CachedArtifacts();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
tempDir.deleteSync(recursive: true);
|
||||
});
|
||||
|
||||
testUsingContext('getArtifactPath', () {
|
||||
expect(
|
||||
artifacts.getArtifactPath(Artifact.libskyShellSo, TargetPlatform.android_arm, BuildMode.debug),
|
||||
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'android-arm', 'libsky_shell.so')
|
||||
);
|
||||
expect(
|
||||
artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, BuildMode.release),
|
||||
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework')
|
||||
);
|
||||
|
||||
expect(
|
||||
artifacts.getArtifactPath(Artifact.skyShell),
|
||||
fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'sky_shell')
|
||||
);
|
||||
}, overrides: <Type, Generator> {
|
||||
Cache: () => new Cache(rootOverride: tempDir),
|
||||
Platform: () => new FakePlatform(operatingSystem: 'linux')
|
||||
});
|
||||
|
||||
testUsingContext('getEngineType', () {
|
||||
expect(
|
||||
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
|
||||
'android-arm'
|
||||
);
|
||||
expect(
|
||||
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
|
||||
'ios-release'
|
||||
);
|
||||
|
||||
expect(
|
||||
artifacts.getEngineType(TargetPlatform.darwin_x64),
|
||||
'darwin-x64'
|
||||
);
|
||||
}, overrides: <Type, Generator> {
|
||||
Cache: () => new Cache(rootOverride: tempDir),
|
||||
Platform: () => new FakePlatform(operatingSystem: 'linux')
|
||||
});
|
||||
});
|
||||
|
||||
group('LocalEngineArtifacts', () {
|
||||
|
||||
Directory tempDir;
|
||||
LocalEngineArtifacts artifacts;
|
||||
|
||||
setUp(() {
|
||||
tempDir = fs.systemTempDirectory.createTempSync('flutter_temp');
|
||||
artifacts = new LocalEngineArtifacts(tempDir.path, fs.path.join(tempDir.path, 'out', 'android_debug_unopt'));
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
tempDir.deleteSync(recursive: true);
|
||||
});
|
||||
|
||||
testUsingContext('getArtifactPath', () {
|
||||
expect(
|
||||
artifacts.getArtifactPath(Artifact.dartIoEntriesTxt, TargetPlatform.android_arm, BuildMode.debug),
|
||||
fs.path.join(tempDir.path, 'dart', 'runtime', 'bin', 'dart_io_entries.txt')
|
||||
);
|
||||
expect(
|
||||
artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, BuildMode.release),
|
||||
fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework')
|
||||
);
|
||||
|
||||
expect(
|
||||
artifacts.getArtifactPath(Artifact.skyShell),
|
||||
fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'sky_shell')
|
||||
);
|
||||
}, overrides: <Type, Generator> {
|
||||
Platform: () => new FakePlatform(operatingSystem: 'linux')
|
||||
});
|
||||
|
||||
testUsingContext('getEngineType', () {
|
||||
expect(
|
||||
artifacts.getEngineType(TargetPlatform.android_arm, BuildMode.debug),
|
||||
'android_debug_unopt'
|
||||
);
|
||||
expect(
|
||||
artifacts.getEngineType(TargetPlatform.ios, BuildMode.release),
|
||||
'android_debug_unopt'
|
||||
);
|
||||
|
||||
expect(
|
||||
artifacts.getEngineType(TargetPlatform.darwin_x64),
|
||||
'android_debug_unopt'
|
||||
);
|
||||
}, overrides: <Type, Generator> {
|
||||
Platform: () => new FakePlatform(operatingSystem: 'linux')
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/config.dart';
|
||||
import 'package:flutter_tools/src/base/context.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
@@ -17,7 +18,6 @@ import 'package:flutter_tools/src/doctor.dart';
|
||||
import 'package:flutter_tools/src/ios/mac.dart';
|
||||
import 'package:flutter_tools/src/ios/simulators.dart';
|
||||
import 'package:flutter_tools/src/run_hot.dart';
|
||||
import 'package:flutter_tools/src/toolchain.dart';
|
||||
import 'package:flutter_tools/src/usage.dart';
|
||||
|
||||
import 'package:mockito/mockito.dart';
|
||||
@@ -53,7 +53,7 @@ void testUsingContext(String description, dynamic testMethod(), {
|
||||
testContext.putIfAbsent(Doctor, () => new MockDoctor());
|
||||
testContext.putIfAbsent(HotRunnerConfig, () => new HotRunnerConfig());
|
||||
testContext.putIfAbsent(Cache, () => new Cache());
|
||||
testContext.putIfAbsent(ToolConfiguration, () => new ToolConfiguration());
|
||||
testContext.putIfAbsent(Artifacts, () => new CachedArtifacts());
|
||||
testContext.putIfAbsent(Config, () => new Config());
|
||||
testContext.putIfAbsent(OperatingSystemUtils, () {
|
||||
MockOperatingSystemUtils os = new MockOperatingSystemUtils();
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
// Copyright 2016 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/toolchain.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'src/context.dart';
|
||||
|
||||
void main() {
|
||||
group('ToolConfiguration', () {
|
||||
Directory tempDir;
|
||||
tempDir = fs.systemTempDirectory.createTempSync('flutter_temp');
|
||||
|
||||
testUsingContext('using cache', () {
|
||||
ToolConfiguration toolConfig = new ToolConfiguration();
|
||||
|
||||
expect(
|
||||
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildMode.debug).path,
|
||||
endsWith(fs.path.join('cache', 'artifacts', 'engine', 'android-arm'))
|
||||
);
|
||||
expect(
|
||||
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildMode.release).path,
|
||||
endsWith(fs.path.join('cache', 'artifacts', 'engine', 'android-arm-release'))
|
||||
);
|
||||
expect(tempDir, isNotNull);
|
||||
tempDir.deleteSync(recursive: true);
|
||||
}, overrides: <Type, Generator> {
|
||||
Cache: () => new Cache(rootOverride: tempDir),
|
||||
});
|
||||
|
||||
testUsingContext('using enginePath', () {
|
||||
ToolConfiguration toolConfig = new ToolConfiguration();
|
||||
toolConfig.engineSrcPath = 'engine';
|
||||
toolConfig.engineBuildPath = 'engine/out/android_debug';
|
||||
|
||||
expect(
|
||||
toolConfig.getEngineArtifactsDirectory(TargetPlatform.android_arm, BuildMode.debug).path,
|
||||
'engine/out/android_debug'
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user