@@ -60,6 +60,19 @@ void main() {
60
60
package.pubspecFile.writeAsStringSync (lines.join ('\n ' ));
61
61
}
62
62
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
+
63
76
test ('no-ops for no plugins' , () async {
64
77
createFakePackage ('foo' , packagesDir, isFlutter: true );
65
78
final RepositoryPackage packageBar =
@@ -81,7 +94,7 @@ void main() {
81
94
expect (packageBar.pubspecFile.readAsStringSync (), originalPubspecContents);
82
95
});
83
96
84
- test ('rewrites references' , () async {
97
+ test ('rewrites "dependencies" references' , () async {
85
98
final RepositoryPackage simplePackage =
86
99
createFakePackage ('foo' , packagesDir, isFlutter: true );
87
100
final Directory pluginGroup = packagesDir.childDirectory ('bar' );
@@ -142,6 +155,35 @@ void main() {
142
155
]));
143
156
});
144
157
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
+
145
187
// This test case ensures that running CI using this command on an interim
146
188
// PR that itself used this command won't fail on the rewrite step.
147
189
test ('running a second time no-ops without failing' , () async {
0 commit comments