Unverified Commit c6fd4249 authored by Dan Field's avatar Dan Field Committed by GitHub

Test update_packages for git packages (#61127)

parent debb3a5d
......@@ -662,6 +662,9 @@ class PubspecYaml {
lastDependency._lockIsOverride = section == Section.dependencyOverrides;
do {
index += 1;
if (index == lines.length) {
throw StateError('Invalid pubspec.yaml: a "git" dependency section terminated early.');
}
line = lines[index];
lastDependency._lockLine += '\n$line';
} while (line.startsWith(' '));
......
......@@ -30,6 +30,11 @@ dependencies:
sky_engine:
sdk: flutter
gallery:
git:
url: https://github.com/flutter/gallery.git
ref: d00362e6bdd0f9b30bba337c358b9e4a6e4ca950
dev_dependencies:
flutter_test:
sdk: flutter
......@@ -42,11 +47,35 @@ dev_dependencies:
# PUBSPEC CHECKSUM: 1437
''';
const String kInvalidGitPubspec = '''
name: flutter
author: Flutter Authors <flutter-dev@googlegroups.com>
description: A framework for writing Flutter applications
homepage: http://flutter.dev
environment:
# The pub client defaults to an <2.0.0 sdk constraint which we need to explicitly overwrite.
sdk: ">=2.2.2 <3.0.0"
dependencies:
# To update these, use "flutter update-packages --force-upgrade".
collection: 1.14.11
meta: 1.1.8
typed_data: 1.1.6
vector_math: 2.0.8
sky_engine:
sdk: flutter
gallery:
git:
''';
void main() {
testWithoutContext('createTemporaryFlutterSdk creates an unpinned flutter SDK', () {
final FileSystem fileSystem = MemoryFileSystem.test();
// Setup simplified FLutter SDK.
// Setup simplified Flutter SDK.
final Directory flutterSdk = fileSystem.directory('flutter')
..createSync();
// Create version file
......@@ -63,6 +92,15 @@ void main() {
// Create already parsed pubspecs.
final PubspecYaml flutterPubspec = PubspecYaml(flutter);
final PubspecDependency gitDependency = flutterPubspec.dependencies.whereType<PubspecDependency>().firstWhere((PubspecDependency dep) => dep.kind == DependencyKind.git);
expect(
gitDependency.lockLine,
'''
git:
url: https://github.com/flutter/gallery.git
ref: d00362e6bdd0f9b30bba337c358b9e4a6e4ca950
''',
);
final Directory result = createTemporaryFlutterSdk(
fileSystem,
flutterSdk,
......@@ -88,4 +126,27 @@ void main() {
expect(outputPubspec.dependencies.first.name, 'collection');
expect(outputPubspec.dependencies.first.version, 'any');
});
testWithoutContext('Throws a StateError on a malformed git: reference', () {
final FileSystem fileSystem = MemoryFileSystem.test();
// Setup simplified Flutter SDK.
final Directory flutterSdk = fileSystem.directory('flutter')
..createSync();
// Create version file
flutterSdk.childFile('version').writeAsStringSync('1.2.3');
// Create a pubspec file
final Directory flutter = flutterSdk
.childDirectory('packages')
.childDirectory('flutter')
..createSync(recursive: true);
flutter
.childFile('pubspec.yaml')
.writeAsStringSync(kInvalidGitPubspec);
expect(
() => PubspecYaml(flutter),
throwsStateError,
);
});
}
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