parent
2ed3dab361
commit
dfdd5f80f2
@ -133,7 +133,7 @@ class KernelSnapshotProgram extends Target {
|
||||
|
||||
@override
|
||||
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.artifact(Artifact.platformKernelDill),
|
||||
Source.artifact(Artifact.engineDartBinary),
|
||||
|
@ -425,6 +425,7 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
||||
flavor: buildInfo.flavor,
|
||||
impellerStatus: debuggingOptions.enableImpeller,
|
||||
buildMode: debuggingOptions.buildInfo.mode,
|
||||
packageConfigPath: buildInfo.packageConfigPath,
|
||||
);
|
||||
testAssetDirectory = globals.fs.path.
|
||||
join(flutterProject.directory.path, 'build', 'unit_test_assets');
|
||||
@ -691,12 +692,11 @@ class TestCommand extends FlutterCommand with DeviceBasedDevelopmentArtifacts {
|
||||
required String? flavor,
|
||||
required ImpellerStatus impellerStatus,
|
||||
required BuildMode buildMode,
|
||||
required String packageConfigPath,
|
||||
}) async {
|
||||
final AssetBundle assetBundle = AssetBundleFactory.instance.createBundle();
|
||||
// TODO(sigurdm): parametrize packageConfigPath to support testing
|
||||
// workspaces.
|
||||
final int build = await assetBundle.build(
|
||||
packageConfigPath: '.dart_tool/package_config.json',
|
||||
packageConfigPath: packageConfigPath,
|
||||
flavor: flavor,
|
||||
);
|
||||
if (build != 0) {
|
||||
|
@ -138,16 +138,14 @@ class NativeAssetsBuildRunnerImpl implements NativeAssetsBuildRunner {
|
||||
|
||||
@override
|
||||
Future<bool> hasPackageConfig() {
|
||||
final File packageConfigJson =
|
||||
fileSystem.directory(projectUri.toFilePath()).childDirectory('.dart_tool').childFile('package_config.json');
|
||||
return packageConfigJson.exists();
|
||||
return fileSystem.file(packageConfigPath).exists();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Package>> packagesWithNativeAssets() async {
|
||||
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
||||
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
|
||||
// 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(
|
||||
packageConfig,
|
||||
projectUri.resolve('.dart_tool/package_config.json'),
|
||||
Uri.file(packageConfigPath),
|
||||
);
|
||||
return _buildRunner.buildDryRun(
|
||||
includeParentEnvironment: includeParentEnvironment,
|
||||
@ -192,7 +190,7 @@ class NativeAssetsBuildRunnerImpl implements NativeAssetsBuildRunner {
|
||||
}) {
|
||||
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
||||
packageConfig,
|
||||
projectUri.resolve('.dart_tool/package_config.json'),
|
||||
Uri.file(packageConfigPath),
|
||||
);
|
||||
return _buildRunner.build(
|
||||
buildMode: buildMode,
|
||||
@ -221,7 +219,7 @@ class NativeAssetsBuildRunnerImpl implements NativeAssetsBuildRunner {
|
||||
}) {
|
||||
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
||||
packageConfig,
|
||||
projectUri.resolve('.dart_tool/package_config.json'),
|
||||
Uri.file(packageConfigPath),
|
||||
);
|
||||
return _buildRunner.linkDryRun(
|
||||
includeParentEnvironment: includeParentEnvironment,
|
||||
@ -249,7 +247,7 @@ class NativeAssetsBuildRunnerImpl implements NativeAssetsBuildRunner {
|
||||
}) {
|
||||
final PackageLayout packageLayout = PackageLayout.fromPackageConfig(
|
||||
packageConfig,
|
||||
projectUri.resolve('.dart_tool/package_config.json'),
|
||||
Uri.file(packageConfigPath),
|
||||
);
|
||||
return _buildRunner.link(
|
||||
buildMode: buildMode,
|
||||
|
@ -112,10 +112,11 @@ void main() {
|
||||
(package.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
..createSync(recursive: true))
|
||||
.writeAsString(_packageConfigContents);
|
||||
.writeAsStringSync(_packageConfigContents);
|
||||
package.childDirectory('test').childFile('some_test.dart').createSync(recursive: true);
|
||||
package.childDirectory('integration_test').childFile('some_integration_test.dart').createSync(recursive: true);
|
||||
|
||||
|
||||
final File flutterToolsPackageConfigFile = fs.directory(
|
||||
fs.path.join(
|
||||
getFlutterRoot(),
|
||||
@ -1430,6 +1431,53 @@ dev_dependencies:
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user