Unverified Commit 76346090 authored by Daco Harkes's avatar Daco Harkes Committed by GitHub

Pin dart-lang/native dependencies (#137601)

Pin the dependencies from dart-lang/native to a specific version during testing (rather than having them auto-upgrade during pub resolution). This will prevent tests using the template to start failing if a bad version is published to pub.

Closes: https://github.com/flutter/flutter/issues/137418

Also bumps dep in flutter_tools.
parent 4455e86d
......@@ -736,11 +736,24 @@ Future<void> _createFfiPackage(String name, Directory parent) async {
await flutter(
'create',
options: <String>[
'--no-pub',
'--org',
'io.flutter.devicelab',
'--template=package_ffi',
name,
],
);
await _pinDependencies(
File(path.join(parent.path, name, 'pubspec.yaml')),
);
await _pinDependencies(
File(path.join(parent.path, name, 'example', 'pubspec.yaml')),
);
});
}
Future<void> _pinDependencies(File pubspecFile) async {
final String oldPubspec = await pubspecFile.readAsString();
final String newPubspec = oldPubspec.replaceAll(': ^', ': ');
await pubspecFile.writeAsString(newPubspec);
}
......@@ -165,22 +165,46 @@ Future<Directory> createTestProject(
String packageName,
Directory tempDirectory,
) async {
final int createResult = await exec(
await exec(
_flutterBin,
<String>[
'create',
'--no-pub',
'--template=package_ffi',
packageName,
],
workingDirectory: tempDirectory.path,
canFail: true,
);
assert(createResult == 0);
final Directory packageDirectory = Directory.fromUri(tempDirectory.uri.resolve('$packageName/'));
final Directory packageDirectory = Directory(
path.join(tempDirectory.path, packageName),
);
await _pinDependencies(
File(path.join(packageDirectory.path, 'pubspec.yaml')),
);
await _pinDependencies(
File(path.join(packageDirectory.path, 'example', 'pubspec.yaml')),
);
await exec(
_flutterBin,
<String>[
'pub',
'get',
],
workingDirectory: packageDirectory.path,
);
return packageDirectory;
}
Future<void> _pinDependencies(File pubspecFile) async {
final String oldPubspec = await pubspecFile.readAsString();
final String newPubspec = oldPubspec.replaceAll(': ^', ': ');
await pubspecFile.writeAsString(newPubspec);
}
Future<T> inTempDir<T>(Future<T> Function(Directory tempDirectory) fun) async {
final Directory tempDirectory = dir(Directory.systemTemp.createTempSync().resolveSymbolicLinksSync());
try {
......
......@@ -7,13 +7,13 @@ environment:
sdk: {{dartSdkVersionBounds}}
dependencies:
cli_config: ^0.1.1
logging: ^1.1.1
native_assets_cli: ^0.3.0
native_toolchain_c: ^0.3.0
cli_config: ^0.1.2
logging: ^1.2.0
native_assets_cli: ^0.3.2
native_toolchain_c: ^0.3.2
dev_dependencies:
ffi: ^2.0.2
ffigen: ^9.0.0
ffi: ^2.1.0
ffigen: ^9.0.1
flutter_lints: ^3.0.0
test: ^1.21.0
test: ^1.24.9
......@@ -18,8 +18,8 @@ dependencies:
dev_dependencies:
{{#withFfi}}
ffi: ^2.0.2
ffigen: ^9.0.0
ffi: ^2.1.0
ffigen: ^9.0.1
{{/withFfi}}
flutter_test:
sdk: flutter
......
......@@ -20,7 +20,7 @@ import 'package:file_testing/file_testing.dart';
import 'package:native_assets_cli/native_assets_cli.dart';
import '../src/common.dart';
import 'test_utils.dart' show fileSystem, platform;
import 'test_utils.dart' show ProcessResultMatcher, fileSystem, platform;
import 'transition_test_utils.dart';
final String hostOs = platform.operatingSystem;
......@@ -375,14 +375,16 @@ Future<Directory> createTestProject(String packageName, Directory tempDirectory)
<String>[
flutterBin,
'create',
'--no-pub',
'--template=package_ffi',
packageName,
],
workingDirectory: tempDirectory.path,
);
if (result.exitCode != 0) {
throw Exception('flutter create failed: ${result.exitCode}\n${result.stderr}\n${result.stdout}');
throw Exception(
'flutter create failed: ${result.exitCode}\n${result.stderr}\n${result.stdout}',
);
}
final Directory packageDirectory = tempDirectory.childDirectory(packageName);
......@@ -394,9 +396,31 @@ Future<Directory> createTestProject(String packageName, Directory tempDirectory)
expect(packageDirectory.childDirectory('macos/'), isNot(exists));
expect(packageDirectory.childDirectory('windows/'), isNot(exists));
await pinDependencies(packageDirectory.childFile('pubspec.yaml'));
await pinDependencies(
packageDirectory.childDirectory('example').childFile('pubspec.yaml'));
final ProcessResult result2 = await processManager.run(
<String>[
flutterBin,
'pub',
'get',
],
workingDirectory: packageDirectory.path,
);
expect(result2, const ProcessResultMatcher());
return packageDirectory;
}
Future<void> pinDependencies(File pubspecFile) async {
expect(pubspecFile, exists);
final String oldPubspec = await pubspecFile.readAsString();
final String newPubspec = oldPubspec.replaceAll(RegExp(r':\s*\^'), ': ');
expect(newPubspec, isNot(oldPubspec));
await pubspecFile.writeAsString(newPubspec);
}
Future<void> inTempDir(Future<void> Function(Directory tempDirectory) fun) async {
final Directory tempDirectory = fileSystem.directory(fileSystem.systemTempDirectory.createTempSync().resolveSymbolicLinksSync());
try {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment