mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:27:43 +00:00
Migration: support changing pubspec in new CLI
Change-Id: I2e091a4ef8999f1fe649c7b9e69798e9959b635a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145643 Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
This commit is contained in:
parent
28952641d5
commit
c33f4ad9fc
|
@ -521,7 +521,10 @@ class _DartFixListener implements DartFixListenerInterface {
|
|||
@override
|
||||
void addSourceFileEdit(
|
||||
String description, Location location, SourceFileEdit fileEdit) {
|
||||
throw UnimplementedError('TODO(paulberry)');
|
||||
suggestions.add(_DartFixSuggestion(description, location: location));
|
||||
for (var sourceEdit in fileEdit.edits) {
|
||||
sourceChange.addEdit(fileEdit.file, fileEdit.fileStamp, sourceEdit);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -603,7 +606,10 @@ class _FixCodeProcessor extends Object with FixCodeProcessor {
|
|||
}
|
||||
|
||||
Future<void> runFirstPhase() async {
|
||||
// TODO(paulberry): do more things from EditDartFix.runAllTasks
|
||||
// Process package
|
||||
await processPackage(context.contextRoot.root);
|
||||
|
||||
// Process each source file.
|
||||
await processResources((ResolvedUnitResult result) async {
|
||||
List<AnalysisError> errors = result.errors
|
||||
.where((error) => error.severity == Severity.error)
|
||||
|
|
|
@ -136,12 +136,11 @@ mixin _MigrationCliTestMethods on _MigrationCliTestBase {
|
|||
}
|
||||
|
||||
Map<String, String> simpleProject({bool migrated: false, String sourceText}) {
|
||||
// TODO(paulberry): pubspec needs to be updated when migrating.
|
||||
return {
|
||||
'pubspec.yaml': '''
|
||||
name: test
|
||||
environment:
|
||||
sdk: '>=2.6.0 <3.0.0'
|
||||
sdk: '${migrated ? '>=2.9.0 <2.10.0' : '>=2.6.0 <3.0.0'}'
|
||||
''',
|
||||
'lib/test.dart': sourceText ??
|
||||
'''
|
||||
|
@ -224,8 +223,9 @@ int${migrated ? '?' : ''} f() => null;
|
|||
await cli.run(['--no-web-preview', '--apply-changes', projectDir]);
|
||||
// Check that a summary was printed
|
||||
expect(logger.stdoutBuffer.toString(), contains('Applying changes'));
|
||||
// And that it refers to test.dart
|
||||
// And that it refers to test.dart and pubspec.yaml
|
||||
expect(logger.stdoutBuffer.toString(), contains('test.dart'));
|
||||
expect(logger.stdoutBuffer.toString(), contains('pubspec.yaml'));
|
||||
// And that it does not tell the user they can rerun with `--apply-changes`
|
||||
expect(logger.stdoutBuffer.toString(), isNot(contains('--apply-changes')));
|
||||
// Changes should have been made
|
||||
|
@ -279,8 +279,9 @@ int? f() => null
|
|||
await cli.run(['--no-web-preview', projectDir]);
|
||||
// Check that a summary was printed
|
||||
expect(logger.stdoutBuffer.toString(), contains('Summary'));
|
||||
// And that it refers to test.dart
|
||||
// And that it refers to test.dart and pubspec.yaml
|
||||
expect(logger.stdoutBuffer.toString(), contains('test.dart'));
|
||||
expect(logger.stdoutBuffer.toString(), contains('pubspec.yaml'));
|
||||
// And that it tells the user they can rerun with `--apply-changes`
|
||||
expect(logger.stdoutBuffer.toString(), contains('--apply-changes'));
|
||||
// No changes should have been made
|
||||
|
|
Loading…
Reference in a new issue