parent
2ed3dab361
commit
dfdd5f80f2
@ -133,7 +133,7 @@ class KernelSnapshotProgram extends Target {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
List<Source> get inputs => const <Source>[
|
List<Source> get inputs => const <Source>[
|
||||||
Source.pattern('{PROJECT_DIR}/.dart_tool/package_config_subset'),
|
Source.pattern('{WORKSPACE_DIR}/.dart_tool/package_config_subset'),
|
||||||
Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/common.dart'),
|
Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/common.dart'),
|
||||||
Source.artifact(Artifact.platformKernelDill),
|
Source.artifact(Artifact.platformKernelDill),
|
||||||
Source.artifact(Artifact.engineDartBinary),
|
Source.artifact(Artifact.engineDartBinary),
|
||||||
|
@ -425,6 +425,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
|||||||
flavor: buildInfo.flavor,
|
flavor: buildInfo.flavor,
|
||||||
impellerStatus: debuggingOptions.enableImpeller,
|
impellerStatus: debuggingOptions.enableImpeller,
|
||||||
buildMode: debuggingOptions.buildInfo.mode,
|
buildMode: debuggingOptions.buildInfo.mode,
|
||||||
|
packageConfigPath: buildInfo.packageConfigPath,
|
||||||
);
|
);
|
||||||
testAssetDirectory = globals.fs.path.
|
testAssetDirectory = globals.fs.path.
|
||||||
join(flutterProject.directory.path, 'build', 'unit_test_assets');
|
join(flutterProject.directory.path, 'build', 'unit_test_assets');
|
||||||
@ -691,12 +692,11 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
|||||||
required String? flavor,
|
required String? flavor,
|
||||||
required ImpellerStatus impellerStatus,
|
required ImpellerStatus impellerStatus,
|
||||||
required BuildMode buildMode,
|
required BuildMode buildMode,
|
||||||
|
required String packageConfigPath,
|
||||||
}) async {
|
}) async {
|
||||||
final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle();
|
final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle();
|
||||||
// TODO(sigurdm): parametrize packageConfigPath to support testing
|
|
||||||
// workspaces.
|
|
||||||
final int build = await assetBundle.build(
|
final int build = await assetBundle.build(
|
||||||
packageConfigPath: '.dart_tool/package_config.json',
|
packageConfigPath: packageConfigPath,
|
||||||
flavor: flavor,
|
flavor: flavor,
|
||||||
);
|
);
|
||||||
if (build != 0) {
|
if (build != 0) {
|
||||||
|
@ -138,16 +138,14 @@ class NativeAssetsBuildRunnerImpl implements NativeAssetsBuildRunner {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> hasPackageConfig() {
|
Future<bool> hasPackageConfig() {
|
||||||
final File packageConfigJson =
|
return fileSystem.file(packageConfigPath).exists();
|
||||||
fileSystem.directory(projectUri.toFilePath()).childDirectory('.dart_tool').childFile('package_config.json');
|
|
||||||
return packageConfigJson.exists();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<Package>> packagesWithNativeAssets() async {
|
Future<List<Package>> packagesWithNativeAssets() async {
|
||||||
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
||||||
packageConfig,
|
packageConfig,
|
||||||
projectUri.resolve('.dart_tool/package_config.json'),
|
Uri.file(packageConfigPath),
|
||||||
);
|
);
|
||||||
// It suffices to only check for build hooks. If no packages have a build
|
// It suffices to only check for build hooks. If no packages have a build
|
||||||
// hook. Then no build hook will output any assets for any link hook, and
|
// hook. Then no build hook will output any assets for any link hook, and
|
||||||
@ -164,7 +162,7 @@ class NativeAssetsBuildRunnerImpl implements NativeAssetsBuildRunner {
|
|||||||
}) {
|
}) {
|
||||||
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
||||||
packageConfig,
|
packageConfig,
|
||||||
projectUri.resolve('.dart_tool/package_config.json'),
|
Uri.file(packageConfigPath),
|
||||||
);
|
);
|
||||||
return _buildRunner.buildDryRun(
|
return _buildRunner.buildDryRun(
|
||||||
includeParentEnvironment: includeParentEnvironment,
|
includeParentEnvironment: includeParentEnvironment,
|
||||||
@ -192,7 +190,7 @@ class NativeAssetsBuildRunnerImpl implements NativeAssetsBuildRunner {
|
|||||||
}) {
|
}) {
|
||||||
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
||||||
packageConfig,
|
packageConfig,
|
||||||
projectUri.resolve('.dart_tool/package_config.json'),
|
Uri.file(packageConfigPath),
|
||||||
);
|
);
|
||||||
return _buildRunner.build(
|
return _buildRunner.build(
|
||||||
buildMode: buildMode,
|
buildMode: buildMode,
|
||||||
@ -221,7 +219,7 @@ class NativeAssetsBuildRunnerImpl implements NativeAssetsBuildRunner {
|
|||||||
}) {
|
}) {
|
||||||
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
||||||
packageConfig,
|
packageConfig,
|
||||||
projectUri.resolve('.dart_tool/package_config.json'),
|
Uri.file(packageConfigPath),
|
||||||
);
|
);
|
||||||
return _buildRunner.linkDryRun(
|
return _buildRunner.linkDryRun(
|
||||||
includeParentEnvironment: includeParentEnvironment,
|
includeParentEnvironment: includeParentEnvironment,
|
||||||
@ -249,7 +247,7 @@ class NativeAssetsBuildRunnerImpl implements NativeAssetsBuildRunner {
|
|||||||
}) {
|
}) {
|
||||||
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
||||||
packageConfig,
|
packageConfig,
|
||||||
projectUri.resolve('.dart_tool/package_config.json'),
|
Uri.file(packageConfigPath),
|
||||||
);
|
);
|
||||||
return _buildRunner.link(
|
return _buildRunner.link(
|
||||||
buildMode: buildMode,
|
buildMode: buildMode,
|
||||||
|
@ -112,10 +112,11 @@ void main() {
|
|||||||
(package.childDirectory('.dart_tool')
|
(package.childDirectory('.dart_tool')
|
||||||
.childFile('package_config.json')
|
.childFile('package_config.json')
|
||||||
..createSync(recursive: true))
|
..createSync(recursive: true))
|
||||||
.writeAsString(_packageConfigContents);
|
.writeAsStringSync(_packageConfigContents);
|
||||||
package.childDirectory('test').childFile('some_test.dart').createSync(recursive: true);
|
package.childDirectory('test').childFile('some_test.dart').createSync(recursive: true);
|
||||||
package.childDirectory('integration_test').childFile('some_integration_test.dart').createSync(recursive: true);
|
package.childDirectory('integration_test').childFile('some_integration_test.dart').createSync(recursive: true);
|
||||||
|
|
||||||
|
|
||||||
final File flutterToolsPackageConfigFile = fs.directory(
|
final File flutterToolsPackageConfigFile = fs.directory(
|
||||||
fs.path.join(
|
fs.path.join(
|
||||||
getFlutterRoot(),
|
getFlutterRoot(),
|
||||||
@ -1430,6 +1431,53 @@ dev_dependencies:
|
|||||||
ProcessManager: () => FakeProcessManager.any(),
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testUsingContext('Can test in a pub workspace',
|
||||||
|
() async {
|
||||||
|
final String root = fs.path.rootPrefix(fs.currentDirectory.absolute.path);
|
||||||
|
final Directory package = fs.directory('${root}package').absolute;
|
||||||
|
package.childFile('pubspec.yaml').createSync(recursive: true);
|
||||||
|
package.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
|
workspace:
|
||||||
|
- app/
|
||||||
|
''');
|
||||||
|
|
||||||
|
final Directory app = package.childDirectory('app');
|
||||||
|
app.createSync();
|
||||||
|
app.childFile('pubspec.yaml').writeAsStringSync('''
|
||||||
|
$_pubspecContents
|
||||||
|
resolution: workspace
|
||||||
|
''');
|
||||||
|
app.childDirectory('test').childFile('some_test.dart').createSync(recursive: true);
|
||||||
|
app.childDirectory('integration_test').childFile('some_integration_test.dart').createSync(recursive: true);
|
||||||
|
|
||||||
|
fs.currentDirectory = app;
|
||||||
|
|
||||||
|
final FakeFlutterTestRunner testRunner = FakeFlutterTestRunner(0);
|
||||||
|
final FakePackageTest fakePackageTest = FakePackageTest();
|
||||||
|
final TestCommand testCommand = TestCommand(
|
||||||
|
testWrapper: fakePackageTest,
|
||||||
|
testRunner: testRunner,
|
||||||
|
);
|
||||||
|
final CommandRunner<void> commandRunner =
|
||||||
|
createTestCommandRunner(testCommand);
|
||||||
|
|
||||||
|
await commandRunner.run(const <String>[
|
||||||
|
'test',
|
||||||
|
'--no-pub',
|
||||||
|
]);
|
||||||
|
expect(
|
||||||
|
testRunner.lastDebuggingOptionsValue.buildInfo.packageConfigPath,
|
||||||
|
package
|
||||||
|
.childDirectory('.dart_tool')
|
||||||
|
.childFile('package_config.json')
|
||||||
|
.path,
|
||||||
|
);
|
||||||
|
}, overrides: <Type, Generator>{
|
||||||
|
FileSystem: () => fs,
|
||||||
|
ProcessManager: () => FakeProcessManager.any(),
|
||||||
|
Logger: () => logger,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class FakeFlutterTestRunner implements FlutterTestRunner {
|
class FakeFlutterTestRunner implements FlutterTestRunner {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user