@@ -66,6 +66,12 @@ const String samplesIndexJson = '''
66
66
{ "id": "sample2" }
67
67
]''' ;
68
68
69
+ /// These files are generated for all project types.
70
+ const List <String > flutterPluginsIgnores = < String > [
71
+ '.flutter-plugins' ,
72
+ '.flutter-plugins-dependencies' ,
73
+ ];
74
+
69
75
void main () {
70
76
late Directory tempDir;
71
77
late Directory projectDir;
@@ -177,6 +183,7 @@ void main() {
177
183
'ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png' ,
178
184
'lib/main.dart' ,
179
185
],
186
+ expectedGitignoreLines: flutterPluginsIgnores,
180
187
);
181
188
expect (logger.statusText, contains ('In order to run your application, type:' ));
182
189
// Check that we're telling them about documentation
@@ -246,6 +253,7 @@ void main() {
246
253
'pubspec.yaml' ,
247
254
'README.md' ,
248
255
],
256
+ expectedGitignoreLines: flutterPluginsIgnores,
249
257
);
250
258
return _runFlutterTest (projectDir);
251
259
}, overrides: < Type , Generator > {
@@ -288,22 +296,28 @@ void main() {
288
296
});
289
297
290
298
testUsingContext ('creates a module project correctly' , () async {
291
- await _createAndAnalyzeProject (projectDir, < String > [
292
- '--template=module' ,
293
- ], < String > [
294
- '.android/app/' ,
295
- '.gitignore' ,
296
- '.ios/Flutter' ,
297
- '.metadata' ,
298
- 'analysis_options.yaml' ,
299
- 'lib/main.dart' ,
300
- 'pubspec.yaml' ,
301
- 'README.md' ,
302
- 'test/widget_test.dart' ,
303
- ], unexpectedPaths: < String > [
304
- 'android/' ,
305
- 'ios/' ,
306
- ]);
299
+ await _createAndAnalyzeProject (
300
+ projectDir,
301
+ < String > [
302
+ '--template=module' ,
303
+ ],
304
+ < String > [
305
+ '.android/app/' ,
306
+ '.gitignore' ,
307
+ '.ios/Flutter' ,
308
+ '.metadata' ,
309
+ 'analysis_options.yaml' ,
310
+ 'lib/main.dart' ,
311
+ 'pubspec.yaml' ,
312
+ 'README.md' ,
313
+ 'test/widget_test.dart' ,
314
+ ],
315
+ unexpectedPaths: < String > [
316
+ 'android/' ,
317
+ 'ios/' ,
318
+ ],
319
+ expectedGitignoreLines: flutterPluginsIgnores,
320
+ );
307
321
return _runFlutterTest (projectDir);
308
322
}, overrides: < Type , Generator > {
309
323
Pub : () => Pub .test (
@@ -568,6 +582,7 @@ void main() {
568
582
'linux/flutter/generated_plugins.cmake' ,
569
583
'macos/Flutter/GeneratedPluginRegistrant.swift' ,
570
584
],
585
+ expectedGitignoreLines: flutterPluginsIgnores,
571
586
);
572
587
return _runFlutterTest (projectDir);
573
588
}, overrides: < Type , Generator > {
@@ -599,6 +614,7 @@ void main() {
599
614
'example/android/app/src/main/java/com/example/flutter_project_example/MainActivity.java' ,
600
615
'lib/flutter_project_web.dart' ,
601
616
],
617
+ expectedGitignoreLines: flutterPluginsIgnores,
602
618
);
603
619
return _runFlutterTest (projectDir.childDirectory ('example' ));
604
620
}, overrides: < Type , Generator > {
@@ -2148,6 +2164,7 @@ void main() {
2148
2164
'ios/Flutter/AppFrameworkInfo.plist' ,
2149
2165
],
2150
2166
unexpectedPaths: < String > ['test' ],
2167
+ expectedGitignoreLines: flutterPluginsIgnores,
2151
2168
);
2152
2169
expect (projectDir.childDirectory ('lib' ).childFile ('main.dart' ).readAsStringSync (),
2153
2170
contains ("Text('Hello World!')" ));
@@ -2236,6 +2253,7 @@ void main() {
2236
2253
'ios/Flutter/AppFrameworkInfo.plist' ,
2237
2254
],
2238
2255
unexpectedPaths: < String > ['test' ],
2256
+ expectedGitignoreLines: flutterPluginsIgnores,
2239
2257
);
2240
2258
expect (projectDir.childDirectory ('lib' ).childFile ('main.dart' ).readAsStringSync (),
2241
2259
contains ('void main() {}' ));
@@ -3915,6 +3933,7 @@ Future<void> _createProject(
3915
3933
List <String > createArgs,
3916
3934
List <String > expectedPaths, {
3917
3935
List <String > unexpectedPaths = const < String > [],
3936
+ List <String > expectedGitignoreLines = const < String > [],
3918
3937
}) async {
3919
3938
Cache .flutterRoot = '../..' ;
3920
3939
final CreateCommand command = CreateCommand ();
@@ -3930,24 +3949,41 @@ Future<void> _createProject(
3930
3949
return globals.fs.typeSync (fullPath) != FileSystemEntityType .notFound;
3931
3950
}
3932
3951
3933
- final List <String > failures = < String > [
3952
+ final List <String > pathFailures = < String > [
3934
3953
for (final String path in expectedPaths)
3935
3954
if (! pathExists (path))
3936
3955
'Path "$path " does not exist.' ,
3937
3956
for (final String path in unexpectedPaths)
3938
3957
if (pathExists (path))
3939
3958
'Path "$path " exists when it shouldn\' t.' ,
3940
3959
];
3941
- expect (failures, isEmpty, reason: failures.join ('\n ' ));
3960
+ expect (pathFailures, isEmpty, reason: pathFailures.join ('\n ' ));
3961
+
3962
+ final String gitignorePath = globals.fs.path.join (dir.path, '.gitignore' );
3963
+ final List <String > gitignore = globals.fs.file (gitignorePath).readAsLinesSync ();
3964
+
3965
+ final List <String > gitignoreFailures = < String > [
3966
+ for (final String line in expectedGitignoreLines)
3967
+ if (! gitignore.contains (line))
3968
+ 'Expected .gitignore to contain "$line ".' ,
3969
+ ];
3970
+ expect (gitignoreFailures, isEmpty, reason: gitignoreFailures.join ('\n ' ));
3942
3971
}
3943
3972
3944
3973
Future <void > _createAndAnalyzeProject (
3945
3974
Directory dir,
3946
3975
List <String > createArgs,
3947
3976
List <String > expectedPaths, {
3948
3977
List <String > unexpectedPaths = const < String > [],
3978
+ List <String > expectedGitignoreLines = const < String > [],
3949
3979
}) async {
3950
- await _createProject (dir, createArgs, expectedPaths, unexpectedPaths: unexpectedPaths);
3980
+ await _createProject (
3981
+ dir,
3982
+ createArgs,
3983
+ expectedPaths,
3984
+ unexpectedPaths: unexpectedPaths,
3985
+ expectedGitignoreLines: expectedGitignoreLines,
3986
+ );
3951
3987
await _analyzeProject (dir.path);
3952
3988
}
3953
3989
0 commit comments