Refactor writing of package config in tests (#163734)
Seems like each test had its own way of doing this. Extracted from https://github.com/flutter/flutter/pull/160443
This commit is contained in:
parent
4da1dec288
commit
45b21ec3bb
@ -29,6 +29,7 @@ import '../../src/common.dart';
|
|||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
import '../../src/fake_pub_deps.dart';
|
import '../../src/fake_pub_deps.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_build_system.dart';
|
import '../../src/test_build_system.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
|
|
||||||
@ -86,8 +87,8 @@ void main() {
|
|||||||
|
|
||||||
// Sets up the minimal mock project files necessary to look like a Flutter project.
|
// Sets up the minimal mock project files necessary to look like a Flutter project.
|
||||||
void createCoreMockProjectFiles() {
|
void createCoreMockProjectFiles() {
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
fileSystem.file('pubspec.yaml').writeAsStringSync('name: my_app');
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,10 +259,7 @@ void main() {
|
|||||||
osUtils: FakeOperatingSystemUtils(),
|
osUtils: FakeOperatingSystemUtils(),
|
||||||
);
|
);
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
fileSystem.file('pubspec.yaml').createSync();
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||||
|
|
||||||
final bool supported =
|
final bool supported =
|
||||||
|
@ -26,6 +26,7 @@ import '../../src/context.dart';
|
|||||||
import '../../src/fake_process_manager.dart';
|
import '../../src/fake_process_manager.dart';
|
||||||
import '../../src/fake_pub_deps.dart';
|
import '../../src/fake_pub_deps.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_build_system.dart';
|
import '../../src/test_build_system.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
|
|
||||||
@ -93,8 +94,8 @@ void main() {
|
|||||||
|
|
||||||
// Sets up the minimal mock project files necessary to look like a Flutter project.
|
// Sets up the minimal mock project files necessary to look like a Flutter project.
|
||||||
void createCoreMockProjectFiles() {
|
void createCoreMockProjectFiles() {
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
fileSystem.file('pubspec.yaml').writeAsStringSync('name: my_app');
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,10 +288,7 @@ void main() {
|
|||||||
osUtils: FakeOperatingSystemUtils(),
|
osUtils: FakeOperatingSystemUtils(),
|
||||||
);
|
);
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
fileSystem.file('pubspec.yaml').createSync();
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||||
|
|
||||||
final bool supported =
|
final bool supported =
|
||||||
|
@ -23,6 +23,7 @@ import 'package:unified_analytics/unified_analytics.dart';
|
|||||||
import '../../src/common.dart';
|
import '../../src/common.dart';
|
||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_build_system.dart';
|
import '../../src/test_build_system.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ void main() {
|
|||||||
// Creates the mock files necessary to look like a Flutter project.
|
// Creates the mock files necessary to look like a Flutter project.
|
||||||
void setUpMockCoreProjectFiles() {
|
void setUpMockCoreProjectFiles() {
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
fileSystem.file('pubspec.yaml').createSync();
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -685,10 +686,7 @@ project(runner LANGUAGES CXX)
|
|||||||
set(BINARY_NAME "fizz_bar")
|
set(BINARY_NAME "fizz_bar")
|
||||||
''');
|
''');
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
fileSystem.file('pubspec.yaml').createSync();
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
final FlutterProject flutterProject = FlutterProject.fromDirectoryTest(
|
final FlutterProject flutterProject = FlutterProject.fromDirectoryTest(
|
||||||
fileSystem.currentDirectory,
|
fileSystem.currentDirectory,
|
||||||
);
|
);
|
||||||
|
@ -27,6 +27,7 @@ import '../../src/context.dart';
|
|||||||
import '../../src/fake_process_manager.dart';
|
import '../../src/fake_process_manager.dart';
|
||||||
import '../../src/fake_pub_deps.dart';
|
import '../../src/fake_pub_deps.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_build_system.dart';
|
import '../../src/test_build_system.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
|
|
||||||
@ -75,8 +76,9 @@ void main() {
|
|||||||
|
|
||||||
// Sets up the minimal mock project files necessary to look like a Flutter project.
|
// Sets up the minimal mock project files necessary to look like a Flutter project.
|
||||||
void createCoreMockProjectFiles() {
|
void createCoreMockProjectFiles() {
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
fileSystem.file('pubspec.yaml').writeAsStringSync('name: my_app');
|
||||||
fileSystem.file('.dart_tool/package_config.json').createSync(recursive: true);
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
|
|
||||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import 'package:flutter_tools/src/web/compile.dart';
|
|||||||
import '../../src/common.dart';
|
import '../../src/common.dart';
|
||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_build_system.dart';
|
import '../../src/test_build_system.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ void main() {
|
|||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync('name: foo\n');
|
..writeAsStringSync('name: foo\n');
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
writePackageConfigFile(mainLibName: 'foo', directory: fileSystem.currentDirectory);
|
||||||
fileSystem.file(fileSystem.path.join('web', 'index.html')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('web', 'index.html')).createSync(recursive: true);
|
||||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||||
logger = BufferLogger.test();
|
logger = BufferLogger.test();
|
||||||
@ -505,27 +506,11 @@ void setupFileSystemForEndToEndTest(FileSystem fileSystem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Project files.
|
// Project files.
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(
|
||||||
..createSync(recursive: true)
|
directory: fileSystem.currentDirectory,
|
||||||
..writeAsStringSync('''
|
mainLibName: 'foo',
|
||||||
{
|
packages: <String, String>{'fizz': 'bar'},
|
||||||
"packages": [
|
);
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"rootUri": "../",
|
|
||||||
"packageUri": "lib/",
|
|
||||||
"languageVersion": "3.2"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "fizz",
|
|
||||||
"rootUri": "../bar",
|
|
||||||
"packageUri": "lib/",
|
|
||||||
"languageVersion": "3.2"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"configVersion": 2
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
fileSystem.file('pubspec.yaml').writeAsStringSync('''
|
fileSystem.file('pubspec.yaml').writeAsStringSync('''
|
||||||
name: foo
|
name: foo
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import 'package:unified_analytics/unified_analytics.dart';
|
|||||||
import '../../src/common.dart';
|
import '../../src/common.dart';
|
||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
|
|
||||||
const String flutterRoot = r'C:\flutter';
|
const String flutterRoot = r'C:\flutter';
|
||||||
@ -62,7 +63,7 @@ void main() {
|
|||||||
// Creates the mock files necessary to look like a Flutter project.
|
// Creates the mock files necessary to look like a Flutter project.
|
||||||
void setUpMockCoreProjectFiles() {
|
void setUpMockCoreProjectFiles() {
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
fileSystem.file('pubspec.yaml').createSync();
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import 'package:test/fake.dart';
|
|||||||
|
|
||||||
import '../../src/common.dart';
|
import '../../src/common.dart';
|
||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -273,10 +274,8 @@ FlutterProject setupProjectUnderTest(Directory currentDirectory, bool setupXcode
|
|||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
}
|
}
|
||||||
projectUnderTest.dartTool.createSync(recursive: true);
|
projectUnderTest.dartTool.createSync(recursive: true);
|
||||||
projectUnderTest.directory
|
writePackageConfigFile(directory: projectUnderTest.directory, mainLibName: 'my_app');
|
||||||
.childDirectory('.dart_tool')
|
|
||||||
.childFile('package_config.jon')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
projectUnderTest.android.ephemeralDirectory.createSync(recursive: true);
|
projectUnderTest.android.ephemeralDirectory.createSync(recursive: true);
|
||||||
|
|
||||||
projectUnderTest.ios.ephemeralDirectory.createSync(recursive: true);
|
projectUnderTest.ios.ephemeralDirectory.createSync(recursive: true);
|
||||||
|
@ -19,6 +19,7 @@ import 'package:test/fake.dart';
|
|||||||
import '../../src/common.dart';
|
import '../../src/common.dart';
|
||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
import '../../src/testbed.dart';
|
import '../../src/testbed.dart';
|
||||||
|
|
||||||
@ -39,10 +40,7 @@ class FakePub extends Fake implements Pub {
|
|||||||
bool shouldSkipThirdPartyGenerator = true,
|
bool shouldSkipThirdPartyGenerator = true,
|
||||||
PubOutputMode outputMode = PubOutputMode.all,
|
PubOutputMode outputMode = PubOutputMode.all,
|
||||||
}) async {
|
}) async {
|
||||||
project.directory
|
writePackageConfigFile(directory: project.directory, mainLibName: 'my_app');
|
||||||
.childDirectory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
if (offline) {
|
if (offline) {
|
||||||
calledGetOffline += 1;
|
calledGetOffline += 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:flutter_tools/src/base/file_system.dart';
|
import 'package:flutter_tools/src/base/file_system.dart';
|
||||||
@ -18,6 +20,7 @@ import 'package:unified_analytics/unified_analytics.dart';
|
|||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
import '../../src/fake_pub_deps.dart';
|
import '../../src/fake_pub_deps.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
|
|
||||||
const String minimalV2EmbeddingManifest = r'''
|
const String minimalV2EmbeddingManifest = r'''
|
||||||
@ -48,7 +51,7 @@ void main() {
|
|||||||
setUp(() {
|
setUp(() {
|
||||||
Cache.disableLocking();
|
Cache.disableLocking();
|
||||||
fileSystem = MemoryFileSystem.test();
|
fileSystem = MemoryFileSystem.test();
|
||||||
pub = FakePub(fileSystem);
|
pub = FakePub();
|
||||||
logger = BufferLogger.test();
|
logger = BufferLogger.test();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -73,7 +76,7 @@ void main() {
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'pub get usage values are resilient to missing package config files before running "pub get"',
|
'pub get usage values are resilient to missing package config files before running "pub get"',
|
||||||
() async {
|
() async {
|
||||||
fileSystem.currentDirectory.childFile('pubspec.yaml').createSync();
|
fileSystem.currentDirectory.childFile('pubspec.yaml').writeAsStringSync('name: my_app');
|
||||||
fileSystem.currentDirectory.childFile('.flutter-plugins').createSync();
|
fileSystem.currentDirectory.childFile('.flutter-plugins').createSync();
|
||||||
fileSystem.currentDirectory.childFile('.flutter-plugins-dependencies').createSync();
|
fileSystem.currentDirectory.childFile('.flutter-plugins-dependencies').createSync();
|
||||||
fileSystem.currentDirectory.childDirectory('android').childFile('AndroidManifest.xml')
|
fileSystem.currentDirectory.childDirectory('android').childFile('AndroidManifest.xml')
|
||||||
@ -152,8 +155,19 @@ void main() {
|
|||||||
await commandRunner.run(<String>['get', '--directory=${targetDirectory.path}']);
|
await commandRunner.run(<String>['get', '--directory=${targetDirectory.path}']);
|
||||||
final FlutterProject rootProject = FlutterProject.fromDirectory(targetDirectory);
|
final FlutterProject rootProject = FlutterProject.fromDirectory(targetDirectory);
|
||||||
final File packageConfigFile = rootProject.dartTool.childFile('package_config.json');
|
final File packageConfigFile = rootProject.dartTool.childFile('package_config.json');
|
||||||
|
|
||||||
expect(packageConfigFile.existsSync(), true);
|
expect(packageConfigFile.existsSync(), true);
|
||||||
expect(packageConfigFile.readAsStringSync(), '{"configVersion":2,"packages":[]}');
|
expect(json.decode(packageConfigFile.readAsStringSync()), <String, Object>{
|
||||||
|
'configVersion': 2,
|
||||||
|
'packages': <Object?>[
|
||||||
|
<String, Object?>{
|
||||||
|
'name': 'my_app',
|
||||||
|
'rootUri': '../',
|
||||||
|
'packageUri': 'lib/',
|
||||||
|
'languageVersion': '3.7',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
},
|
},
|
||||||
overrides: <Type, Generator>{
|
overrides: <Type, Generator>{
|
||||||
Pub: () => pub,
|
Pub: () => pub,
|
||||||
@ -328,9 +342,8 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FakePub extends Fake implements Pub {
|
class FakePub extends Fake implements Pub {
|
||||||
FakePub(this.fileSystem);
|
FakePub();
|
||||||
|
|
||||||
final FileSystem fileSystem;
|
|
||||||
List<String>? expectedArguments;
|
List<String>? expectedArguments;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -347,12 +360,7 @@ class FakePub extends Fake implements Pub {
|
|||||||
expect(arguments, expectedArguments);
|
expect(arguments, expectedArguments);
|
||||||
}
|
}
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
fileSystem
|
writePackageConfigFile(directory: project.directory, mainLibName: 'my_app');
|
||||||
.directory(project.directory)
|
|
||||||
.childDirectory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import '../../src/common.dart';
|
|||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
import '../../src/fake_devices.dart';
|
import '../../src/fake_devices.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -174,15 +175,9 @@ void main() {
|
|||||||
artifacts = Artifacts.test();
|
artifacts = Artifacts.test();
|
||||||
fs = MemoryFileSystem.test();
|
fs = MemoryFileSystem.test();
|
||||||
|
|
||||||
fs.currentDirectory.childFile('pubspec.yaml').writeAsStringSync('name: flutter_app');
|
fs.currentDirectory.childFile('pubspec.yaml').writeAsStringSync('name: my_app');
|
||||||
fs.currentDirectory.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: fs.currentDirectory, mainLibName: 'my_app');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('''
|
|
||||||
{
|
|
||||||
"packages": [],
|
|
||||||
"configVersion": 2
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
final Directory libDir = fs.currentDirectory.childDirectory('lib');
|
final Directory libDir = fs.currentDirectory.childDirectory('lib');
|
||||||
libDir.createSync();
|
libDir.createSync();
|
||||||
final File mainFile = libDir.childFile('main.dart');
|
final File mainFile = libDir.childFile('main.dart');
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:args/command_runner.dart';
|
import 'package:args/command_runner.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
@ -37,66 +36,16 @@ import '../../src/context.dart';
|
|||||||
import '../../src/fake_devices.dart';
|
import '../../src/fake_devices.dart';
|
||||||
import '../../src/fake_vm_services.dart';
|
import '../../src/fake_vm_services.dart';
|
||||||
import '../../src/logging_logger.dart';
|
import '../../src/logging_logger.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
|
|
||||||
final String _flutterToolsPackageConfigContents = json.encode(<String, Object>{
|
|
||||||
'configVersion': 2,
|
|
||||||
'packages': <Map<String, Object>>[
|
|
||||||
<String, String>{
|
|
||||||
'name': 'ffi',
|
|
||||||
'rootUri': 'file:///path/to/pubcache/.pub-cache/hosted/pub.dev/ffi-2.1.2',
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
'languageVersion': '3.3',
|
|
||||||
},
|
|
||||||
<String, String>{
|
|
||||||
'name': 'test',
|
|
||||||
'rootUri': 'file:///path/to/pubcache/.pub-cache/hosted/pub.dev/test-1.24.9',
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
'languageVersion': '3.0',
|
|
||||||
},
|
|
||||||
<String, String>{
|
|
||||||
'name': 'test_api',
|
|
||||||
'rootUri': 'file:///path/to/pubcache/.pub-cache/hosted/pub.dev/test_api-0.6.1',
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
'languageVersion': '3.0',
|
|
||||||
},
|
|
||||||
<String, String>{
|
|
||||||
'name': 'test_core',
|
|
||||||
'rootUri': 'file:///path/to/pubcache/.pub-cache/hosted/pub.dev/test_core-0.5.9',
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
'languageVersion': '3.0',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'generated': '2021-02-24T07:55:20.084834Z',
|
|
||||||
'generator': 'pub',
|
|
||||||
'generatorVersion': '2.13.0-68.0.dev',
|
|
||||||
});
|
|
||||||
const String _pubspecContents = '''
|
const String _pubspecContents = '''
|
||||||
|
name: my_app
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
integration_test:
|
integration_test:
|
||||||
sdk: flutter''';
|
sdk: flutter''';
|
||||||
final String _packageConfigContents = json.encode(<String, Object>{
|
|
||||||
'configVersion': 2,
|
|
||||||
'packages': <Map<String, Object>>[
|
|
||||||
<String, String>{
|
|
||||||
'name': 'test_api',
|
|
||||||
'rootUri': 'file:///path/to/pubcache/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.19',
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
'languageVersion': '2.12',
|
|
||||||
},
|
|
||||||
<String, String>{
|
|
||||||
'name': 'integration_test',
|
|
||||||
'rootUri': 'file:///path/to/flutter/packages/integration_test',
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
'languageVersion': '2.12',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'generated': '2021-02-24T07:55:20.084834Z',
|
|
||||||
'generator': 'pub',
|
|
||||||
'generatorVersion': '2.13.0-68.0.dev',
|
|
||||||
});
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
Cache.disableLocking();
|
Cache.disableLocking();
|
||||||
@ -111,20 +60,30 @@ void main() {
|
|||||||
final Directory package = fs.directory('package');
|
final Directory package = fs.directory('package');
|
||||||
package.childFile('pubspec.yaml').createSync(recursive: true);
|
package.childFile('pubspec.yaml').createSync(recursive: true);
|
||||||
package.childFile('pubspec.yaml').writeAsStringSync(_pubspecContents);
|
package.childFile('pubspec.yaml').writeAsStringSync(_pubspecContents);
|
||||||
(package.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(
|
||||||
..createSync(recursive: true)).writeAsStringSync(_packageConfigContents);
|
directory: package,
|
||||||
|
packages: <String, String>{
|
||||||
|
'test_api': 'file:///path/to/pubcache/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.19',
|
||||||
|
'integration_test': 'file:///path/to/flutter/packages/integration_test',
|
||||||
|
},
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
package.childDirectory('test').childFile('some_test.dart').createSync(recursive: true);
|
package.childDirectory('test').childFile('some_test.dart').createSync(recursive: true);
|
||||||
package
|
package
|
||||||
.childDirectory('integration_test')
|
.childDirectory('integration_test')
|
||||||
.childFile('some_integration_test.dart')
|
.childFile('some_integration_test.dart')
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
|
|
||||||
final File flutterToolsPackageConfigFile = fs
|
writePackageConfigFile(
|
||||||
.directory(fs.path.join(getFlutterRoot(), 'packages', 'flutter_tools'))
|
directory: fs.directory(fs.path.join(getFlutterRoot(), 'packages', 'flutter_tools')),
|
||||||
.childDirectory('.dart_tool')
|
packages: <String, String>{
|
||||||
.childFile('package_config.json');
|
'ffi': 'file:///path/to/pubcache/.pub-cache/hosted/pub.dev/ffi-2.1.2',
|
||||||
flutterToolsPackageConfigFile.createSync(recursive: true);
|
'test': 'file:///path/to/pubcache/.pub-cache/hosted/pub.dev/test-1.24.9',
|
||||||
flutterToolsPackageConfigFile.writeAsStringSync(_flutterToolsPackageConfigContents);
|
'test_api': 'file:///path/to/pubcache/.pub-cache/hosted/pub.dev/test_api-0.6.1',
|
||||||
|
'test_core': 'file:///path/to/pubcache/.pub-cache/hosted/pub.dev/test_core-0.5.9',
|
||||||
|
},
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
|
|
||||||
fs.currentDirectory = package.path;
|
fs.currentDirectory = package.path;
|
||||||
|
|
||||||
@ -161,26 +120,14 @@ dev_dependencies:
|
|||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
''');
|
''');
|
||||||
fs
|
writePackageConfigFile(
|
||||||
.directory('.dart_tool')
|
directory: fs.currentDirectory,
|
||||||
.childFile('package_config.json')
|
packages: <String, String>{
|
||||||
.writeAsStringSync(
|
'test_api': 'file:///path/to/pubcache/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.19',
|
||||||
json.encode(<String, Object>{
|
},
|
||||||
'configVersion': 2,
|
mainLibName: 'my_app',
|
||||||
'packages': <Map<String, Object>>[
|
);
|
||||||
<String, String>{
|
|
||||||
'name': 'test_api',
|
|
||||||
'rootUri':
|
|
||||||
'file:///path/to/pubcache/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.19',
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
'languageVersion': '2.12',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'generated': '2021-02-24T07:55:20.084834Z',
|
|
||||||
'generator': 'pub',
|
|
||||||
'generatorVersion': '2.13.0-68.0.dev',
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
final FakePackageTest fakePackageTest = FakePackageTest();
|
final FakePackageTest fakePackageTest = FakePackageTest();
|
||||||
final TestCommand testCommand = TestCommand(testWrapper: fakePackageTest);
|
final TestCommand testCommand = TestCommand(testWrapper: fakePackageTest);
|
||||||
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
|
final CommandRunner<void> commandRunner = createTestCommandRunner(testCommand);
|
||||||
@ -361,7 +308,7 @@ dev_dependencies:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'Coverage provides current library name to Coverage Collector by default',
|
'Coverage provides current library name to Coverage Collector by default',
|
||||||
() async {
|
() async {
|
||||||
const String currentPackageName = '';
|
const String currentPackageName = 'my_app';
|
||||||
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(
|
final FakeVmServiceHost fakeVmServiceHost = FakeVmServiceHost(
|
||||||
requests: <VmServiceExpectation>[
|
requests: <VmServiceExpectation>[
|
||||||
FakeVmServiceRequest(
|
FakeVmServiceRequest(
|
||||||
@ -1210,6 +1157,7 @@ const List<String> packageTestArgs = <String>[
|
|||||||
fs.file('vanilla.txt').writeAsStringSync('vanilla');
|
fs.file('vanilla.txt').writeAsStringSync('vanilla');
|
||||||
fs.file('orange.txt').writeAsStringSync('orange');
|
fs.file('orange.txt').writeAsStringSync('orange');
|
||||||
fs.file('pubspec.yaml').writeAsStringSync('''
|
fs.file('pubspec.yaml').writeAsStringSync('''
|
||||||
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- path: vanilla.txt
|
- path: vanilla.txt
|
||||||
@ -1251,6 +1199,7 @@ dev_dependencies:
|
|||||||
fs.file('vanilla.txt').writeAsStringSync('vanilla');
|
fs.file('vanilla.txt').writeAsStringSync('vanilla');
|
||||||
fs.file('flavorless.txt').writeAsStringSync('flavorless');
|
fs.file('flavorless.txt').writeAsStringSync('flavorless');
|
||||||
fs.file('pubspec.yaml').writeAsStringSync('''
|
fs.file('pubspec.yaml').writeAsStringSync('''
|
||||||
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- path: vanilla.txt
|
- path: vanilla.txt
|
||||||
@ -1321,6 +1270,7 @@ dev_dependencies:
|
|||||||
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
|
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
|
||||||
fs.file('asset.txt').writeAsStringSync('1');
|
fs.file('asset.txt').writeAsStringSync('1');
|
||||||
fs.file('pubspec.yaml').writeAsStringSync('''
|
fs.file('pubspec.yaml').writeAsStringSync('''
|
||||||
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- asset.txt
|
- asset.txt
|
||||||
|
@ -14,6 +14,7 @@ import 'package:test/fake.dart';
|
|||||||
import 'package:yaml/yaml.dart';
|
import 'package:yaml/yaml.dart';
|
||||||
|
|
||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_flutter_command_runner.dart';
|
import '../../src/test_flutter_command_runner.dart';
|
||||||
|
|
||||||
// An example pubspec.yaml from flutter, not necessary for it to be up to date.
|
// An example pubspec.yaml from flutter, not necessary for it to be up to date.
|
||||||
@ -116,7 +117,7 @@ void main() {
|
|||||||
..writeAsStringSync(kExamplesPubspecYaml);
|
..writeAsStringSync(kExamplesPubspecYaml);
|
||||||
flutter.childFile('pubspec.yaml').writeAsStringSync(kFlutterPubspecYaml);
|
flutter.childFile('pubspec.yaml').writeAsStringSync(kFlutterPubspecYaml);
|
||||||
Cache.flutterRoot = flutterSdk.absolute.path;
|
Cache.flutterRoot = flutterSdk.absolute.path;
|
||||||
pub = FakePub(fileSystem);
|
pub = FakePub();
|
||||||
processManager = FakeProcessManager.empty();
|
processManager = FakeProcessManager.empty();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -367,9 +368,8 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FakePub extends Fake implements Pub {
|
class FakePub extends Fake implements Pub {
|
||||||
FakePub(this.fileSystem);
|
FakePub();
|
||||||
|
|
||||||
final FileSystem fileSystem;
|
|
||||||
final List<String> pubGetDirectories = <String>[];
|
final List<String> pubGetDirectories = <String>[];
|
||||||
final List<String> pubBatchDirectories = <String>[];
|
final List<String> pubBatchDirectories = <String>[];
|
||||||
final List<String> pubspecYamls = <String>[];
|
final List<String> pubspecYamls = <String>[];
|
||||||
@ -405,9 +405,7 @@ packages:
|
|||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.14.0 <3.0.0"
|
dart: ">=2.14.0 <3.0.0"
|
||||||
''');
|
''');
|
||||||
fileSystem.currentDirectory.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: project.directory, mainLibName: 'my_app');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -19,6 +19,7 @@ import 'package:test_api/fake.dart';
|
|||||||
import '../../../src/common.dart';
|
import '../../../src/common.dart';
|
||||||
import '../../../src/context.dart';
|
import '../../../src/context.dart';
|
||||||
import '../../../src/fakes.dart';
|
import '../../../src/fakes.dart';
|
||||||
|
import '../../../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('WidgetPreviewStartCommand', () {
|
group('WidgetPreviewStartCommand', () {
|
||||||
@ -174,19 +175,6 @@ flutter:
|
|||||||
- deferredComponentArg
|
- deferredComponentArg
|
||||||
- path: package/deferredComponentUri''';
|
- path: package/deferredComponentUri''';
|
||||||
|
|
||||||
static const String basicPackageConfig = '''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "test",
|
|
||||||
"rootUri": "fileSystem.currentDirectory.path",
|
|
||||||
"packageUri": "lib/"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
|
|
||||||
final String projectRoot;
|
final String projectRoot;
|
||||||
final FileSystem fileSystem;
|
final FileSystem fileSystem;
|
||||||
final Logger logger;
|
final Logger logger;
|
||||||
@ -212,10 +200,9 @@ flutter:
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
late final File packageConfig = () {
|
late final File packageConfig = () {
|
||||||
final File file = fileSystem
|
return writePackageConfigFile(
|
||||||
.directory(fileSystem.path.join(projectRoot, '.dart_tool'))
|
directory: fileSystem.directory(projectRoot),
|
||||||
.childFile('package_config.json')..createSync(recursive: true);
|
mainLibName: 'my_app',
|
||||||
file.writeAsStringSync(basicPackageConfig);
|
);
|
||||||
return file;
|
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import '../src/common.dart';
|
|||||||
import '../src/context.dart';
|
import '../src/context.dart';
|
||||||
import '../src/fake_process_manager.dart';
|
import '../src/fake_process_manager.dart';
|
||||||
import '../src/fakes.dart';
|
import '../src/fakes.dart';
|
||||||
|
import '../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Apk with partial Android SDK works', () {
|
group('Apk with partial Android SDK works', () {
|
||||||
@ -982,9 +983,7 @@ class FakeAndroidSdkVersion extends Fake implements AndroidSdkVersion {
|
|||||||
|
|
||||||
Future<FlutterProject> aModuleProject() async {
|
Future<FlutterProject> aModuleProject() async {
|
||||||
final Directory directory = globals.fs.directory('module_project');
|
final Directory directory = globals.fs.directory('module_project');
|
||||||
directory.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: directory, mainLibName: 'my_app');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
|
||||||
directory.childFile('pubspec.yaml').writeAsStringSync('''
|
directory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
name: my_module
|
name: my_module
|
||||||
flutter:
|
flutter:
|
||||||
|
@ -12,6 +12,7 @@ import 'package:flutter_tools/src/cache.dart';
|
|||||||
import 'package:flutter_tools/src/project.dart';
|
import 'package:flutter_tools/src/project.dart';
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
|
import '../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
Future<ManifestAssetBundle> buildBundleWithFlavor(
|
Future<ManifestAssetBundle> buildBundleWithFlavor(
|
||||||
@ -50,10 +51,8 @@ void main() {
|
|||||||
final BufferLogger logger = BufferLogger.test();
|
final BufferLogger logger = BufferLogger.test();
|
||||||
final FakePlatform platform = FakePlatform();
|
final FakePlatform platform = FakePlatform();
|
||||||
|
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'example');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
fileSystem
|
fileSystem
|
||||||
.file(fileSystem.path.join('assets', 'common', 'image.png'))
|
.file(fileSystem.path.join('assets', 'common', 'image.png'))
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
@ -129,10 +128,8 @@ flutter:
|
|||||||
);
|
);
|
||||||
final BufferLogger logger = BufferLogger.test();
|
final BufferLogger logger = BufferLogger.test();
|
||||||
final FakePlatform platform = FakePlatform();
|
final FakePlatform platform = FakePlatform();
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'example');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
fileSystem.file(fileSystem.path.join('assets', 'unflavored.png')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('assets', 'unflavored.png')).createSync(recursive: true);
|
||||||
fileSystem
|
fileSystem
|
||||||
.file(fileSystem.path.join('assets', 'vanillaOrange.png'))
|
.file(fileSystem.path.join('assets', 'vanillaOrange.png'))
|
||||||
@ -174,10 +171,7 @@ flutter:
|
|||||||
);
|
);
|
||||||
final BufferLogger logger = BufferLogger.test();
|
final BufferLogger logger = BufferLogger.test();
|
||||||
final FakePlatform platform = FakePlatform();
|
final FakePlatform platform = FakePlatform();
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'example');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
fileSystem.file(fileSystem.path.join('vanilla', 'vanilla.png')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('vanilla', 'vanilla.png')).createSync(recursive: true);
|
||||||
fileSystem
|
fileSystem
|
||||||
.file(fileSystem.path.join('vanilla', 'flavorless.png'))
|
.file(fileSystem.path.join('vanilla', 'flavorless.png'))
|
||||||
@ -217,10 +211,7 @@ flutter:
|
|||||||
);
|
);
|
||||||
final BufferLogger logger = BufferLogger.test();
|
final BufferLogger logger = BufferLogger.test();
|
||||||
final FakePlatform platform = FakePlatform();
|
final FakePlatform platform = FakePlatform();
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'example');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
fileSystem.file('orange.png').createSync(recursive: true);
|
fileSystem.file('orange.png').createSync(recursive: true);
|
||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
@ -258,10 +249,7 @@ flutter:
|
|||||||
);
|
);
|
||||||
final BufferLogger logger = BufferLogger.test();
|
final BufferLogger logger = BufferLogger.test();
|
||||||
final FakePlatform platform = FakePlatform();
|
final FakePlatform platform = FakePlatform();
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'example');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
fileSystem
|
fileSystem
|
||||||
.file(fileSystem.path.join('vanilla', 'actually-strawberry.png'))
|
.file(fileSystem.path.join('vanilla', 'actually-strawberry.png'))
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
|
@ -14,6 +14,7 @@ import 'package:flutter_tools/src/globals.dart' as globals;
|
|||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import '../src/context.dart';
|
import '../src/context.dart';
|
||||||
|
import '../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
String fixPath(String path) {
|
String fixPath(String path) {
|
||||||
@ -47,26 +48,6 @@ $fontsSection
|
|||||||
''');
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
void writePackageConfigFile(Map<String, String> packages) {
|
|
||||||
globals.fs.directory('.dart_tool').childFile('package_config.json')
|
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync(
|
|
||||||
json.encode(<String, dynamic>{
|
|
||||||
'packages': <dynamic>[
|
|
||||||
...packages.entries.map((MapEntry<String, String> entry) {
|
|
||||||
return <String, dynamic>{
|
|
||||||
'name': entry.key,
|
|
||||||
'rootUri': '../${entry.value}',
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
'languageVersion': '3.2',
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
'configVersion': 2,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> buildAndVerifyFonts(
|
Future<void> buildAndVerifyFonts(
|
||||||
List<String> localFonts,
|
List<String> localFonts,
|
||||||
List<String> packageFonts,
|
List<String> packageFonts,
|
||||||
@ -116,8 +97,13 @@ $fontsSection
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'App includes neither font manifest nor fonts when no defines fonts',
|
'App includes neither font manifest nor fonts when no defines fonts',
|
||||||
() async {
|
() async {
|
||||||
|
final Map<String, String> deps = <String, String>{'test_package': 'p/p/'};
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
packages: deps,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||||
|
|
||||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||||
@ -146,8 +132,14 @@ $fontsSection
|
|||||||
fonts:
|
fonts:
|
||||||
- asset: packages/test_package/bar
|
- asset: packages/test_package/bar
|
||||||
''';
|
''';
|
||||||
writePubspecFile('pubspec.yaml', 'test', fontsSection: fontsSection);
|
writePubspecFile('pubspec.yaml', 'my_app', fontsSection: fontsSection);
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
|
||||||
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||||
|
|
||||||
const String font = 'bar';
|
const String font = 'bar';
|
||||||
@ -177,8 +169,13 @@ $fontsSection
|
|||||||
- asset: packages/test_package/bar
|
- asset: packages/test_package/bar
|
||||||
- asset: a/bar
|
- asset: a/bar
|
||||||
''';
|
''';
|
||||||
writePubspecFile('pubspec.yaml', 'test', fontsSection: fontsSection);
|
writePubspecFile('pubspec.yaml', 'my_app', fontsSection: fontsSection);
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||||
|
|
||||||
const String packageFont = 'bar';
|
const String packageFont = 'bar';
|
||||||
@ -202,8 +199,14 @@ $fontsSection
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'App uses package font with own font file',
|
'App uses package font with own font file',
|
||||||
() async {
|
() async {
|
||||||
|
final Map<String, String> deps = <String, String>{'test_package': 'p/p/'};
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
|
||||||
|
packages: deps,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
const String fontsSection = '''
|
const String fontsSection = '''
|
||||||
- family: foo
|
- family: foo
|
||||||
fonts:
|
fonts:
|
||||||
@ -233,8 +236,17 @@ $fontsSection
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'App uses package font with font file from another package',
|
'App uses package font with font file from another package',
|
||||||
() async {
|
() async {
|
||||||
|
final Map<String, String> deps = <String, String>{
|
||||||
|
'test_package': 'p/p/',
|
||||||
|
'test_package2': 'p2/p/',
|
||||||
|
};
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/', 'test_package2': 'p2/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
|
||||||
|
packages: deps,
|
||||||
|
mainLibName: 'test',
|
||||||
|
);
|
||||||
const String fontsSection = '''
|
const String fontsSection = '''
|
||||||
- family: foo
|
- family: foo
|
||||||
fonts:
|
fonts:
|
||||||
@ -265,8 +277,14 @@ $fontsSection
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'App uses package font with properties and own font file',
|
'App uses package font with properties and own font file',
|
||||||
() async {
|
() async {
|
||||||
|
final Map<String, String> deps = <String, String>{'test_package': 'p/p/'};
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
|
||||||
|
packages: deps,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
|
|
||||||
const String pubspec = '''
|
const String pubspec = '''
|
||||||
- family: foo
|
- family: foo
|
||||||
@ -298,13 +316,19 @@ $fontsSection
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'App uses local font and package font with own font file.',
|
'App uses local font and package font with own font file.',
|
||||||
() async {
|
() async {
|
||||||
|
final Map<String, String> deps = <String, String>{'test_package': 'p/p/'};
|
||||||
const String fontsSection = '''
|
const String fontsSection = '''
|
||||||
- family: foo
|
- family: foo
|
||||||
fonts:
|
fonts:
|
||||||
- asset: a/bar
|
- asset: a/bar
|
||||||
''';
|
''';
|
||||||
writePubspecFile('pubspec.yaml', 'test', fontsSection: fontsSection);
|
writePubspecFile('pubspec.yaml', 'test', fontsSection: fontsSection);
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
packages: deps,
|
||||||
|
mainLibName: 'test',
|
||||||
|
);
|
||||||
|
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package', fontsSection: fontsSection);
|
writePubspecFile('p/p/pubspec.yaml', 'test_package', fontsSection: fontsSection);
|
||||||
|
|
||||||
const String font = 'a/bar';
|
const String font = 'a/bar';
|
||||||
|
@ -16,6 +16,7 @@ import 'package:standard_message_codec/standard_message_codec.dart';
|
|||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import '../src/context.dart';
|
import '../src/context.dart';
|
||||||
|
import '../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
String fixPath(String path) {
|
String fixPath(String path) {
|
||||||
@ -71,26 +72,6 @@ $assetsSection
|
|||||||
''');
|
''');
|
||||||
}
|
}
|
||||||
|
|
||||||
void writePackageConfigFile(Map<String, String> packages) {
|
|
||||||
globals.fs.directory('.dart_tool').childFile('package_config.json')
|
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync(
|
|
||||||
json.encode(<String, dynamic>{
|
|
||||||
'packages': <dynamic>[
|
|
||||||
...packages.entries.map((MapEntry<String, String> entry) {
|
|
||||||
return <String, dynamic>{
|
|
||||||
'name': entry.key,
|
|
||||||
'rootUri': '../${entry.value}',
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
'languageVersion': '3.2',
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
'configVersion': 2,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Object, Object> assetManifestBinToJson(Map<Object, Object> manifest) {
|
Map<Object, Object> assetManifestBinToJson(Map<Object, Object> manifest) {
|
||||||
List<Object> convertList(List<Object> variants) =>
|
List<Object> convertList(List<Object> variants) =>
|
||||||
variants.map((Object variant) => (variant as Map<Object?, Object?>)['asset']!).toList();
|
variants.map((Object variant) => (variant as Map<Object?, Object?>)['asset']!).toList();
|
||||||
@ -159,7 +140,11 @@ $assetsSection
|
|||||||
'No assets are bundled when the package has no assets',
|
'No assets are bundled when the package has no assets',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||||
|
|
||||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||||
@ -190,7 +175,11 @@ $assetsSection
|
|||||||
'No assets are bundled when the package has an asset that is not listed',
|
'No assets are bundled when the package has an asset that is not listed',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||||
|
|
||||||
final List<String> assets = <String>['a/foo'];
|
final List<String> assets = <String>['a/foo'];
|
||||||
@ -225,7 +214,11 @@ $assetsSection
|
|||||||
'asset its pubspec',
|
'asset its pubspec',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
|
|
||||||
final List<String> assets = <String>['a/foo'];
|
final List<String> assets = <String>['a/foo'];
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: assets);
|
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: assets);
|
||||||
@ -252,7 +245,11 @@ $assetsSection
|
|||||||
() async {
|
() async {
|
||||||
final List<String> assetEntries = <String>['packages/test_package/a/foo'];
|
final List<String> assetEntries = <String>['packages/test_package/a/foo'];
|
||||||
writePubspecFile('pubspec.yaml', 'test', assets: assetEntries);
|
writePubspecFile('pubspec.yaml', 'test', assets: assetEntries);
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||||
|
|
||||||
final List<String> assets = <String>['a/foo'];
|
final List<String> assets = <String>['a/foo'];
|
||||||
@ -276,7 +273,11 @@ $assetsSection
|
|||||||
'has an asset and a variant, and lists the asset in its pubspec',
|
'has an asset and a variant, and lists the asset in its pubspec',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: <String>['a/foo', 'a/bar']);
|
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: <String>['a/foo', 'a/bar']);
|
||||||
|
|
||||||
final List<String> assets = <String>['a/foo', 'a/2x/foo', 'a/bar'];
|
final List<String> assets = <String>['a/foo', 'a/2x/foo', 'a/bar'];
|
||||||
@ -305,7 +306,11 @@ $assetsSection
|
|||||||
'has an asset and a variant, and the app lists the asset in its pubspec',
|
'has an asset and a variant, and the app lists the asset in its pubspec',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test', assets: <String>['packages/test_package/a/foo']);
|
writePubspecFile('pubspec.yaml', 'test', assets: <String>['packages/test_package/a/foo']);
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||||
|
|
||||||
final List<String> assets = <String>['a/foo', 'a/2x/foo'];
|
final List<String> assets = <String>['a/foo', 'a/2x/foo'];
|
||||||
@ -331,7 +336,11 @@ $assetsSection
|
|||||||
'two assets in its pubspec',
|
'two assets in its pubspec',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
|
|
||||||
final List<String> assets = <String>['a/foo', 'a/bar'];
|
final List<String> assets = <String>['a/foo', 'a/bar'];
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: assets);
|
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: assets);
|
||||||
@ -362,7 +371,11 @@ $assetsSection
|
|||||||
'packages/test_package/a/bar',
|
'packages/test_package/a/bar',
|
||||||
];
|
];
|
||||||
writePubspecFile('pubspec.yaml', 'test', assets: assetEntries);
|
writePubspecFile('pubspec.yaml', 'test', assets: assetEntries);
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
|
|
||||||
final List<String> assets = <String>['a/foo', 'a/bar'];
|
final List<String> assets = <String>['a/foo', 'a/bar'];
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||||
@ -389,7 +402,11 @@ $assetsSection
|
|||||||
'Two assets are bundled when two packages each have and list an asset their pubspec',
|
'Two assets are bundled when two packages each have and list an asset their pubspec',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/', 'test_package2': 'p2/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/', 'test_package2': 'p2/p/'},
|
||||||
|
);
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: <String>['a/foo']);
|
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: <String>['a/foo']);
|
||||||
writePubspecFile('p2/p/pubspec.yaml', 'test_package2', assets: <String>['a/foo']);
|
writePubspecFile('p2/p/pubspec.yaml', 'test_package2', assets: <String>['a/foo']);
|
||||||
|
|
||||||
@ -427,7 +444,11 @@ $assetsSection
|
|||||||
'packages/test_package2/a/foo',
|
'packages/test_package2/a/foo',
|
||||||
];
|
];
|
||||||
writePubspecFile('pubspec.yaml', 'test', assets: assetEntries);
|
writePubspecFile('pubspec.yaml', 'test', assets: assetEntries);
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/', 'test_package2': 'p2/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/', 'test_package2': 'p2/p/'},
|
||||||
|
);
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
writePubspecFile('p/p/pubspec.yaml', 'test_package');
|
||||||
writePubspecFile('p2/p/pubspec.yaml', 'test_package2');
|
writePubspecFile('p2/p/pubspec.yaml', 'test_package2');
|
||||||
|
|
||||||
@ -462,7 +483,11 @@ $assetsSection
|
|||||||
'listing in its pubspec an asset from another package',
|
'listing in its pubspec an asset from another package',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/', 'test_package2': 'p2/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/', 'test_package2': 'p2/p/'},
|
||||||
|
);
|
||||||
writePubspecFile(
|
writePubspecFile(
|
||||||
'p/p/pubspec.yaml',
|
'p/p/pubspec.yaml',
|
||||||
'test_package',
|
'test_package',
|
||||||
@ -492,7 +517,11 @@ $assetsSection
|
|||||||
'Flavored assets are bundled when the app depends on a package',
|
'Flavored assets are bundled when the app depends on a package',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
writePubspecFile(
|
writePubspecFile(
|
||||||
'p/p/pubspec.yaml',
|
'p/p/pubspec.yaml',
|
||||||
'test_package',
|
'test_package',
|
||||||
@ -526,7 +555,11 @@ $assetsSection
|
|||||||
'Asset paths can contain URL reserved characters',
|
'Asset paths can contain URL reserved characters',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
|
|
||||||
final List<String> assets = <String>['a/foo', 'a/foo [x]'];
|
final List<String> assets = <String>['a/foo', 'a/foo [x]'];
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: assets);
|
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: assets);
|
||||||
@ -553,7 +586,11 @@ $assetsSection
|
|||||||
'Asset paths can contain URL reserved characters',
|
'Asset paths can contain URL reserved characters',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
|
|
||||||
final List<String> assets = <String>['a/foo', 'a/foo [x]'];
|
final List<String> assets = <String>['a/foo', 'a/foo [x]'];
|
||||||
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: assets);
|
writePubspecFile('p/p/pubspec.yaml', 'test_package', assets: assets);
|
||||||
@ -581,7 +618,11 @@ $assetsSection
|
|||||||
'Two assets are bundled when scanning their directory',
|
'Two assets are bundled when scanning their directory',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
|
|
||||||
final List<String> assetsOnDisk = <String>['a/foo', 'a/bar'];
|
final List<String> assetsOnDisk = <String>['a/foo', 'a/bar'];
|
||||||
final List<String> assetsOnManifest = <String>['a/'];
|
final List<String> assetsOnManifest = <String>['a/'];
|
||||||
@ -610,7 +651,11 @@ $assetsSection
|
|||||||
'Two assets are bundled when listing one and scanning second directory',
|
'Two assets are bundled when listing one and scanning second directory',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
|
|
||||||
final List<String> assetsOnDisk = <String>['a/foo', 'abc/bar'];
|
final List<String> assetsOnDisk = <String>['a/foo', 'abc/bar'];
|
||||||
final List<String> assetOnManifest = <String>['a/foo', 'abc/'];
|
final List<String> assetOnManifest = <String>['a/foo', 'abc/'];
|
||||||
@ -639,7 +684,11 @@ $assetsSection
|
|||||||
'One asset is bundled with variant, scanning wrong directory',
|
'One asset is bundled with variant, scanning wrong directory',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
|
|
||||||
final List<String> assetsOnDisk = <String>['a/foo', 'a/b/foo', 'a/bar'];
|
final List<String> assetsOnDisk = <String>['a/foo', 'a/b/foo', 'a/bar'];
|
||||||
final List<String> assetOnManifest = <String>[
|
final List<String> assetOnManifest = <String>[
|
||||||
@ -672,7 +721,11 @@ $assetsSection
|
|||||||
'One asset is bundled with variant, scanning directory',
|
'One asset is bundled with variant, scanning directory',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
|
|
||||||
final List<String> assetsOnDisk = <String>['a/foo', 'a/2x/foo'];
|
final List<String> assetsOnDisk = <String>['a/foo', 'a/2x/foo'];
|
||||||
final List<String> assetOnManifest = <String>['a/'];
|
final List<String> assetOnManifest = <String>['a/'];
|
||||||
@ -698,7 +751,11 @@ $assetsSection
|
|||||||
'No asset is bundled with variant, no assets or directories are listed',
|
'No asset is bundled with variant, no assets or directories are listed',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
|
|
||||||
final List<String> assetsOnDisk = <String>['a/foo', 'a/2x/foo'];
|
final List<String> assetsOnDisk = <String>['a/foo', 'a/2x/foo'];
|
||||||
final List<String> assetOnManifest = <String>[];
|
final List<String> assetOnManifest = <String>[];
|
||||||
@ -722,7 +779,11 @@ $assetsSection
|
|||||||
'Expect error generating manifest, wrong non-existing directory is listed',
|
'Expect error generating manifest, wrong non-existing directory is listed',
|
||||||
() async {
|
() async {
|
||||||
writePubspecFile('pubspec.yaml', 'test');
|
writePubspecFile('pubspec.yaml', 'test');
|
||||||
writePackageConfigFile(<String, String>{'test_package': 'p/p/'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'test_package': 'p/p/'},
|
||||||
|
);
|
||||||
|
|
||||||
final List<String> assetOnManifest = <String>['c/'];
|
final List<String> assetOnManifest = <String>['c/'];
|
||||||
|
|
||||||
|
@ -23,34 +23,11 @@ import 'package:standard_message_codec/standard_message_codec.dart';
|
|||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
import '../src/context.dart';
|
import '../src/context.dart';
|
||||||
|
import '../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
const String shaderLibDir = '/./shader_lib';
|
const String shaderLibDir = '/./shader_lib';
|
||||||
|
|
||||||
File createPackageConfig(
|
|
||||||
FileSystem fileSystem, {
|
|
||||||
Map<String, String> packages = const <String, String>{},
|
|
||||||
}) {
|
|
||||||
final File file = fileSystem.directory('.dart_tool').childFile('package_config.json');
|
|
||||||
file.createSync(recursive: true);
|
|
||||||
file.writeAsStringSync(
|
|
||||||
json.encode(<String, dynamic>{
|
|
||||||
'packages': <dynamic>[
|
|
||||||
...packages.entries.map((MapEntry<String, String> entry) {
|
|
||||||
return <String, dynamic>{
|
|
||||||
'name': entry.key,
|
|
||||||
'rootUri': '../${entry.value}',
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
'languageVersion': '3.2',
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
'configVersion': 2,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
group('AssetBundle.build (using context)', () {
|
group('AssetBundle.build (using context)', () {
|
||||||
late FileSystem testFileSystem;
|
late FileSystem testFileSystem;
|
||||||
late Platform platform;
|
late Platform platform;
|
||||||
@ -115,9 +92,9 @@ void main() {
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'wildcard directories do not include subdirectories',
|
'wildcard directories do not include subdirectories',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs);
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
globals.fs.file('pubspec.yaml').writeAsStringSync('''
|
globals.fs.file('pubspec.yaml').writeAsStringSync('''
|
||||||
name: test
|
name: my_app
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
@ -164,14 +141,18 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'wildcard directories are updated when filesystem changes',
|
'wildcard directories are updated when filesystem changes',
|
||||||
() async {
|
() async {
|
||||||
final File packageFile = createPackageConfig(globals.fs);
|
final File packageFile = writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
|
|
||||||
globals.fs
|
globals.fs
|
||||||
.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- assets/foo/
|
- assets/foo/
|
||||||
@ -224,12 +205,15 @@ flutter:
|
|||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- assets/foo/
|
- assets/foo/
|
||||||
''');
|
''');
|
||||||
final File packageConfig = createPackageConfig(globals.fs);
|
final File packageConfig = writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||||
expect(
|
expect(
|
||||||
@ -250,7 +234,7 @@ flutter:
|
|||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example''')
|
name: my_app''')
|
||||||
..setLastModifiedSync(modifiedTime);
|
..setLastModifiedSync(modifiedTime);
|
||||||
|
|
||||||
// touch the package config to make sure its change time is after pubspec.yaml's
|
// touch the package config to make sure its change time is after pubspec.yaml's
|
||||||
@ -292,12 +276,12 @@ name: example''')
|
|||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- assets/foo/
|
- assets/foo/
|
||||||
''');
|
''');
|
||||||
createPackageConfig(globals.fs);
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
final AssetBundle bundle = AssetBundleFactory.instance.createBundle();
|
||||||
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
await bundle.build(packageConfigPath: '.dart_tool/package_config.json');
|
||||||
expect(
|
expect(
|
||||||
@ -322,7 +306,7 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'deferred assets are parsed',
|
'deferred assets are parsed',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs);
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
globals.fs
|
globals.fs
|
||||||
.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
@ -335,7 +319,7 @@ flutter:
|
|||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- assets/foo/
|
- assets/foo/
|
||||||
@ -380,7 +364,7 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'deferred assets are parsed regularly when splitDeferredAssets Disabled',
|
'deferred assets are parsed regularly when splitDeferredAssets Disabled',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs);
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
globals.fs
|
globals.fs
|
||||||
.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
@ -393,7 +377,7 @@ flutter:
|
|||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- assets/foo/
|
- assets/foo/
|
||||||
@ -430,7 +414,10 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'deferred assets wildcard parsed',
|
'deferred assets wildcard parsed',
|
||||||
() async {
|
() async {
|
||||||
final File packageFile = createPackageConfig(globals.fs);
|
final File packageFile = writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
);
|
||||||
globals.fs
|
globals.fs
|
||||||
.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
.file(globals.fs.path.join('assets', 'foo', 'bar.txt'))
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
@ -443,7 +430,7 @@ flutter:
|
|||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- assets/foo/
|
- assets/foo/
|
||||||
@ -523,11 +510,11 @@ flutter:
|
|||||||
userMessages: UserMessages(),
|
userMessages: UserMessages(),
|
||||||
);
|
);
|
||||||
|
|
||||||
createPackageConfig(fileSystem);
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- https://mywebsite.com/images/
|
- https://mywebsite.com/images/
|
||||||
@ -577,7 +564,7 @@ flutter:
|
|||||||
fileSystem: fileSystem,
|
fileSystem: fileSystem,
|
||||||
userMessages: UserMessages(),
|
userMessages: UserMessages(),
|
||||||
);
|
);
|
||||||
createPackageConfig(fileSystem);
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
@ -612,11 +599,11 @@ flutter:
|
|||||||
|
|
||||||
final BufferLogger logger = BufferLogger.test();
|
final BufferLogger logger = BufferLogger.test();
|
||||||
final FakePlatform platform = FakePlatform();
|
final FakePlatform platform = FakePlatform();
|
||||||
createPackageConfig(fileSystem);
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- path: my-asset.txt
|
- path: my-asset.txt
|
||||||
@ -649,7 +636,7 @@ flutter:
|
|||||||
expect(bundle.entries['my-asset.txt']!.content.isModified, isFalse);
|
expect(bundle.entries['my-asset.txt']!.content.isModified, isFalse);
|
||||||
|
|
||||||
fileSystem.file('pubspec.yaml').writeAsStringSync(r'''
|
fileSystem.file('pubspec.yaml').writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- path: my-asset.txt
|
- path: my-asset.txt
|
||||||
@ -717,9 +704,9 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'pubspec contains an asset',
|
'pubspec contains an asset',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs);
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
globals.fs.file('pubspec.yaml').writeAsStringSync(r'''
|
globals.fs.file('pubspec.yaml').writeAsStringSync(r'''
|
||||||
name: test
|
name: my_app
|
||||||
dependencies:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
@ -809,12 +796,12 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'does not unnecessarily recreate asset manifest, font manifest, license',
|
'does not unnecessarily recreate asset manifest, font manifest, license',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs);
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- assets/foo/bar.txt
|
- assets/foo/bar.txt
|
||||||
@ -843,12 +830,12 @@ assets:
|
|||||||
'inserts dummy file into additionalDependencies when '
|
'inserts dummy file into additionalDependencies when '
|
||||||
'wildcards are used',
|
'wildcards are used',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs);
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
globals.fs.file(globals.fs.path.join('assets', 'bar.txt')).createSync(recursive: true);
|
globals.fs.file(globals.fs.path.join('assets', 'bar.txt')).createSync(recursive: true);
|
||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- assets/
|
- assets/
|
||||||
@ -872,12 +859,12 @@ flutter:
|
|||||||
'Does not insert dummy file into additionalDependencies '
|
'Does not insert dummy file into additionalDependencies '
|
||||||
'when wildcards are not used',
|
'when wildcards are not used',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs);
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
globals.fs.file(globals.fs.path.join('assets', 'bar.txt')).createSync(recursive: true);
|
globals.fs.file(globals.fs.path.join('assets', 'bar.txt')).createSync(recursive: true);
|
||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- assets/bar.txt
|
- assets/bar.txt
|
||||||
@ -920,11 +907,11 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'Including a shader triggers the shader compiler',
|
'Including a shader triggers the shader compiler',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(fileSystem);
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
shaders:
|
shaders:
|
||||||
- assets/shader.frag
|
- assets/shader.frag
|
||||||
@ -978,11 +965,11 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'Included shaders are compiled for the web',
|
'Included shaders are compiled for the web',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(fileSystem);
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
shaders:
|
shaders:
|
||||||
- assets/shader.frag
|
- assets/shader.frag
|
||||||
@ -1040,7 +1027,7 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'Material shaders are compiled for the web',
|
'Material shaders are compiled for the web',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(fileSystem);
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
|
|
||||||
final String materialIconsPath = fileSystem.path.join(
|
final String materialIconsPath = fileSystem.path.join(
|
||||||
getFlutterRoot(),
|
getFlutterRoot(),
|
||||||
@ -1090,7 +1077,7 @@ flutter:
|
|||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
''');
|
''');
|
||||||
@ -1130,12 +1117,16 @@ flutter:
|
|||||||
'Does not insert dummy file into additionalDependencies '
|
'Does not insert dummy file into additionalDependencies '
|
||||||
'when wildcards are used by dependencies',
|
'when wildcards are used by dependencies',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs, packages: <String, String>{'example': '', 'foo': 'foo'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'foo': 'foo'},
|
||||||
|
);
|
||||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
dependencies:
|
dependencies:
|
||||||
foo: any
|
foo: any
|
||||||
''');
|
''');
|
||||||
@ -1164,12 +1155,16 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'does not track wildcard directories from dependencies',
|
'does not track wildcard directories from dependencies',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs, packages: <String, String>{'example': '', 'foo': 'foo'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'foo': 'foo'},
|
||||||
|
);
|
||||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
dependencies:
|
dependencies:
|
||||||
foo: any
|
foo: any
|
||||||
''');
|
''');
|
||||||
@ -1215,12 +1210,16 @@ flutter:
|
|||||||
'reports package that causes asset bundle error when it is '
|
'reports package that causes asset bundle error when it is '
|
||||||
'a dependency',
|
'a dependency',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs, packages: <String, String>{'example': '', 'foo': 'foo'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'foo': 'foo'},
|
||||||
|
);
|
||||||
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true);
|
||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
dependencies:
|
dependencies:
|
||||||
foo: any
|
foo: any
|
||||||
''');
|
''');
|
||||||
@ -1249,11 +1248,15 @@ flutter:
|
|||||||
'does not report package that causes asset bundle error '
|
'does not report package that causes asset bundle error '
|
||||||
'when it is from own pubspec',
|
'when it is from own pubspec',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs, packages: <String, String>{'example': '', 'foo': 'foo'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'foo': 'foo'},
|
||||||
|
);
|
||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
- bar.txt
|
- bar.txt
|
||||||
@ -1274,11 +1277,15 @@ flutter:
|
|||||||
'does not include Material Design assets if uses-material-design: true is '
|
'does not include Material Design assets if uses-material-design: true is '
|
||||||
'specified only by a dependency',
|
'specified only by a dependency',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs, packages: <String, String>{'example': '', 'foo': 'foo'});
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'foo': 'foo'},
|
||||||
|
);
|
||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
dependencies:
|
dependencies:
|
||||||
foo: any
|
foo: any
|
||||||
|
|
||||||
@ -1310,11 +1317,11 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'does not include assets in project directories as asset variants',
|
'does not include assets in project directories as asset variants',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs, packages: <String, String>{'example': ''});
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
@ -1354,11 +1361,11 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'deferred and regular assets are included in manifest alphabetically',
|
'deferred and regular assets are included in manifest alphabetically',
|
||||||
() async {
|
() async {
|
||||||
createPackageConfig(globals.fs, packages: <String, String>{'example': ''});
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'my_app');
|
||||||
globals.fs.file('pubspec.yaml')
|
globals.fs.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync(r'''
|
..writeAsStringSync(r'''
|
||||||
name: example
|
name: my_app
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
|
@ -19,6 +19,7 @@ import 'package:flutter_tools/src/project.dart';
|
|||||||
import 'package:standard_message_codec/standard_message_codec.dart';
|
import 'package:standard_message_codec/standard_message_codec.dart';
|
||||||
|
|
||||||
import '../src/common.dart';
|
import '../src/common.dart';
|
||||||
|
import '../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
Future<Map<String, List<String>>> extractAssetManifestJsonFromBundle(
|
Future<Map<String, List<String>>> extractAssetManifestJsonFromBundle(
|
||||||
@ -58,14 +59,7 @@ void main() {
|
|||||||
fileSystem: fs,
|
fileSystem: fs,
|
||||||
userMessages: UserMessages(),
|
userMessages: UserMessages(),
|
||||||
);
|
);
|
||||||
fs.directory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: fs.currentDirectory, mainLibName: 'test');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": []
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
void createPubspec({required List<String> assets}) {
|
void createPubspec({required List<String> assets}) {
|
||||||
@ -292,14 +286,7 @@ ${assets.map((String entry) => ' - $entry').join('\n')}
|
|||||||
userMessages: UserMessages(),
|
userMessages: UserMessages(),
|
||||||
);
|
);
|
||||||
|
|
||||||
fs.directory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: fs.currentDirectory, mainLibName: 'test');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": []
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
|
|
||||||
fs.file('pubspec.yaml').writeAsStringSync('''
|
fs.file('pubspec.yaml').writeAsStringSync('''
|
||||||
name: test
|
name: test
|
||||||
|
@ -16,6 +16,7 @@ import 'package:flutter_tools/src/build_system/targets/android.dart';
|
|||||||
import '../../../src/common.dart';
|
import '../../../src/common.dart';
|
||||||
import '../../../src/context.dart';
|
import '../../../src/context.dart';
|
||||||
import '../../../src/fake_process_manager.dart';
|
import '../../../src/fake_process_manager.dart';
|
||||||
|
import '../../../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
late FakeProcessManager processManager;
|
late FakeProcessManager processManager;
|
||||||
@ -552,10 +553,7 @@ void main() {
|
|||||||
fileSystem
|
fileSystem
|
||||||
.file('pubspec.yaml')
|
.file('pubspec.yaml')
|
||||||
.writeAsStringSync('name: hello\nflutter:\n shaders:\n - shader.glsl');
|
.writeAsStringSync('name: hello\nflutter:\n shaders:\n - shader.glsl');
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'hello');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
fileSystem.file('shader.glsl').writeAsStringSync('test');
|
fileSystem.file('shader.glsl').writeAsStringSync('test');
|
||||||
|
|
||||||
processManager.addCommands(<FakeCommand>[
|
processManager.addCommands(<FakeCommand>[
|
||||||
|
@ -21,6 +21,7 @@ import 'package:flutter_tools/src/globals.dart' as globals;
|
|||||||
import '../../../src/common.dart';
|
import '../../../src/common.dart';
|
||||||
import '../../../src/context.dart';
|
import '../../../src/context.dart';
|
||||||
import '../../../src/fake_process_manager.dart';
|
import '../../../src/fake_process_manager.dart';
|
||||||
|
import '../../../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
late Environment environment;
|
late Environment environment;
|
||||||
@ -47,7 +48,6 @@ void main() {
|
|||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
fileSystem.file('assets/foo/bar.png').createSync(recursive: true);
|
fileSystem.file('assets/foo/bar.png').createSync(recursive: true);
|
||||||
fileSystem.file('assets/wildcard/#bar.png').createSync(recursive: true);
|
fileSystem.file('assets/wildcard/#bar.png').createSync(recursive: true);
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
|
||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync('''
|
..writeAsStringSync('''
|
||||||
@ -64,20 +64,11 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'includes LICENSE file inputs in dependencies',
|
'includes LICENSE file inputs in dependencies',
|
||||||
() async {
|
() async {
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(
|
||||||
..createSync(recursive: true)
|
directory: globals.fs.currentDirectory,
|
||||||
..writeAsStringSync('''
|
mainLibName: 'example',
|
||||||
{
|
packages: <String, String>{'foo': 'bar'},
|
||||||
"configVersion": 2,
|
);
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"rootUri": "file:///bar",
|
|
||||||
"packageUri": "lib/"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
fileSystem.file('bar/LICENSE')
|
fileSystem.file('bar/LICENSE')
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync('THIS IS A LICENSE');
|
..writeAsStringSync('THIS IS A LICENSE');
|
||||||
@ -104,6 +95,7 @@ flutter:
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'Copies files to correct asset directory',
|
'Copies files to correct asset directory',
|
||||||
() async {
|
() async {
|
||||||
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'example');
|
||||||
await const CopyAssets().build(environment);
|
await const CopyAssets().build(environment);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
@ -152,6 +144,7 @@ flutter:
|
|||||||
flavors:
|
flavors:
|
||||||
- strawberry
|
- strawberry
|
||||||
''');
|
''');
|
||||||
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'example');
|
||||||
|
|
||||||
fileSystem.file('assets/common/image.png').createSync(recursive: true);
|
fileSystem.file('assets/common/image.png').createSync(recursive: true);
|
||||||
fileSystem.file('assets/vanilla/ice-cream.png').createSync(recursive: true);
|
fileSystem.file('assets/vanilla/ice-cream.png').createSync(recursive: true);
|
||||||
@ -200,6 +193,7 @@ flutter:
|
|||||||
flavors:
|
flavors:
|
||||||
- strawberry
|
- strawberry
|
||||||
''');
|
''');
|
||||||
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'example');
|
||||||
|
|
||||||
fileSystem.file('assets/common/image.png').createSync(recursive: true);
|
fileSystem.file('assets/common/image.png').createSync(recursive: true);
|
||||||
fileSystem.file('assets/vanilla/ice-cream.png').createSync(recursive: true);
|
fileSystem.file('assets/vanilla/ice-cream.png').createSync(recursive: true);
|
||||||
@ -251,11 +245,6 @@ flutter:
|
|||||||
defines: <String, String>{kBuildMode: BuildMode.debug.cliName},
|
defines: <String, String>{kBuildMode: BuildMode.debug.cliName},
|
||||||
);
|
);
|
||||||
|
|
||||||
fileSystem
|
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
|
|
||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync('''
|
..writeAsStringSync('''
|
||||||
@ -268,6 +257,8 @@ flutter:
|
|||||||
args: ["-a", "-b", "--color", "green"]
|
args: ["-a", "-b", "--color", "green"]
|
||||||
''');
|
''');
|
||||||
|
|
||||||
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'example');
|
||||||
|
|
||||||
fileSystem.file('input.txt')
|
fileSystem.file('input.txt')
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync('abc');
|
..writeAsStringSync('abc');
|
||||||
@ -341,11 +332,6 @@ flutter:
|
|||||||
defines: <String, String>{kBuildMode: BuildMode.debug.cliName},
|
defines: <String, String>{kBuildMode: BuildMode.debug.cliName},
|
||||||
);
|
);
|
||||||
|
|
||||||
fileSystem
|
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
|
|
||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync('''
|
..writeAsStringSync('''
|
||||||
@ -358,6 +344,8 @@ flutter:
|
|||||||
args: ["-a", "-b", "--color", "green"]
|
args: ["-a", "-b", "--color", "green"]
|
||||||
''');
|
''');
|
||||||
|
|
||||||
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'example');
|
||||||
|
|
||||||
await fileSystem.file('input.txt').create(recursive: true);
|
await fileSystem.file('input.txt').create(recursive: true);
|
||||||
|
|
||||||
await expectToolExitLater(
|
await expectToolExitLater(
|
||||||
@ -441,11 +429,6 @@ flutter:
|
|||||||
defines: <String, String>{kBuildMode: BuildMode.debug.cliName},
|
defines: <String, String>{kBuildMode: BuildMode.debug.cliName},
|
||||||
);
|
);
|
||||||
|
|
||||||
fileSystem
|
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
|
|
||||||
fileSystem.file('pubspec.yaml')
|
fileSystem.file('pubspec.yaml')
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync('''
|
..writeAsStringSync('''
|
||||||
@ -457,6 +440,8 @@ flutter:
|
|||||||
- package: my_capitalizer_transformer
|
- package: my_capitalizer_transformer
|
||||||
''');
|
''');
|
||||||
|
|
||||||
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'example');
|
||||||
|
|
||||||
fileSystem.file('input.txt')
|
fileSystem.file('input.txt')
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync('abc');
|
..writeAsStringSync('abc');
|
||||||
|
@ -17,6 +17,7 @@ import '../../../src/common.dart';
|
|||||||
import '../../../src/context.dart';
|
import '../../../src/context.dart';
|
||||||
import '../../../src/fake_pub_deps.dart';
|
import '../../../src/fake_pub_deps.dart';
|
||||||
import '../../../src/fakes.dart';
|
import '../../../src/fakes.dart';
|
||||||
|
import '../../../src/package_config.dart';
|
||||||
|
|
||||||
const String _kEmptyPubspecFile = '''
|
const String _kEmptyPubspecFile = '''
|
||||||
name: path_provider_example
|
name: path_provider_example
|
||||||
@ -26,40 +27,6 @@ dependencies:
|
|||||||
sdk: flutter
|
sdk: flutter
|
||||||
''';
|
''';
|
||||||
|
|
||||||
const String _kEmptyPackageJson = '''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "path_provider_example",
|
|
||||||
"rootUri": "../",
|
|
||||||
"packageUri": "lib/",
|
|
||||||
"languageVersion": "2.12"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
|
|
||||||
const String _kSamplePackageJson = '''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "path_provider_linux",
|
|
||||||
"rootUri": "/path_provider_linux",
|
|
||||||
"packageUri": "lib/",
|
|
||||||
"languageVersion": "2.12"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "path_provider_example",
|
|
||||||
"rootUri": "../",
|
|
||||||
"packageUri": "lib/",
|
|
||||||
"languageVersion": "2.12"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
''';
|
|
||||||
|
|
||||||
const String _kSamplePubspecFile = '''
|
const String _kSamplePubspecFile = '''
|
||||||
name: path_provider_example
|
name: path_provider_example
|
||||||
description: Demonstrates how to use the path_provider plugin.
|
description: Demonstrates how to use the path_provider plugin.
|
||||||
@ -174,11 +141,15 @@ void main() {
|
|||||||
generateDartPluginRegistry: true,
|
generateDartPluginRegistry: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
projectDir.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(
|
||||||
..createSync(recursive: true)
|
directory: projectDir,
|
||||||
..writeAsStringSync(_kSamplePackageJson);
|
mainLibName: 'path_provider_example',
|
||||||
|
packages: <String, String>{'path_provider_linux': '/path_provider_linux'},
|
||||||
|
);
|
||||||
|
|
||||||
projectDir.childFile('pubspec.yaml').createSync();
|
projectDir.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
|
name: path_provider_example
|
||||||
|
''');
|
||||||
|
|
||||||
final FlutterProject testProject = FlutterProject.fromDirectoryTest(projectDir);
|
final FlutterProject testProject = FlutterProject.fromDirectoryTest(projectDir);
|
||||||
await DartPluginRegistrantTarget.test(testProject).build(environment);
|
await DartPluginRegistrantTarget.test(testProject).build(environment);
|
||||||
@ -213,9 +184,12 @@ void main() {
|
|||||||
generateDartPluginRegistry: true,
|
generateDartPluginRegistry: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
projectDir.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(
|
||||||
..createSync(recursive: true)
|
directory: projectDir,
|
||||||
..writeAsStringSync(_kSamplePackageJson);
|
mainLibName: 'path_provider_example',
|
||||||
|
packages: <String, String>{'path_provider_linux': '/path_provider_linux'},
|
||||||
|
languageVersions: <String, String>{'path_provider_example': '2.12'},
|
||||||
|
);
|
||||||
|
|
||||||
projectDir.childFile('pubspec.yaml').writeAsStringSync(_kSamplePubspecFile);
|
projectDir.childFile('pubspec.yaml').writeAsStringSync(_kSamplePubspecFile);
|
||||||
|
|
||||||
@ -296,10 +270,11 @@ void main() {
|
|||||||
},
|
},
|
||||||
generateDartPluginRegistry: true,
|
generateDartPluginRegistry: true,
|
||||||
);
|
);
|
||||||
final File config =
|
writePackageConfigFile(
|
||||||
projectDir.childDirectory('.dart_tool').childFile('package_config.json')
|
directory: projectDir,
|
||||||
..createSync(recursive: true)
|
mainLibName: 'path_provider_example',
|
||||||
..writeAsStringSync(_kSamplePackageJson);
|
packages: <String, String>{'path_provider_linux': '/path_provider_linux'},
|
||||||
|
);
|
||||||
|
|
||||||
final File pubspec = projectDir.childFile('pubspec.yaml')
|
final File pubspec = projectDir.childFile('pubspec.yaml')
|
||||||
..writeAsStringSync(_kSamplePubspecFile);
|
..writeAsStringSync(_kSamplePubspecFile);
|
||||||
@ -321,7 +296,7 @@ void main() {
|
|||||||
|
|
||||||
// Simulate a user removing everything from pubspec.yaml.
|
// Simulate a user removing everything from pubspec.yaml.
|
||||||
pubspec.writeAsStringSync(_kEmptyPubspecFile);
|
pubspec.writeAsStringSync(_kEmptyPubspecFile);
|
||||||
config.writeAsStringSync(_kEmptyPackageJson);
|
writePackageConfigFile(directory: projectDir, mainLibName: 'path_provider_example');
|
||||||
|
|
||||||
await DartPluginRegistrantTarget.test(testProject).build(environment);
|
await DartPluginRegistrantTarget.test(testProject).build(environment);
|
||||||
expect(generatedMain.existsSync(), isFalse);
|
expect(generatedMain.existsSync(), isFalse);
|
||||||
@ -350,9 +325,11 @@ void main() {
|
|||||||
generateDartPluginRegistry: true,
|
generateDartPluginRegistry: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
projectDir.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(
|
||||||
..createSync(recursive: true)
|
directory: projectDir,
|
||||||
..writeAsStringSync(_kSamplePackageJson);
|
mainLibName: 'path_provider_example',
|
||||||
|
packages: <String, String>{'path_provider_linux': '/path_provider_linux'},
|
||||||
|
);
|
||||||
|
|
||||||
projectDir.childFile('pubspec.yaml').writeAsStringSync(_kSamplePubspecFile);
|
projectDir.childFile('pubspec.yaml').writeAsStringSync(_kSamplePubspecFile);
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import '../../../src/common.dart';
|
|||||||
import '../../../src/context.dart';
|
import '../../../src/context.dart';
|
||||||
import '../../../src/fake_process_manager.dart';
|
import '../../../src/fake_process_manager.dart';
|
||||||
import '../../../src/fakes.dart';
|
import '../../../src/fakes.dart';
|
||||||
|
import '../../../src/package_config.dart';
|
||||||
|
|
||||||
final Platform macPlatform = FakePlatform(
|
final Platform macPlatform = FakePlatform(
|
||||||
operatingSystem: 'macos',
|
operatingSystem: 'macos',
|
||||||
@ -208,11 +209,8 @@ void main() {
|
|||||||
.file(artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: BuildMode.debug))
|
.file(artifacts.getArtifactPath(Artifact.isolateSnapshotData, mode: BuildMode.debug))
|
||||||
.createSync();
|
.createSync();
|
||||||
// Project info
|
// Project info
|
||||||
fileSystem.file('pubspec.yaml').writeAsStringSync('name: hello');
|
fileSystem.file('pubspec.yaml').writeAsStringSync('name: my_app');
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
// Plist file
|
// Plist file
|
||||||
fileSystem
|
fileSystem
|
||||||
.file(fileSystem.path.join('ios', 'Flutter', 'AppFrameworkInfo.plist'))
|
.file(fileSystem.path.join('ios', 'Flutter', 'AppFrameworkInfo.plist'))
|
||||||
@ -390,11 +388,8 @@ void main() {
|
|||||||
// Project info
|
// Project info
|
||||||
fileSystem
|
fileSystem
|
||||||
.file('pubspec.yaml')
|
.file('pubspec.yaml')
|
||||||
.writeAsStringSync('name: hello\nflutter:\n shaders:\n - shader.glsl');
|
.writeAsStringSync('name: my_app\nflutter:\n shaders:\n - shader.glsl');
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
// Plist file
|
// Plist file
|
||||||
fileSystem
|
fileSystem
|
||||||
.file(fileSystem.path.join('ios', 'Flutter', 'AppFrameworkInfo.plist'))
|
.file(fileSystem.path.join('ios', 'Flutter', 'AppFrameworkInfo.plist'))
|
||||||
@ -474,11 +469,9 @@ void main() {
|
|||||||
environment.defines[kXcodeAction] = 'build';
|
environment.defines[kXcodeAction] = 'build';
|
||||||
|
|
||||||
// Project info
|
// Project info
|
||||||
fileSystem.file('pubspec.yaml').writeAsStringSync('name: hello');
|
fileSystem.file('pubspec.yaml').writeAsStringSync('name: my_app');
|
||||||
fileSystem
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
.directory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
// Plist file
|
// Plist file
|
||||||
fileSystem
|
fileSystem
|
||||||
.file(fileSystem.path.join('ios', 'Flutter', 'AppFrameworkInfo.plist'))
|
.file(fileSystem.path.join('ios', 'Flutter', 'AppFrameworkInfo.plist'))
|
||||||
|
@ -23,6 +23,7 @@ import '../../../src/common.dart';
|
|||||||
import '../../../src/fake_process_manager.dart';
|
import '../../../src/fake_process_manager.dart';
|
||||||
import '../../../src/fake_pub_deps.dart';
|
import '../../../src/fake_pub_deps.dart';
|
||||||
import '../../../src/fakes.dart';
|
import '../../../src/fakes.dart';
|
||||||
|
import '../../../src/package_config.dart';
|
||||||
import '../../../src/testbed.dart';
|
import '../../../src/testbed.dart';
|
||||||
|
|
||||||
const List<String> _kDart2jsLinuxArgs = <String>[
|
const List<String> _kDart2jsLinuxArgs = <String>[
|
||||||
@ -61,21 +62,16 @@ void main() {
|
|||||||
setUp(() {
|
setUp(() {
|
||||||
testbed = Testbed(
|
testbed = Testbed(
|
||||||
setup: () {
|
setup: () {
|
||||||
globals.fs.directory('.dart_tool').childFile('package_config.json')
|
globals.fs.currentDirectory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
..createSync(recursive: true)
|
name: foo
|
||||||
..writeAsStringSync('''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "foo",
|
|
||||||
"rootUri": "../foo/",
|
|
||||||
"packageUri": "lib/",
|
|
||||||
"languageVersion": "2.7"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
''');
|
''');
|
||||||
|
|
||||||
|
writePackageConfigFile(
|
||||||
|
directory: globals.fs.currentDirectory,
|
||||||
|
mainLibName: 'my_app',
|
||||||
|
packages: <String, String>{'foo': 'foo/'},
|
||||||
|
languageVersions: <String, String>{'foo': '2.7'},
|
||||||
|
);
|
||||||
globals.fs.currentDirectory.childDirectory('bar').createSync();
|
globals.fs.currentDirectory.childDirectory('bar').createSync();
|
||||||
processManager = FakeProcessManager.empty();
|
processManager = FakeProcessManager.empty();
|
||||||
globals.fs
|
globals.fs
|
||||||
|
@ -26,6 +26,7 @@ import 'package:test/fake.dart';
|
|||||||
import '../../src/common.dart';
|
import '../../src/common.dart';
|
||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
|
|
||||||
void _writeCustomDevicesConfigFile(Directory dir, List<CustomDeviceConfig> configs) {
|
void _writeCustomDevicesConfigFile(Directory dir, List<CustomDeviceConfig> configs) {
|
||||||
dir.createSync();
|
dir.createSync();
|
||||||
@ -298,7 +299,7 @@ void main() {
|
|||||||
testWithoutContext('CustomDevice.isSupportedForProject is true with editable host app', () async {
|
testWithoutContext('CustomDevice.isSupportedForProject is true with editable host app', () async {
|
||||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
fileSystem.file('pubspec.yaml').createSync();
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
|
|
||||||
final FlutterProject flutterProject = _setUpFlutterProject(fileSystem.currentDirectory);
|
final FlutterProject flutterProject = _setUpFlutterProject(fileSystem.currentDirectory);
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import 'package:flutter_tools/src/project.dart';
|
|||||||
import '../../src/common.dart';
|
import '../../src/common.dart';
|
||||||
import '../../src/fake_process_manager.dart';
|
import '../../src/fake_process_manager.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
setUpAll(() {
|
setUpAll(() {
|
||||||
@ -750,12 +751,11 @@ exit code: 66
|
|||||||
'get',
|
'get',
|
||||||
'--example',
|
'--example',
|
||||||
],
|
],
|
||||||
onRun: (_) {
|
onRun:
|
||||||
fileSystem.currentDirectory
|
(_) => writePackageConfigFile(
|
||||||
.childDirectory('.dart_tool')
|
directory: fileSystem.currentDirectory,
|
||||||
.childFile('package_config.json')
|
mainLibName: 'my_app',
|
||||||
.createSync(recursive: true);
|
),
|
||||||
},
|
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -907,12 +907,11 @@ exit code: 66
|
|||||||
'FLUTTER_ROOT': '',
|
'FLUTTER_ROOT': '',
|
||||||
'PUB_ENVIRONMENT': 'flutter_cli:flutter_tests',
|
'PUB_ENVIRONMENT': 'flutter_cli:flutter_tests',
|
||||||
},
|
},
|
||||||
onRun: (_) {
|
onRun:
|
||||||
fileSystem.currentDirectory
|
(_) => writePackageConfigFile(
|
||||||
.childDirectory('.dart_tool')
|
directory: fileSystem.currentDirectory,
|
||||||
.childFile('package_config.json')
|
mainLibName: 'my_app',
|
||||||
.createSync(recursive: true);
|
),
|
||||||
},
|
|
||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:flutter_tools/src/dart/package_map.dart';
|
import 'package:flutter_tools/src/dart/package_map.dart';
|
||||||
@ -23,6 +21,7 @@ import '../src/common.dart';
|
|||||||
import '../src/context.dart';
|
import '../src/context.dart';
|
||||||
import '../src/fake_pub_deps.dart';
|
import '../src/fake_pub_deps.dart';
|
||||||
import '../src/fakes.dart';
|
import '../src/fakes.dart';
|
||||||
|
import '../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// TODO(matanlurey): Remove after `explicit-package-dependencies` is enabled by default.
|
// TODO(matanlurey): Remove after `explicit-package-dependencies` is enabled by default.
|
||||||
@ -47,10 +46,7 @@ void main() {
|
|||||||
..flutterPluginsFile = directory.childFile('.flutter-plugins')
|
..flutterPluginsFile = directory.childFile('.flutter-plugins')
|
||||||
..flutterPluginsDependenciesFile = directory.childFile('.flutter-plugins-dependencies')
|
..flutterPluginsDependenciesFile = directory.childFile('.flutter-plugins-dependencies')
|
||||||
..dartPluginRegistrant = directory.childFile('dart_plugin_registrant.dart');
|
..dartPluginRegistrant = directory.childFile('dart_plugin_registrant.dart');
|
||||||
flutterProject.directory
|
writePackageConfigFile(directory: flutterProject.directory, mainLibName: 'my_app');
|
||||||
.childDirectory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
group('resolvePlatformImplementation', () {
|
group('resolvePlatformImplementation', () {
|
||||||
@ -1282,7 +1278,7 @@ void main() {
|
|||||||
'Plugin without platform support throws tool exit',
|
'Plugin without platform support throws tool exit',
|
||||||
() async {
|
() async {
|
||||||
flutterProject.isModule = false;
|
flutterProject.isModule = false;
|
||||||
|
flutterManifest.dependencies.add('url_launcher_macos');
|
||||||
createFakeDartPlugins(flutterProject, flutterManifest, fs, <String, String>{
|
createFakeDartPlugins(flutterProject, flutterManifest, fs, <String, String>{
|
||||||
'url_launcher_macos': '''
|
'url_launcher_macos': '''
|
||||||
flutter:
|
flutter:
|
||||||
@ -1375,6 +1371,7 @@ void main() {
|
|||||||
'Does not create new entrypoint if there are no platform resolutions',
|
'Does not create new entrypoint if there are no platform resolutions',
|
||||||
() async {
|
() async {
|
||||||
flutterProject.isModule = false;
|
flutterProject.isModule = false;
|
||||||
|
createFakeDartPlugins(flutterProject, flutterManifest, fs, <String, String>{});
|
||||||
|
|
||||||
final Directory libDir = flutterProject.directory.childDirectory('lib');
|
final Directory libDir = flutterProject.directory.childDirectory('lib');
|
||||||
libDir.createSync(recursive: true);
|
libDir.createSync(recursive: true);
|
||||||
@ -1456,23 +1453,6 @@ void main() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToPackageConfig(FlutterProject project, String name, Directory packageDir) {
|
|
||||||
final File packageConfigFile = project.directory
|
|
||||||
.childDirectory('.dart_tool')
|
|
||||||
.childFile('package_config.json');
|
|
||||||
|
|
||||||
final Map<String, Object?> packageConfig =
|
|
||||||
jsonDecode(packageConfigFile.readAsStringSync()) as Map<String, Object?>;
|
|
||||||
|
|
||||||
(packageConfig['packages']! as List<Object?>).add(<String, Object?>{
|
|
||||||
'name': name,
|
|
||||||
'rootUri': packageDir.uri.toString(),
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
});
|
|
||||||
|
|
||||||
packageConfigFile.writeAsStringSync(jsonEncode(packageConfig));
|
|
||||||
}
|
|
||||||
|
|
||||||
void createFakeDartPlugins(
|
void createFakeDartPlugins(
|
||||||
FakeFlutterProject flutterProject,
|
FakeFlutterProject flutterProject,
|
||||||
FakeFlutterManifest flutterManifest,
|
FakeFlutterManifest flutterManifest,
|
||||||
@ -1480,21 +1460,18 @@ void createFakeDartPlugins(
|
|||||||
Map<String, String> plugins,
|
Map<String, String> plugins,
|
||||||
) {
|
) {
|
||||||
final Directory fakePubCache = fs.systemTempDirectory.childDirectory('cache');
|
final Directory fakePubCache = fs.systemTempDirectory.childDirectory('cache');
|
||||||
|
writePackageConfigFile(
|
||||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json')
|
directory: flutterProject.directory,
|
||||||
..deleteSync(recursive: true)
|
mainLibName: flutterProject.manifest.appName,
|
||||||
..createSync(recursive: true)
|
packages: <String, String>{
|
||||||
..writeAsStringSync('''
|
for (final String name in plugins.keys)
|
||||||
{
|
name: fakePubCache.childDirectory(name).uri.toString(),
|
||||||
"packages": [],
|
},
|
||||||
"configVersion": 2
|
);
|
||||||
}
|
|
||||||
''');
|
|
||||||
|
|
||||||
for (final MapEntry<String, String> entry in plugins.entries) {
|
for (final MapEntry<String, String> entry in plugins.entries) {
|
||||||
final String name = fs.path.basename(entry.key);
|
final String name = fs.path.basename(entry.key);
|
||||||
final Directory pluginDirectory = fakePubCache.childDirectory(name);
|
final Directory pluginDirectory = fakePubCache.childDirectory(name);
|
||||||
addToPackageConfig(flutterProject, name, pluginDirectory);
|
|
||||||
pluginDirectory.childFile('pubspec.yaml')
|
pluginDirectory.childFile('pubspec.yaml')
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync(entry.value);
|
..writeAsStringSync(entry.value);
|
||||||
@ -1505,6 +1482,9 @@ void createFakeDartPlugins(
|
|||||||
class FakeFlutterManifest extends Fake implements FlutterManifest {
|
class FakeFlutterManifest extends Fake implements FlutterManifest {
|
||||||
@override
|
@override
|
||||||
Set<String> dependencies = <String>{};
|
Set<String> dependencies = <String>{};
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get appName => 'myapp';
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeFlutterProject extends Fake implements FlutterProject {
|
class FakeFlutterProject extends Fake implements FlutterProject {
|
||||||
|
@ -24,6 +24,7 @@ import '../src/common.dart';
|
|||||||
import '../src/context.dart';
|
import '../src/context.dart';
|
||||||
import '../src/fake_pub_deps.dart';
|
import '../src/fake_pub_deps.dart';
|
||||||
import '../src/fakes.dart';
|
import '../src/fakes.dart';
|
||||||
|
import '../src/package_config.dart';
|
||||||
import 'hot_shared.dart';
|
import 'hot_shared.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -182,14 +183,7 @@ void main() {
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'setupHotRestart function fails',
|
'setupHotRestart function fails',
|
||||||
() async {
|
() async {
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": []
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
final FakeDevice device = FakeDevice();
|
final FakeDevice device = FakeDevice();
|
||||||
final List<FlutterDevice> devices = <FlutterDevice>[FakeFlutterDevice(device)];
|
final List<FlutterDevice> devices = <FlutterDevice>[FakeFlutterDevice(device)];
|
||||||
final OperationResult result = await HotRunner(
|
final OperationResult result = await HotRunner(
|
||||||
@ -217,14 +211,7 @@ void main() {
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'setupHotReload function fails',
|
'setupHotReload function fails',
|
||||||
() async {
|
() async {
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": []
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
final FakeDevice device = FakeDevice();
|
final FakeDevice device = FakeDevice();
|
||||||
final FakeFlutterDevice fakeFlutterDevice = FakeFlutterDevice(device);
|
final FakeFlutterDevice fakeFlutterDevice = FakeFlutterDevice(device);
|
||||||
final List<FlutterDevice> devices = <FlutterDevice>[fakeFlutterDevice];
|
final List<FlutterDevice> devices = <FlutterDevice>[fakeFlutterDevice];
|
||||||
@ -273,14 +260,7 @@ void main() {
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'shutdown hook called after signal',
|
'shutdown hook called after signal',
|
||||||
() async {
|
() async {
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": []
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
final FakeDevice device = FakeDevice();
|
final FakeDevice device = FakeDevice();
|
||||||
final List<FlutterDevice> devices = <FlutterDevice>[
|
final List<FlutterDevice> devices = <FlutterDevice>[
|
||||||
FlutterDevice(
|
FlutterDevice(
|
||||||
@ -310,14 +290,7 @@ void main() {
|
|||||||
testUsingContext(
|
testUsingContext(
|
||||||
'shutdown hook called after app stop',
|
'shutdown hook called after app stop',
|
||||||
() async {
|
() async {
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": []
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
final FakeDevice device = FakeDevice();
|
final FakeDevice device = FakeDevice();
|
||||||
final List<FlutterDevice> devices = <FlutterDevice>[
|
final List<FlutterDevice> devices = <FlutterDevice>[
|
||||||
FlutterDevice(
|
FlutterDevice(
|
||||||
@ -680,14 +653,7 @@ void main() {
|
|||||||
'Exits with code 2 when HttpException is thrown '
|
'Exits with code 2 when HttpException is thrown '
|
||||||
'during VM service connection',
|
'during VM service connection',
|
||||||
() async {
|
() async {
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": []
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
|
|
||||||
final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
|
final FakeResidentCompiler residentCompiler = FakeResidentCompiler();
|
||||||
final FakeDevice device = FakeDevice();
|
final FakeDevice device = FakeDevice();
|
||||||
|
@ -37,6 +37,7 @@ import '../../src/fake_devices.dart';
|
|||||||
import '../../src/fake_process_manager.dart';
|
import '../../src/fake_process_manager.dart';
|
||||||
import '../../src/fake_pub_deps.dart';
|
import '../../src/fake_pub_deps.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
|
|
||||||
List<String> _xattrArgs(FlutterProject flutterProject) {
|
List<String> _xattrArgs(FlutterProject flutterProject) {
|
||||||
return <String>['xattr', '-r', '-d', 'com.apple.FinderInfo', flutterProject.directory.path];
|
return <String>['xattr', '-r', '-d', 'com.apple.FinderInfo', flutterProject.directory.path];
|
||||||
@ -1156,8 +1157,10 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setUpIOSProject(FileSystem fileSystem, {bool createWorkspace = true}) {
|
void setUpIOSProject(FileSystem fileSystem, {bool createWorkspace = true}) {
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
fileSystem.file('pubspec.yaml').writeAsStringSync('''
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
name: my_app
|
||||||
|
''');
|
||||||
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
fileSystem.directory('ios').createSync();
|
fileSystem.directory('ios').createSync();
|
||||||
if (createWorkspace) {
|
if (createWorkspace) {
|
||||||
fileSystem.directory('ios/Runner.xcworkspace').createSync();
|
fileSystem.directory('ios/Runner.xcworkspace').createSync();
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:flutter_tools/src/artifacts.dart';
|
import 'package:flutter_tools/src/artifacts.dart';
|
||||||
@ -28,6 +26,7 @@ import '../../src/context.dart';
|
|||||||
import '../../src/fake_process_manager.dart';
|
import '../../src/fake_process_manager.dart';
|
||||||
import '../../src/fake_pub_deps.dart';
|
import '../../src/fake_pub_deps.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
late BufferLogger logger;
|
late BufferLogger logger;
|
||||||
@ -658,7 +657,9 @@ duplicate symbol '_$s29plugin_1_name23PluginNamePluginC9setDouble3key5valueySS_S
|
|||||||
final FakeFlutterProject project = FakeFlutterProject(fileSystem: fs);
|
final FakeFlutterProject project = FakeFlutterProject(fileSystem: fs);
|
||||||
project.ios.podfile.createSync(recursive: true);
|
project.ios.podfile.createSync(recursive: true);
|
||||||
project.manifest = FakeFlutterManifest();
|
project.manifest = FakeFlutterManifest();
|
||||||
createFakePlugins(project, fs, <String>['plugin_1_name', 'plugin_2_name']);
|
final List<String> pluginNames = <String>['plugin_1_name', 'plugin_2_name'];
|
||||||
|
project.manifest.dependencies.addAll(pluginNames);
|
||||||
|
createFakePlugins(project, fs, pluginNames);
|
||||||
fs.systemTempDirectory
|
fs.systemTempDirectory
|
||||||
.childFile('cache/plugin_1_name/ios/plugin_1_name/Package.swift')
|
.childFile('cache/plugin_1_name/ios/plugin_1_name/Package.swift')
|
||||||
.createSync(recursive: true);
|
.createSync(recursive: true);
|
||||||
@ -770,23 +771,6 @@ duplicate symbol '_$s29plugin_1_name23PluginNamePluginC9setDouble3key5valueySS_S
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void addToPackageConfig(FlutterProject flutterProject, String name, Directory packageDir) {
|
|
||||||
final File packageConfigFile = flutterProject.directory
|
|
||||||
.childDirectory('.dart_tool')
|
|
||||||
.childFile('package_config.json');
|
|
||||||
|
|
||||||
final Map<String, Object?> packageConfig =
|
|
||||||
jsonDecode(packageConfigFile.readAsStringSync()) as Map<String, Object?>;
|
|
||||||
|
|
||||||
(packageConfig['packages']! as List<Object?>).add(<String, Object?>{
|
|
||||||
'name': name,
|
|
||||||
'rootUri': packageDir.uri.toString(),
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
});
|
|
||||||
|
|
||||||
packageConfigFile.writeAsStringSync(jsonEncode(packageConfig));
|
|
||||||
}
|
|
||||||
|
|
||||||
void createFakePlugins(
|
void createFakePlugins(
|
||||||
FlutterProject flutterProject,
|
FlutterProject flutterProject,
|
||||||
FileSystem fileSystem,
|
FileSystem fileSystem,
|
||||||
@ -803,17 +787,15 @@ void createFakePlugins(
|
|||||||
''';
|
''';
|
||||||
|
|
||||||
final Directory fakePubCache = fileSystem.systemTempDirectory.childDirectory('cache');
|
final Directory fakePubCache = fileSystem.systemTempDirectory.childDirectory('cache');
|
||||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(
|
||||||
..createSync(recursive: true)
|
directory: flutterProject.directory,
|
||||||
..writeAsStringSync('''
|
mainLibName: 'my_app',
|
||||||
{
|
packages: <String, String>{
|
||||||
"packages": [],
|
for (final String name in pluginNames) name: fakePubCache.childDirectory(name).path,
|
||||||
"configVersion": 2
|
},
|
||||||
}
|
);
|
||||||
''');
|
|
||||||
for (final String name in pluginNames) {
|
for (final String name in pluginNames) {
|
||||||
final Directory pluginDirectory = fakePubCache.childDirectory(name);
|
final Directory pluginDirectory = fakePubCache.childDirectory(name);
|
||||||
addToPackageConfig(flutterProject, name, pluginDirectory);
|
|
||||||
pluginDirectory.childFile('pubspec.yaml')
|
pluginDirectory.childFile('pubspec.yaml')
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync(pluginYamlTemplate.replaceAll('PLUGIN_CLASS', name));
|
..writeAsStringSync(pluginYamlTemplate.replaceAll('PLUGIN_CLASS', name));
|
||||||
|
@ -18,6 +18,7 @@ import 'package:native_assets_cli/code_assets_builder.dart';
|
|||||||
import '../../../../src/common.dart';
|
import '../../../../src/common.dart';
|
||||||
import '../../../../src/context.dart';
|
import '../../../../src/context.dart';
|
||||||
import '../../../../src/fakes.dart';
|
import '../../../../src/fakes.dart';
|
||||||
|
import '../../../../src/package_config.dart';
|
||||||
import '../../fake_native_assets_build_runner.dart';
|
import '../../fake_native_assets_build_runner.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -73,7 +74,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext('NativeAssets defaults to ios archs if missing', () async {
|
testUsingContext('NativeAssets defaults to ios archs if missing', () async {
|
||||||
await createPackageConfig(iosEnvironment);
|
writePackageConfigFile(directory: iosEnvironment.projectDir, mainLibName: 'my_app');
|
||||||
|
|
||||||
iosEnvironment.defines.remove(kIosArchs);
|
iosEnvironment.defines.remove(kIosArchs);
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ void main() {
|
|||||||
'NativeAssets throws error if missing sdk root',
|
'NativeAssets throws error if missing sdk root',
|
||||||
overrides: <Type, Generator>{FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true)},
|
overrides: <Type, Generator>{FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true)},
|
||||||
() async {
|
() async {
|
||||||
await createPackageConfig(iosEnvironment);
|
writePackageConfigFile(directory: iosEnvironment.projectDir, mainLibName: 'my_app');
|
||||||
|
|
||||||
final FlutterNativeAssetsBuildRunner buildRunner = FakeFlutterNativeAssetsBuildRunner(
|
final FlutterNativeAssetsBuildRunner buildRunner = FakeFlutterNativeAssetsBuildRunner(
|
||||||
packagesWithNativeAssetsResult: <String>['foo'],
|
packagesWithNativeAssetsResult: <String>['foo'],
|
||||||
@ -116,7 +117,7 @@ void main() {
|
|||||||
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: isNativeAssetsEnabled),
|
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: isNativeAssetsEnabled),
|
||||||
},
|
},
|
||||||
() async {
|
() async {
|
||||||
await createPackageConfig(iosEnvironment);
|
writePackageConfigFile(directory: iosEnvironment.projectDir, mainLibName: 'my_app');
|
||||||
|
|
||||||
final FlutterNativeAssetsBuildRunner buildRunner = FakeFlutterNativeAssetsBuildRunner();
|
final FlutterNativeAssetsBuildRunner buildRunner = FakeFlutterNativeAssetsBuildRunner();
|
||||||
await DartBuildForNative(buildRunner: buildRunner).build(iosEnvironment);
|
await DartBuildForNative(buildRunner: buildRunner).build(iosEnvironment);
|
||||||
@ -186,7 +187,7 @@ void main() {
|
|||||||
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true),
|
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true),
|
||||||
},
|
},
|
||||||
() async {
|
() async {
|
||||||
await createPackageConfig(iosEnvironment);
|
writePackageConfigFile(directory: iosEnvironment.projectDir, mainLibName: 'my_app');
|
||||||
|
|
||||||
final List<CodeAsset> codeAssets = <CodeAsset>[
|
final List<CodeAsset> codeAssets = <CodeAsset>[
|
||||||
CodeAsset(
|
CodeAsset(
|
||||||
@ -252,7 +253,7 @@ void main() {
|
|||||||
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true),
|
FeatureFlags: () => TestFeatureFlags(isNativeAssetsEnabled: true),
|
||||||
},
|
},
|
||||||
() async {
|
() async {
|
||||||
await createPackageConfig(androidEnvironment);
|
writePackageConfigFile(directory: androidEnvironment.projectDir, mainLibName: 'my_app');
|
||||||
await fileSystem.file('libfoo.so').create();
|
await fileSystem.file('libfoo.so').create();
|
||||||
|
|
||||||
final List<CodeAsset> codeAssets = <CodeAsset>[
|
final List<CodeAsset> codeAssets = <CodeAsset>[
|
||||||
@ -279,11 +280,3 @@ void main() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> createPackageConfig(Environment iosEnvironment) async {
|
|
||||||
final File packageConfig = iosEnvironment.projectDir
|
|
||||||
.childDirectory('.dart_tool')
|
|
||||||
.childFile('package_config.json');
|
|
||||||
await packageConfig.parent.create();
|
|
||||||
await packageConfig.create();
|
|
||||||
}
|
|
||||||
|
@ -21,6 +21,7 @@ import 'package:package_config/package_config_types.dart';
|
|||||||
import '../../../src/common.dart';
|
import '../../../src/common.dart';
|
||||||
import '../../../src/context.dart';
|
import '../../../src/context.dart';
|
||||||
import '../../../src/fakes.dart';
|
import '../../../src/fakes.dart';
|
||||||
|
import '../../../src/package_config.dart';
|
||||||
import '../fake_native_assets_build_runner.dart';
|
import '../fake_native_assets_build_runner.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -103,12 +104,10 @@ void main() {
|
|||||||
await fileSystem.file('/some/path/to/llvm-ar').create();
|
await fileSystem.file('/some/path/to/llvm-ar').create();
|
||||||
await fileSystem.file('/some/path/to/ld.lld').create();
|
await fileSystem.file('/some/path/to/ld.lld').create();
|
||||||
|
|
||||||
final File packageConfigFile = fileSystem
|
final File packageConfigFile = writePackageConfigFile(
|
||||||
.directory(projectUri)
|
directory: fileSystem.directory(projectUri),
|
||||||
.childDirectory('.dart_tool')
|
mainLibName: 'my_app',
|
||||||
.childFile('package_config.json');
|
);
|
||||||
await packageConfigFile.parent.create();
|
|
||||||
await packageConfigFile.create();
|
|
||||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||||
packageConfigFile,
|
packageConfigFile,
|
||||||
logger: environment.logger,
|
logger: environment.logger,
|
||||||
|
@ -21,6 +21,7 @@ import 'package:package_config/package_config_types.dart';
|
|||||||
import '../../../src/common.dart';
|
import '../../../src/common.dart';
|
||||||
import '../../../src/context.dart';
|
import '../../../src/context.dart';
|
||||||
import '../../../src/fakes.dart';
|
import '../../../src/fakes.dart';
|
||||||
|
import '../../../src/package_config.dart';
|
||||||
import '../fake_native_assets_build_runner.dart';
|
import '../fake_native_assets_build_runner.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -388,12 +389,10 @@ InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final File packageConfigFile = fileSystem
|
final File packageConfigFile = writePackageConfigFile(
|
||||||
.directory(projectUri)
|
directory: fileSystem.directory(projectUri),
|
||||||
.childDirectory('.dart_tool')
|
mainLibName: 'my_app',
|
||||||
.childFile('package_config.json');
|
);
|
||||||
await packageConfigFile.parent.create();
|
|
||||||
await packageConfigFile.create();
|
|
||||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||||
packageConfigFile,
|
packageConfigFile,
|
||||||
logger: environment.logger,
|
logger: environment.logger,
|
||||||
|
@ -22,6 +22,7 @@ import 'package:package_config/package_config_types.dart';
|
|||||||
import '../../../src/common.dart';
|
import '../../../src/common.dart';
|
||||||
import '../../../src/context.dart';
|
import '../../../src/context.dart';
|
||||||
import '../../../src/fakes.dart';
|
import '../../../src/fakes.dart';
|
||||||
|
import '../../../src/package_config.dart';
|
||||||
import '../fake_native_assets_build_runner.dart';
|
import '../fake_native_assets_build_runner.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -76,13 +77,9 @@ void main() {
|
|||||||
ProcessManager: () => FakeProcessManager.empty(),
|
ProcessManager: () => FakeProcessManager.empty(),
|
||||||
},
|
},
|
||||||
() async {
|
() async {
|
||||||
final File packageConfig = environment.projectDir
|
writePackageConfigFile(directory: environment.projectDir, mainLibName: 'my_app');
|
||||||
.childDirectory('.dart_tool')
|
|
||||||
.childFile('package_config.json');
|
|
||||||
final Uri nonFlutterTesterAssetUri =
|
final Uri nonFlutterTesterAssetUri =
|
||||||
environment.buildDir.childFile(InstallCodeAssets.nativeAssetsFilename).uri;
|
environment.buildDir.childFile(InstallCodeAssets.nativeAssetsFilename).uri;
|
||||||
await packageConfig.parent.create();
|
|
||||||
await packageConfig.create();
|
|
||||||
final File dylibAfterCompiling = fileSystem.file('bar.dll');
|
final File dylibAfterCompiling = fileSystem.file('bar.dll');
|
||||||
// The mock doesn't create the file, so create it here.
|
// The mock doesn't create the file, so create it here.
|
||||||
await dylibAfterCompiling.create();
|
await dylibAfterCompiling.create();
|
||||||
@ -255,12 +252,10 @@ void main() {
|
|||||||
);
|
);
|
||||||
await msvcBinDir.create(recursive: true);
|
await msvcBinDir.create(recursive: true);
|
||||||
|
|
||||||
final File packageConfigFile = fileSystem
|
final File packageConfigFile = writePackageConfigFile(
|
||||||
.directory(projectUri)
|
directory: fileSystem.directory(projectUri),
|
||||||
.childDirectory('.dart_tool')
|
mainLibName: 'my_app',
|
||||||
.childFile('package_config.json');
|
);
|
||||||
await packageConfigFile.parent.create();
|
|
||||||
await packageConfigFile.create();
|
|
||||||
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
final PackageConfig packageConfig = await loadPackageConfigWithLogging(
|
||||||
packageConfigFile,
|
packageConfigFile,
|
||||||
logger: environment.logger,
|
logger: environment.logger,
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:file/memory.dart';
|
import 'package:file/memory.dart';
|
||||||
import 'package:file_testing/file_testing.dart';
|
import 'package:file_testing/file_testing.dart';
|
||||||
@ -19,6 +17,7 @@ import 'package:test/fake.dart';
|
|||||||
import '../../src/common.dart';
|
import '../../src/common.dart';
|
||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
import '../../src/fake_pub_deps.dart';
|
import '../../src/fake_pub_deps.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('processPodsIfNeeded', () {
|
group('processPodsIfNeeded', () {
|
||||||
@ -27,7 +26,11 @@ void main() {
|
|||||||
late BufferLogger logger;
|
late BufferLogger logger;
|
||||||
|
|
||||||
// Adds basic properties to the flutterProject and its subprojects.
|
// Adds basic properties to the flutterProject and its subprojects.
|
||||||
void setUpProject(FakeFlutterProject flutterProject, MemoryFileSystem fileSystem) {
|
void setUpProject(
|
||||||
|
FakeFlutterProject flutterProject,
|
||||||
|
MemoryFileSystem fileSystem, {
|
||||||
|
List<String> pluginNames = const <String>[],
|
||||||
|
}) {
|
||||||
flutterProject
|
flutterProject
|
||||||
..manifest = FakeFlutterManifest()
|
..manifest = FakeFlutterManifest()
|
||||||
..directory = fileSystem.systemTempDirectory.childDirectory('app')
|
..directory = fileSystem.systemTempDirectory.childDirectory('app')
|
||||||
@ -40,28 +43,11 @@ void main() {
|
|||||||
..android = FakeAndroidProject()
|
..android = FakeAndroidProject()
|
||||||
..web = FakeWebProject()
|
..web = FakeWebProject()
|
||||||
..windows = FakeWindowsProject()
|
..windows = FakeWindowsProject()
|
||||||
..linux = FakeLinuxProject();
|
..linux = FakeLinuxProject()
|
||||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json')
|
..packageConfig = flutterProject.directory
|
||||||
..createSync(recursive: true)
|
.childDirectory('.dart_tool')
|
||||||
..writeAsStringSync('''
|
.childFile('package_config.json');
|
||||||
{
|
|
||||||
"packages": [],
|
|
||||||
"configVersion": 2
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
}
|
|
||||||
|
|
||||||
setUp(() async {
|
|
||||||
fs = MemoryFileSystem.test();
|
|
||||||
cocoaPods = FakeCocoaPods();
|
|
||||||
logger = BufferLogger.test();
|
|
||||||
});
|
|
||||||
|
|
||||||
void createFakePlugins(
|
|
||||||
FlutterProject flutterProject,
|
|
||||||
FileSystem fileSystem,
|
|
||||||
List<String> pluginNames,
|
|
||||||
) {
|
|
||||||
const String pluginYamlTemplate = '''
|
const String pluginYamlTemplate = '''
|
||||||
flutter:
|
flutter:
|
||||||
plugin:
|
plugin:
|
||||||
@ -73,36 +59,38 @@ void main() {
|
|||||||
''';
|
''';
|
||||||
|
|
||||||
final Directory fakePubCache = fileSystem.systemTempDirectory.childDirectory('cache');
|
final Directory fakePubCache = fileSystem.systemTempDirectory.childDirectory('cache');
|
||||||
final File packageConfigFile = flutterProject.directory
|
|
||||||
.childDirectory('.dart_tool')
|
writePackageConfigFile(
|
||||||
.childFile('package_config.json')..createSync(recursive: true);
|
directory: flutterProject.directory,
|
||||||
final Map<String, Object?> packageConfig = <String, Object?>{
|
mainLibName: 'my_app',
|
||||||
'packages': <Object?>[],
|
packages: <String, String>{
|
||||||
'configVersion': 2,
|
for (final String plugin in pluginNames)
|
||||||
};
|
plugin: fakePubCache.childDirectory(plugin).uri.toString(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
for (final String name in pluginNames) {
|
for (final String name in pluginNames) {
|
||||||
|
flutterProject.manifest.dependencies.add(name);
|
||||||
final Directory pluginDirectory = fakePubCache.childDirectory(name);
|
final Directory pluginDirectory = fakePubCache.childDirectory(name);
|
||||||
(packageConfig['packages']! as List<Object?>).add(<String, Object?>{
|
|
||||||
'name': name,
|
|
||||||
'rootUri': pluginDirectory.uri.toString(),
|
|
||||||
'packageUri': 'lib/',
|
|
||||||
});
|
|
||||||
pluginDirectory.childFile('pubspec.yaml')
|
pluginDirectory.childFile('pubspec.yaml')
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync(pluginYamlTemplate.replaceAll('PLUGIN_CLASS', name));
|
..writeAsStringSync(pluginYamlTemplate.replaceAll('PLUGIN_CLASS', name));
|
||||||
}
|
}
|
||||||
|
|
||||||
packageConfigFile.writeAsStringSync(jsonEncode(packageConfig));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setUp(() async {
|
||||||
|
fs = MemoryFileSystem.test();
|
||||||
|
cocoaPods = FakeCocoaPods();
|
||||||
|
logger = BufferLogger.test();
|
||||||
|
});
|
||||||
|
|
||||||
group('for iOS', () {
|
group('for iOS', () {
|
||||||
group('using CocoaPods only', () {
|
group('using CocoaPods only', () {
|
||||||
testUsingContext(
|
testUsingContext(
|
||||||
'processes when there are plugins',
|
'processes when there are plugins',
|
||||||
() async {
|
() async {
|
||||||
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
||||||
setUpProject(flutterProject, fs);
|
setUpProject(flutterProject, fs, pluginNames: <String>['plugin_one', 'plugin_two']);
|
||||||
createFakePlugins(flutterProject, fs, <String>['plugin_one', 'plugin_two']);
|
|
||||||
|
|
||||||
await processPodsIfNeeded(
|
await processPodsIfNeeded(
|
||||||
flutterProject.ios,
|
flutterProject.ios,
|
||||||
@ -191,8 +179,7 @@ void main() {
|
|||||||
'processes if podfile exists',
|
'processes if podfile exists',
|
||||||
() async {
|
() async {
|
||||||
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
||||||
setUpProject(flutterProject, fs);
|
setUpProject(flutterProject, fs, pluginNames: <String>['plugin_one', 'plugin_two']);
|
||||||
createFakePlugins(flutterProject, fs, <String>['plugin_one', 'plugin_two']);
|
|
||||||
flutterProject.ios.usesSwiftPackageManager = true;
|
flutterProject.ios.usesSwiftPackageManager = true;
|
||||||
flutterProject.ios.podfile.createSync(recursive: true);
|
flutterProject.ios.podfile.createSync(recursive: true);
|
||||||
|
|
||||||
@ -215,8 +202,7 @@ void main() {
|
|||||||
'skip if podfile does not exists',
|
'skip if podfile does not exists',
|
||||||
() async {
|
() async {
|
||||||
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
||||||
setUpProject(flutterProject, fs);
|
setUpProject(flutterProject, fs, pluginNames: <String>['plugin_one', 'plugin_two']);
|
||||||
createFakePlugins(flutterProject, fs, <String>['plugin_one', 'plugin_two']);
|
|
||||||
flutterProject.ios.usesSwiftPackageManager = true;
|
flutterProject.ios.usesSwiftPackageManager = true;
|
||||||
|
|
||||||
await processPodsIfNeeded(
|
await processPodsIfNeeded(
|
||||||
@ -237,8 +223,7 @@ void main() {
|
|||||||
'process if podfile does not exists but forceCocoaPodsOnly is true',
|
'process if podfile does not exists but forceCocoaPodsOnly is true',
|
||||||
() async {
|
() async {
|
||||||
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
||||||
setUpProject(flutterProject, fs);
|
setUpProject(flutterProject, fs, pluginNames: <String>['plugin_one', 'plugin_two']);
|
||||||
createFakePlugins(flutterProject, fs, <String>['plugin_one', 'plugin_two']);
|
|
||||||
flutterProject.ios.usesSwiftPackageManager = true;
|
flutterProject.ios.usesSwiftPackageManager = true;
|
||||||
final File generatedManifestFile = flutterProject.ios.flutterPluginSwiftPackageManifest;
|
final File generatedManifestFile = flutterProject.ios.flutterPluginSwiftPackageManifest;
|
||||||
generatedManifestFile.createSync(recursive: true);
|
generatedManifestFile.createSync(recursive: true);
|
||||||
@ -277,8 +262,7 @@ void main() {
|
|||||||
'processes when there are plugins',
|
'processes when there are plugins',
|
||||||
() async {
|
() async {
|
||||||
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
||||||
setUpProject(flutterProject, fs);
|
setUpProject(flutterProject, fs, pluginNames: <String>['plugin_one', 'plugin_two']);
|
||||||
createFakePlugins(flutterProject, fs, <String>['plugin_one', 'plugin_two']);
|
|
||||||
|
|
||||||
await processPodsIfNeeded(
|
await processPodsIfNeeded(
|
||||||
flutterProject.macos,
|
flutterProject.macos,
|
||||||
@ -367,8 +351,7 @@ void main() {
|
|||||||
'processes if podfile exists',
|
'processes if podfile exists',
|
||||||
() async {
|
() async {
|
||||||
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
||||||
setUpProject(flutterProject, fs);
|
setUpProject(flutterProject, fs, pluginNames: <String>['plugin_one', 'plugin_two']);
|
||||||
createFakePlugins(flutterProject, fs, <String>['plugin_one', 'plugin_two']);
|
|
||||||
flutterProject.macos.usesSwiftPackageManager = true;
|
flutterProject.macos.usesSwiftPackageManager = true;
|
||||||
flutterProject.macos.podfile.createSync(recursive: true);
|
flutterProject.macos.podfile.createSync(recursive: true);
|
||||||
|
|
||||||
@ -391,8 +374,7 @@ void main() {
|
|||||||
'skip if podfile does not exists',
|
'skip if podfile does not exists',
|
||||||
() async {
|
() async {
|
||||||
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
||||||
setUpProject(flutterProject, fs);
|
setUpProject(flutterProject, fs, pluginNames: <String>['plugin_one', 'plugin_two']);
|
||||||
createFakePlugins(flutterProject, fs, <String>['plugin_one', 'plugin_two']);
|
|
||||||
flutterProject.macos.usesSwiftPackageManager = true;
|
flutterProject.macos.usesSwiftPackageManager = true;
|
||||||
|
|
||||||
await processPodsIfNeeded(
|
await processPodsIfNeeded(
|
||||||
@ -413,8 +395,7 @@ void main() {
|
|||||||
'process if podfile does not exists but forceCocoaPodsOnly is true',
|
'process if podfile does not exists but forceCocoaPodsOnly is true',
|
||||||
() async {
|
() async {
|
||||||
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
final FakeFlutterProject flutterProject = FakeFlutterProject();
|
||||||
setUpProject(flutterProject, fs);
|
setUpProject(flutterProject, fs, pluginNames: <String>['plugin_one', 'plugin_two']);
|
||||||
createFakePlugins(flutterProject, fs, <String>['plugin_one', 'plugin_two']);
|
|
||||||
flutterProject.macos.usesSwiftPackageManager = true;
|
flutterProject.macos.usesSwiftPackageManager = true;
|
||||||
final File generatedManifestFile =
|
final File generatedManifestFile =
|
||||||
flutterProject.macos.flutterPluginSwiftPackageManifest;
|
flutterProject.macos.flutterPluginSwiftPackageManifest;
|
||||||
@ -489,6 +470,9 @@ class FakeFlutterProject extends Fake implements FlutterProject {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
late WindowsProject windows;
|
late WindowsProject windows;
|
||||||
|
|
||||||
|
@override
|
||||||
|
late File packageConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeMacOSProject extends Fake implements MacOSProject {
|
class FakeMacOSProject extends Fake implements MacOSProject {
|
||||||
|
@ -23,6 +23,7 @@ import '../../src/context.dart';
|
|||||||
import '../../src/fake_process_manager.dart';
|
import '../../src/fake_process_manager.dart';
|
||||||
import '../../src/fake_pub_deps.dart';
|
import '../../src/fake_pub_deps.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
|
|
||||||
enum _StdioStream { stdout, stderr }
|
enum _StdioStream { stdout, stderr }
|
||||||
|
|
||||||
@ -58,10 +59,19 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FlutterProject setupProjectUnderTest() {
|
FlutterProject setupProjectUnderTest() {
|
||||||
|
fileSystem.directory('project').childFile('pubspec.yaml')
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('''
|
||||||
|
name: my_app
|
||||||
|
environement:
|
||||||
|
sdk: '^3.5.0'
|
||||||
|
''');
|
||||||
|
|
||||||
// This needs to be run within testWithoutContext and not setUp since FlutterProject uses context.
|
// This needs to be run within testWithoutContext and not setUp since FlutterProject uses context.
|
||||||
final FlutterProject projectUnderTest = FlutterProject.fromDirectory(
|
final FlutterProject projectUnderTest = FlutterProject.fromDirectory(
|
||||||
fileSystem.directory('project'),
|
fileSystem.directory('project'),
|
||||||
);
|
);
|
||||||
|
writePackageConfigFile(directory: projectUnderTest.directory, mainLibName: 'my_app');
|
||||||
projectUnderTest.ios.xcodeProject.createSync(recursive: true);
|
projectUnderTest.ios.xcodeProject.createSync(recursive: true);
|
||||||
projectUnderTest.macos.xcodeProject.createSync(recursive: true);
|
projectUnderTest.macos.xcodeProject.createSync(recursive: true);
|
||||||
return projectUnderTest;
|
return projectUnderTest;
|
||||||
@ -389,11 +399,6 @@ void main() {
|
|||||||
'includes Pod config in xcconfig files, if the user manually added Pod dependencies without using Flutter plugins',
|
'includes Pod config in xcconfig files, if the user manually added Pod dependencies without using Flutter plugins',
|
||||||
() async {
|
() async {
|
||||||
final FlutterProject projectUnderTest = setupProjectUnderTest();
|
final FlutterProject projectUnderTest = setupProjectUnderTest();
|
||||||
final File packageConfigFile = fileSystem.file(
|
|
||||||
fileSystem.path.join('project', '.dart_tool', 'package_config.json'),
|
|
||||||
);
|
|
||||||
packageConfigFile.createSync(recursive: true);
|
|
||||||
packageConfigFile.writeAsStringSync('{"configVersion":2,"packages":[]}');
|
|
||||||
projectUnderTest.ios.podfile
|
projectUnderTest.ios.podfile
|
||||||
..createSync()
|
..createSync()
|
||||||
..writeAsStringSync('Custom Podfile');
|
..writeAsStringSync('Custom Podfile');
|
||||||
|
@ -33,6 +33,7 @@ import '../src/common.dart';
|
|||||||
import '../src/context.dart';
|
import '../src/context.dart';
|
||||||
import '../src/fake_pub_deps.dart';
|
import '../src/fake_pub_deps.dart';
|
||||||
import '../src/fakes.dart' hide FakeOperatingSystemUtils;
|
import '../src/fakes.dart' hide FakeOperatingSystemUtils;
|
||||||
|
import '../src/package_config.dart';
|
||||||
import '../src/pubspec_schema.dart';
|
import '../src/pubspec_schema.dart';
|
||||||
|
|
||||||
/// Information for a platform entry in the 'platforms' section of a plugin's
|
/// Information for a platform entry in the 'platforms' section of a plugin's
|
||||||
@ -197,14 +198,7 @@ void main() {
|
|||||||
|
|
||||||
// Add basic properties to the Flutter project and subprojects
|
// Add basic properties to the Flutter project and subprojects
|
||||||
setUpProject(fs);
|
setUpProject(fs);
|
||||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: flutterProject.directory, mainLibName: 'my_app');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('''
|
|
||||||
{
|
|
||||||
"packages": [],
|
|
||||||
"configVersion": 2
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
void addToPackageConfig(String name, Directory packageDir) {
|
void addToPackageConfig(String name, Directory packageDir) {
|
||||||
@ -254,14 +248,7 @@ void main() {
|
|||||||
|
|
||||||
final List<Directory> directories = <Directory>[];
|
final List<Directory> directories = <Directory>[];
|
||||||
final Directory fakePubCache = fileSystem.systemTempDirectory.childDirectory('cache');
|
final Directory fakePubCache = fileSystem.systemTempDirectory.childDirectory('cache');
|
||||||
flutterProject.directory.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: flutterProject.directory, mainLibName: 'my_app');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('''
|
|
||||||
{
|
|
||||||
"packages": [],
|
|
||||||
"configVersion": 2
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
for (final String nameOrPath in pluginNamesOrPaths) {
|
for (final String nameOrPath in pluginNamesOrPaths) {
|
||||||
final String name = fileSystem.path.basename(nameOrPath);
|
final String name = fileSystem.path.basename(nameOrPath);
|
||||||
final Directory pluginDirectory =
|
final Directory pluginDirectory =
|
||||||
@ -1317,7 +1304,7 @@ flutter:
|
|||||||
|
|
||||||
final FlutterManifest manifest =
|
final FlutterManifest manifest =
|
||||||
FlutterManifest.createFromString('''
|
FlutterManifest.createFromString('''
|
||||||
name: test
|
name: my_app
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -1590,7 +1577,7 @@ flutter:
|
|||||||
|
|
||||||
final FlutterManifest manifest =
|
final FlutterManifest manifest =
|
||||||
FlutterManifest.createFromString('''
|
FlutterManifest.createFromString('''
|
||||||
name: test
|
name: my_app
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -1663,7 +1650,7 @@ flutter:
|
|||||||
|
|
||||||
final FlutterManifest manifest =
|
final FlutterManifest manifest =
|
||||||
FlutterManifest.createFromString('''
|
FlutterManifest.createFromString('''
|
||||||
name: test
|
name: my_app
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -2445,10 +2432,7 @@ flutter:
|
|||||||
..flutterPluginsDependenciesFile = dependenciesFile
|
..flutterPluginsDependenciesFile = dependenciesFile
|
||||||
..windows = windowsProject;
|
..windows = windowsProject;
|
||||||
|
|
||||||
flutterProject.directory
|
writePackageConfigFile(directory: flutterProject.directory, mainLibName: 'my_app');
|
||||||
.childDirectory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
|
|
||||||
const String dependenciesFileContents = r'''
|
const String dependenciesFileContents = r'''
|
||||||
{
|
{
|
||||||
@ -2817,10 +2801,7 @@ flutter:
|
|||||||
)
|
)
|
||||||
..windows = windowsProject;
|
..windows = windowsProject;
|
||||||
|
|
||||||
flutterProject.directory
|
writePackageConfigFile(directory: flutterProject.directory, mainLibName: 'my_app');
|
||||||
.childDirectory('.dart_tool')
|
|
||||||
.childFile('package_config.json')
|
|
||||||
.createSync(recursive: true);
|
|
||||||
|
|
||||||
createPluginSymlinks(
|
createPluginSymlinks(
|
||||||
flutterProject,
|
flutterProject,
|
||||||
|
@ -29,6 +29,7 @@ import '../src/common.dart';
|
|||||||
import '../src/context.dart';
|
import '../src/context.dart';
|
||||||
import '../src/fake_pub_deps.dart';
|
import '../src/fake_pub_deps.dart';
|
||||||
import '../src/fakes.dart';
|
import '../src/fakes.dart';
|
||||||
|
import '../src/package_config.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// TODO(matanlurey): Remove after `explicit-package-dependencies` is enabled by default.
|
// TODO(matanlurey): Remove after `explicit-package-dependencies` is enabled by default.
|
||||||
@ -1825,9 +1826,7 @@ Future<FlutterProject> someProject({
|
|||||||
bool includePubspec = false,
|
bool includePubspec = false,
|
||||||
}) async {
|
}) async {
|
||||||
final Directory directory = globals.fs.directory('some_project');
|
final Directory directory = globals.fs.directory('some_project');
|
||||||
directory.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(directory: globals.fs.currentDirectory, mainLibName: 'hello');
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
|
||||||
if (includePubspec) {
|
if (includePubspec) {
|
||||||
directory.childFile('pubspec.yaml')
|
directory.childFile('pubspec.yaml')
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
@ -1926,9 +1925,7 @@ class MyPlugin extends FluttPlugin { /* ... */ }
|
|||||||
|
|
||||||
Future<FlutterProject> aModuleProject() async {
|
Future<FlutterProject> aModuleProject() async {
|
||||||
final Directory directory = globals.fs.directory('module_project');
|
final Directory directory = globals.fs.directory('module_project');
|
||||||
directory.childDirectory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(mainLibName: 'my_module', directory: directory);
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
|
||||||
directory.childFile('pubspec.yaml').writeAsStringSync('''
|
directory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
name: my_module
|
name: my_module
|
||||||
flutter:
|
flutter:
|
||||||
@ -1952,9 +1949,6 @@ void _testInMemory(
|
|||||||
}) {
|
}) {
|
||||||
Cache.flutterRoot = getFlutterRoot();
|
Cache.flutterRoot = getFlutterRoot();
|
||||||
final FileSystem testFileSystem = fileSystem ?? getFileSystemForPlatform();
|
final FileSystem testFileSystem = fileSystem ?? getFileSystemForPlatform();
|
||||||
testFileSystem.directory('.dart_tool').childFile('package_config.json')
|
|
||||||
..createSync(recursive: true)
|
|
||||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
|
||||||
// Transfer needed parts of the Flutter installation folder
|
// Transfer needed parts of the Flutter installation folder
|
||||||
// to the in-memory file system used during testing.
|
// to the in-memory file system used during testing.
|
||||||
final Logger logger = BufferLogger.test();
|
final Logger logger = BufferLogger.test();
|
||||||
@ -1982,27 +1976,17 @@ void _testInMemory(
|
|||||||
testFileSystem,
|
testFileSystem,
|
||||||
);
|
);
|
||||||
// Set up enough of the packages to satisfy the templating code.
|
// Set up enough of the packages to satisfy the templating code.
|
||||||
final File packagesFile = testFileSystem
|
|
||||||
.directory(Cache.flutterRoot)
|
|
||||||
.childDirectory('packages')
|
|
||||||
.childDirectory('flutter_tools')
|
|
||||||
.childDirectory('.dart_tool')
|
|
||||||
.childFile('package_config.json');
|
|
||||||
final Directory dummyTemplateImagesDirectory = testFileSystem.directory(Cache.flutterRoot).parent;
|
final Directory dummyTemplateImagesDirectory = testFileSystem.directory(Cache.flutterRoot).parent;
|
||||||
dummyTemplateImagesDirectory.createSync(recursive: true);
|
dummyTemplateImagesDirectory.createSync(recursive: true);
|
||||||
packagesFile.createSync(recursive: true);
|
writePackageConfigFile(
|
||||||
packagesFile.writeAsStringSync(
|
directory: testFileSystem
|
||||||
json.encode(<String, Object>{
|
.directory(Cache.flutterRoot)
|
||||||
'configVersion': 2,
|
.childDirectory('packages')
|
||||||
'packages': <Object>[
|
.childDirectory('flutter_tools'),
|
||||||
<String, Object>{
|
mainLibName: 'my_app',
|
||||||
'name': 'flutter_template_images',
|
packages: <String, String>{
|
||||||
'rootUri': dummyTemplateImagesDirectory.uri.toString(),
|
'flutter_template_images': dummyTemplateImagesDirectory.uri.toString(),
|
||||||
'packageUri': 'lib/',
|
},
|
||||||
'languageVersion': '2.6',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
testUsingContext(
|
testUsingContext(
|
||||||
|
@ -36,6 +36,7 @@ import '../src/context.dart';
|
|||||||
import '../src/fake_pub_deps.dart';
|
import '../src/fake_pub_deps.dart';
|
||||||
import '../src/fake_vm_services.dart';
|
import '../src/fake_vm_services.dart';
|
||||||
import '../src/fakes.dart';
|
import '../src/fakes.dart';
|
||||||
|
import '../src/package_config.dart';
|
||||||
import '../src/testbed.dart';
|
import '../src/testbed.dart';
|
||||||
import 'resident_runner_helpers.dart';
|
import 'resident_runner_helpers.dart';
|
||||||
|
|
||||||
@ -1087,26 +1088,18 @@ void main() {
|
|||||||
}
|
}
|
||||||
}''');
|
}''');
|
||||||
globals.fs.file('l10n.yaml').createSync();
|
globals.fs.file('l10n.yaml').createSync();
|
||||||
globals.fs.file('pubspec.yaml').writeAsStringSync('flutter:\n generate: true\n');
|
globals.fs.file('pubspec.yaml').writeAsStringSync('''
|
||||||
|
name: my_app
|
||||||
|
flutter:
|
||||||
|
generate: true''');
|
||||||
|
|
||||||
// Create necessary files for [DartPluginRegistrantTarget]
|
// Create necessary files for [DartPluginRegistrantTarget]
|
||||||
final File packageConfig = globals.fs
|
writePackageConfigFile(
|
||||||
.directory('.dart_tool')
|
directory: globals.fs.currentDirectory,
|
||||||
.childFile('package_config.json');
|
mainLibName: 'my_app',
|
||||||
packageConfig.createSync(recursive: true);
|
packages: <String, String>{'path_provider_linux': 'path_provider_linux'},
|
||||||
packageConfig.writeAsStringSync('''
|
);
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "path_provider_linux",
|
|
||||||
"rootUri": "../../../path_provider_linux",
|
|
||||||
"packageUri": "lib/",
|
|
||||||
"languageVersion": "2.12"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
// Start from an empty dart_plugin_registrant.dart file.
|
// Start from an empty dart_plugin_registrant.dart file.
|
||||||
globals.fs
|
globals.fs
|
||||||
.directory('.dart_tool')
|
.directory('.dart_tool')
|
||||||
@ -1141,6 +1134,7 @@ void main() {
|
|||||||
}''');
|
}''');
|
||||||
globals.fs.file('l10n.yaml').createSync();
|
globals.fs.file('l10n.yaml').createSync();
|
||||||
globals.fs.file('pubspec.yaml').writeAsStringSync('''
|
globals.fs.file('pubspec.yaml').writeAsStringSync('''
|
||||||
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
generate: true
|
generate: true
|
||||||
|
|
||||||
@ -1152,23 +1146,12 @@ dependencies:
|
|||||||
|
|
||||||
// Create necessary files for [DartPluginRegistrantTarget], including a
|
// Create necessary files for [DartPluginRegistrantTarget], including a
|
||||||
// plugin that will trigger generation.
|
// plugin that will trigger generation.
|
||||||
final File packageConfig = globals.fs
|
writePackageConfigFile(
|
||||||
.directory('.dart_tool')
|
directory: globals.fs.currentDirectory,
|
||||||
.childFile('package_config.json');
|
mainLibName: 'my_app',
|
||||||
packageConfig.createSync(recursive: true);
|
packages: <String, String>{'path_provider_linux': 'path_provider_linux'},
|
||||||
packageConfig.writeAsStringSync('''
|
);
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "path_provider_linux",
|
|
||||||
"rootUri": "../path_provider_linux",
|
|
||||||
"packageUri": "lib/",
|
|
||||||
"languageVersion": "2.12"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
final Directory fakePluginDir = globals.fs.directory('path_provider_linux');
|
final Directory fakePluginDir = globals.fs.directory('path_provider_linux');
|
||||||
final File pluginPubspec = fakePluginDir.childFile('pubspec.yaml');
|
final File pluginPubspec = fakePluginDir.childFile('pubspec.yaml');
|
||||||
pluginPubspec.createSync(recursive: true);
|
pluginPubspec.createSync(recursive: true);
|
||||||
|
@ -28,6 +28,7 @@ import '../src/common.dart';
|
|||||||
import '../src/context.dart';
|
import '../src/context.dart';
|
||||||
import '../src/fake_pub_deps.dart';
|
import '../src/fake_pub_deps.dart';
|
||||||
import '../src/fakes.dart';
|
import '../src/fakes.dart';
|
||||||
|
import '../src/package_config.dart';
|
||||||
import '../src/test_build_system.dart';
|
import '../src/test_build_system.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -48,8 +49,11 @@ void main() {
|
|||||||
mockFlutterDevice = FakeFlutterDevice(mockWebDevice);
|
mockFlutterDevice = FakeFlutterDevice(mockWebDevice);
|
||||||
mockFlutterDevice._devFS = mockWebDevFS;
|
mockFlutterDevice._devFS = mockWebDevFS;
|
||||||
|
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
fileSystem.file('pubspec.yaml').writeAsStringSync('''
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
name: my_app
|
||||||
|
''');
|
||||||
|
|
||||||
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).createSync(recursive: true);
|
||||||
fileSystem.file(fileSystem.path.join('web', 'index.html')).createSync(recursive: true);
|
fileSystem.file(fileSystem.path.join('web', 'index.html')).createSync(recursive: true);
|
||||||
});
|
});
|
||||||
|
@ -45,6 +45,7 @@ import '../src/fake_process_manager.dart';
|
|||||||
import '../src/fake_pub_deps.dart';
|
import '../src/fake_pub_deps.dart';
|
||||||
import '../src/fake_vm_services.dart';
|
import '../src/fake_vm_services.dart';
|
||||||
import '../src/fakes.dart' as test_fakes;
|
import '../src/fakes.dart' as test_fakes;
|
||||||
|
import '../src/package_config.dart';
|
||||||
|
|
||||||
const List<VmServiceExpectation> kAttachLogExpectations = <VmServiceExpectation>[
|
const List<VmServiceExpectation> kAttachLogExpectations = <VmServiceExpectation>[
|
||||||
FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{'streamId': 'Stdout'}),
|
FakeVmServiceRequest(method: 'streamListen', args: <String, Object>{'streamId': 'Stdout'}),
|
||||||
@ -113,7 +114,10 @@ void main() {
|
|||||||
.._devFS = webDevFS
|
.._devFS = webDevFS
|
||||||
..device = mockDevice
|
..device = mockDevice
|
||||||
..generator = residentCompiler;
|
..generator = residentCompiler;
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
fileSystem.file('pubspec.yaml').writeAsStringSync('''
|
||||||
|
name: my_app
|
||||||
|
''');
|
||||||
|
writePackageConfigFile(directory: fileSystem.currentDirectory, mainLibName: 'my_app');
|
||||||
fakeAnalytics = getInitializedFakeAnalyticsInstance(
|
fakeAnalytics = getInitializedFakeAnalyticsInstance(
|
||||||
fs: fileSystem,
|
fs: fileSystem,
|
||||||
fakeFlutterVersion: test_fakes.FakeFlutterVersion(),
|
fakeFlutterVersion: test_fakes.FakeFlutterVersion(),
|
||||||
@ -1381,24 +1385,15 @@ void main() {
|
|||||||
}''');
|
}''');
|
||||||
globals.fs.file('l10n.yaml').createSync();
|
globals.fs.file('l10n.yaml').createSync();
|
||||||
globals.fs.file('pubspec.yaml').writeAsStringSync('''
|
globals.fs.file('pubspec.yaml').writeAsStringSync('''
|
||||||
|
name: my_app
|
||||||
flutter:
|
flutter:
|
||||||
generate: true
|
generate: true
|
||||||
''');
|
''');
|
||||||
globals.fs.directory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(
|
||||||
..createSync(recursive: true)
|
directory: globals.fs.currentDirectory,
|
||||||
..writeAsStringSync('''
|
mainLibName: 'my_app',
|
||||||
{
|
packages: <String, String>{'path_provider_linux': '../../path_provider_linux'},
|
||||||
"configVersion": 2,
|
);
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "path_provider_linux",
|
|
||||||
"rootUri": "../../../path_provider_linux",
|
|
||||||
"packageUri": "lib/",
|
|
||||||
"languageVersion": "2.12"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
expect(await residentWebRunner.run(), 0);
|
expect(await residentWebRunner.run(), 0);
|
||||||
final File generatedLocalizationsFile = globals.fs
|
final File generatedLocalizationsFile = globals.fs
|
||||||
.directory('lib')
|
.directory('lib')
|
||||||
@ -1422,23 +1417,12 @@ flutter:
|
|||||||
'Does not generate dart_plugin_registrant.dart',
|
'Does not generate dart_plugin_registrant.dart',
|
||||||
() async {
|
() async {
|
||||||
// Create necessary files for [DartPluginRegistrantTarget]
|
// Create necessary files for [DartPluginRegistrantTarget]
|
||||||
final File packageConfig = globals.fs
|
writePackageConfigFile(
|
||||||
.directory('.dart_tool')
|
directory: globals.fs.currentDirectory,
|
||||||
.childFile('package_config.json');
|
mainLibName: 'my_app',
|
||||||
packageConfig.createSync(recursive: true);
|
packages: <String, String>{'path_provider_linux': '../../path_provider_linux'},
|
||||||
packageConfig.writeAsStringSync('''
|
);
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "path_provider_linux",
|
|
||||||
"rootUri": "../../../path_provider_linux",
|
|
||||||
"packageUri": "lib/",
|
|
||||||
"languageVersion": "2.12"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
// Start with a dart_plugin_registrant.dart file.
|
// Start with a dart_plugin_registrant.dart file.
|
||||||
globals.fs
|
globals.fs
|
||||||
.directory('.dart_tool')
|
.directory('.dart_tool')
|
||||||
|
@ -22,6 +22,7 @@ import '../../src/context.dart';
|
|||||||
import '../../src/fake_pub_deps.dart';
|
import '../../src/fake_pub_deps.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
import '../../src/logging_logger.dart';
|
import '../../src/logging_logger.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
|
|
||||||
final Platform linuxPlatform = FakePlatform(environment: <String, String>{});
|
final Platform linuxPlatform = FakePlatform(environment: <String, String>{});
|
||||||
|
|
||||||
@ -46,9 +47,13 @@ void main() {
|
|||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
fileSystem = MemoryFileSystem.test();
|
fileSystem = MemoryFileSystem.test();
|
||||||
fileSystem.file('pubspec.yaml').createSync();
|
fileSystem.file('pubspec.yaml')
|
||||||
|
..createSync()
|
||||||
|
..writeAsStringSync('''
|
||||||
|
name: foo
|
||||||
|
''');
|
||||||
fileSystem.file('test/foo.dart').createSync(recursive: true);
|
fileSystem.file('test/foo.dart').createSync(recursive: true);
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
writePackageConfigFile(mainLibName: 'foo', directory: fileSystem.currentDirectory);
|
||||||
residentCompiler = FakeResidentCompiler(fileSystem);
|
residentCompiler = FakeResidentCompiler(fileSystem);
|
||||||
logger = LoggingLogger();
|
logger = LoggingLogger();
|
||||||
});
|
});
|
||||||
@ -216,20 +221,11 @@ dependencies:
|
|||||||
sdk: flutter
|
sdk: flutter
|
||||||
a_plugin: 1.0.0
|
a_plugin: 1.0.0
|
||||||
''');
|
''');
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json')
|
writePackageConfigFile(
|
||||||
..createSync(recursive: true)
|
directory: fileSystem.currentDirectory,
|
||||||
..writeAsStringSync('''
|
mainLibName: 'foo',
|
||||||
{
|
packages: <String, String>{'a_plugin': '/a_plugin'},
|
||||||
"configVersion": 2,
|
);
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "a_plugin",
|
|
||||||
"rootUri": "/a_plugin/",
|
|
||||||
"packageUri": "lib/"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
fakeDartPlugin.childFile('pubspec.yaml')
|
fakeDartPlugin.childFile('pubspec.yaml')
|
||||||
..createSync(recursive: true)
|
..createSync(recursive: true)
|
||||||
..writeAsStringSync('''
|
..writeAsStringSync('''
|
||||||
|
@ -19,6 +19,7 @@ import '../../src/common.dart';
|
|||||||
import '../../src/context.dart';
|
import '../../src/context.dart';
|
||||||
import '../../src/fake_pub_deps.dart';
|
import '../../src/fake_pub_deps.dart';
|
||||||
import '../../src/fakes.dart';
|
import '../../src/fakes.dart';
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../../src/test_build_system.dart';
|
import '../../src/test_build_system.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@ -48,10 +49,16 @@ void main() {
|
|||||||
fs: fileSystem,
|
fs: fileSystem,
|
||||||
fakeFlutterVersion: flutterVersion,
|
fakeFlutterVersion: flutterVersion,
|
||||||
);
|
);
|
||||||
|
fileSystem.currentDirectory.childFile('pubspec.yaml')
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync('''
|
||||||
|
name: my_app
|
||||||
|
environement:
|
||||||
|
sdk: '^3.5.0'
|
||||||
|
''');
|
||||||
|
|
||||||
flutterProject = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
flutterProject = FlutterProject.fromDirectoryTest(fileSystem.currentDirectory);
|
||||||
|
writePackageConfigFile(directory: flutterProject.directory, mainLibName: 'my_app');
|
||||||
fileSystem.directory('.dart_tool').childFile('package_config.json').createSync(recursive: true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testUsingContext(
|
testUsingContext(
|
||||||
|
@ -14,6 +14,7 @@ import 'package:flutter_tools/src/features.dart';
|
|||||||
import '../../../src/context.dart'; // legacy
|
import '../../../src/context.dart'; // legacy
|
||||||
import '../../../src/fake_pub_deps.dart';
|
import '../../../src/fake_pub_deps.dart';
|
||||||
import '../../../src/fakes.dart';
|
import '../../../src/fakes.dart';
|
||||||
|
import '../../../src/package_config.dart';
|
||||||
import '../../../src/test_build_system.dart';
|
import '../../../src/test_build_system.dart';
|
||||||
import '../../../src/test_flutter_command_runner.dart'; // legacy
|
import '../../../src/test_flutter_command_runner.dart'; // legacy
|
||||||
|
|
||||||
@ -284,4 +285,9 @@ flutter:
|
|||||||
class UrlLauncherPlugin {}
|
class UrlLauncherPlugin {}
|
||||||
''');
|
''');
|
||||||
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).writeAsStringSync('void main() { }');
|
fileSystem.file(fileSystem.path.join('lib', 'main.dart')).writeAsStringSync('void main() { }');
|
||||||
|
writePackageConfigFile(
|
||||||
|
directory: fileSystem.currentDirectory,
|
||||||
|
mainLibName: 'foo',
|
||||||
|
packages: <String, String>{'bar': 'bar'},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
|
|
||||||
|
import '../../src/package_config.dart';
|
||||||
import '../test_utils.dart';
|
import '../test_utils.dart';
|
||||||
import 'deferred_components_config.dart';
|
import 'deferred_components_config.dart';
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ abstract class Project {
|
|||||||
writeFile(fileSystem.path.join(dir.path, 'web', 'index.html'), indexHtml);
|
writeFile(fileSystem.path.join(dir.path, 'web', 'index.html'), indexHtml);
|
||||||
writeFile(fileSystem.path.join(dir.path, 'web', 'flutter.js'), '');
|
writeFile(fileSystem.path.join(dir.path, 'web', 'flutter.js'), '');
|
||||||
writeFile(fileSystem.path.join(dir.path, 'web', 'flutter_service_worker.js'), '');
|
writeFile(fileSystem.path.join(dir.path, 'web', 'flutter_service_worker.js'), '');
|
||||||
writePackageConfig(dir.path);
|
writePackageConfigFile(directory: dir, mainLibName: 'test');
|
||||||
await getPackages(dir.path);
|
await getPackages(dir.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,21 +56,6 @@ void writeBytesFile(String path, List<int> content) {
|
|||||||
..writeAsBytesSync(content, flush: true);
|
..writeAsBytesSync(content, flush: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void writePackageConfig(String folder) {
|
|
||||||
writeFile(fileSystem.path.join(folder, '.dart_tool', 'package_config.json'), '''
|
|
||||||
{
|
|
||||||
"configVersion": 2,
|
|
||||||
"packages": [
|
|
||||||
{
|
|
||||||
"name": "test",
|
|
||||||
"rootUri": "fileSystem.currentDirectory.path"
|
|
||||||
"packageUri": "lib/",
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
''');
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> getPackages(String folder) async {
|
Future<void> getPackages(String folder) async {
|
||||||
final List<String> command = <String>[
|
final List<String> command = <String>[
|
||||||
fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'),
|
fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'),
|
||||||
|
47
packages/flutter_tools/test/src/package_config.dart
Normal file
47
packages/flutter_tools/test/src/package_config.dart
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright 2014 The Flutter 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 'dart:convert';
|
||||||
|
import 'package:file/file.dart';
|
||||||
|
|
||||||
|
/// Writes a `.dart_tool/package_config.json` file at [directory].
|
||||||
|
///
|
||||||
|
/// If directory is not specified, it will be `globals.fs.currentDirectory`;
|
||||||
|
///
|
||||||
|
/// It will contain a package entry for [mainLibName] with `rootUri` at
|
||||||
|
/// [directory].
|
||||||
|
///
|
||||||
|
/// [otherLibs] maps other package names to their `rootUri` relative to `directory`.
|
||||||
|
///
|
||||||
|
/// Returns the `File` Object representing the package config.
|
||||||
|
File writePackageConfigFile({
|
||||||
|
required Directory directory,
|
||||||
|
required String mainLibName,
|
||||||
|
Map<String, String> packages = const <String, String>{},
|
||||||
|
Map<String, String> languageVersions = const <String, String>{},
|
||||||
|
}) {
|
||||||
|
return directory.childDirectory('.dart_tool').childFile('package_config.json')
|
||||||
|
..createSync(recursive: true)
|
||||||
|
..writeAsStringSync(
|
||||||
|
json.encode(<String, Object?>{
|
||||||
|
'packages': <Object>[
|
||||||
|
<String, Object?>{
|
||||||
|
'name': mainLibName,
|
||||||
|
'rootUri': '../',
|
||||||
|
'packageUri': 'lib/',
|
||||||
|
'languageVersion': languageVersions[mainLibName] ?? '3.7',
|
||||||
|
},
|
||||||
|
...packages.entries.map(
|
||||||
|
(MapEntry<String, String> entry) => <String, Object?>{
|
||||||
|
'name': entry.key,
|
||||||
|
'rootUri': Uri.parse('../').resolve(entry.value).toString(),
|
||||||
|
'packageUri': 'lib/',
|
||||||
|
'languageVersion': languageVersions[entry.key] ?? '3.7',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
'configVersion': 2,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user