@@ -60,6 +60,19 @@ void main() {
6060 package.pubspecFile.writeAsStringSync (lines.join ('\n ' ));
6161 }
6262
63+ /// Adds a 'dev_dependencies:' section with entries for each package in
64+ /// [dependencies] to [package] .
65+ void _addDevDependenciesSection (
66+ RepositoryPackage package, Iterable <String > devDependencies) {
67+ final String originalContent = package.pubspecFile.readAsStringSync ();
68+ package.pubspecFile.writeAsStringSync ('''
69+ $originalContent
70+
71+ dev_dependencies:
72+ ${devDependencies .map ((String dep ) => ' $dep : ^1.0.0' ).join ('\n ' )}
73+ ''' );
74+ }
75+
6376 test ('no-ops for no plugins' , () async {
6477 createFakePackage ('foo' , packagesDir, isFlutter: true );
6578 final RepositoryPackage packageBar =
@@ -81,7 +94,7 @@ void main() {
8194 expect (packageBar.pubspecFile.readAsStringSync (), originalPubspecContents);
8295 });
8396
84- test ('rewrites references' , () async {
97+ test ('rewrites "dependencies" references' , () async {
8598 final RepositoryPackage simplePackage =
8699 createFakePackage ('foo' , packagesDir, isFlutter: true );
87100 final Directory pluginGroup = packagesDir.childDirectory ('bar' );
@@ -142,6 +155,35 @@ void main() {
142155 ]));
143156 });
144157
158+ test ('rewrites "dev_dependencies" references' , () async {
159+ createFakePackage ('foo' , packagesDir);
160+ final RepositoryPackage builderPackage =
161+ createFakePackage ('foo_builder' , packagesDir);
162+
163+ _addDevDependenciesSection (builderPackage, < String > [
164+ 'foo' ,
165+ ]);
166+
167+ final List <String > output = await runCapturingPrint (
168+ runner, < String > ['make-deps-path-based' , '--target-dependencies=foo' ]);
169+
170+ expect (
171+ output,
172+ containsAll (< String > [
173+ 'Rewriting references to: foo...' ,
174+ ' Modified packages/foo_builder/pubspec.yaml' ,
175+ ]));
176+
177+ expect (
178+ builderPackage.pubspecFile.readAsLinesSync (),
179+ containsAllInOrder (< String > [
180+ '# FOR TESTING ONLY. DO NOT MERGE.' ,
181+ 'dependency_overrides:' ,
182+ ' foo:' ,
183+ ' path: ../foo' ,
184+ ]));
185+ });
186+
145187 // This test case ensures that running CI using this command on an interim
146188 // PR that itself used this command won't fail on the rewrite step.
147189 test ('running a second time no-ops without failing' , () async {
0 commit comments