@@ -69,76 +69,6 @@ void main() {
6969 },
7070 );
7171
72- testUsingContext (
73- 'not using synthetic packages (explicitly)' ,
74- () async {
75- final Directory l10nDirectory = fileSystem.directory (fileSystem.path.join ('lib' , 'l10n' ));
76- final File arbFile = l10nDirectory.childFile ('app_en.arb' )..createSync (recursive: true );
77-
78- arbFile.writeAsStringSync ('''
79- {
80- "helloWorld": "Hello, World!",
81- "@helloWorld": {
82- "description": "Sample description"
83- }
84- }''' );
85- fileSystem.file ('pubspec.yaml' ).writeAsStringSync ('''
86- flutter:
87- generate: true''' );
88-
89- final GenerateLocalizationsCommand command = GenerateLocalizationsCommand (
90- fileSystem: fileSystem,
91- logger: logger,
92- artifacts: artifacts,
93- processManager: processManager,
94- );
95- await createTestCommandRunner (command).run (< String > ['gen-l10n' , '--no-synthetic-package' ]);
96-
97- expect (l10nDirectory.existsSync (), true );
98- expect (l10nDirectory.childFile ('app_localizations_en.dart' ).existsSync (), true );
99- expect (l10nDirectory.childFile ('app_localizations.dart' ).existsSync (), true );
100- },
101- overrides: < Type , Generator > {
102- FileSystem : () => fileSystem,
103- ProcessManager : () => FakeProcessManager .any (),
104- },
105- );
106-
107- testUsingContext (
108- 'not using synthetic packages (due to --explicit-package-dependencies)' ,
109- () async {
110- final Directory l10nDirectory = fileSystem.directory (fileSystem.path.join ('lib' , 'l10n' ));
111- final File arbFile = l10nDirectory.childFile ('app_en.arb' )..createSync (recursive: true );
112-
113- arbFile.writeAsStringSync ('''
114- {
115- "helloWorld": "Hello, World!",
116- "@helloWorld": {
117- "description": "Sample description"
118- }
119- }''' );
120- fileSystem.file ('pubspec.yaml' ).writeAsStringSync ('''
121- flutter:
122- generate: true''' );
123-
124- final GenerateLocalizationsCommand command = GenerateLocalizationsCommand (
125- fileSystem: fileSystem,
126- logger: logger,
127- artifacts: artifacts,
128- processManager: processManager,
129- );
130- await createTestCommandRunner (command).run (< String > ['gen-l10n' ]);
131-
132- expect (l10nDirectory.existsSync (), true );
133- expect (l10nDirectory.childFile ('app_localizations_en.dart' ).existsSync (), true );
134- expect (l10nDirectory.childFile ('app_localizations.dart' ).existsSync (), true );
135- },
136- overrides: < Type , Generator > {
137- FileSystem : () => fileSystem,
138- ProcessManager : () => FakeProcessManager .any (),
139- },
140- );
141-
14272 testUsingContext (
14373 'throws error when arguments are invalid' ,
14474 () async {
@@ -590,7 +520,7 @@ format: false
590520 );
591521
592522 testUsingContext (
593- 'throw when generate: false and uses synthetic package when run with l10n.yaml' ,
523+ 'throw when generate: false when run with l10n.yaml' ,
594524 () async {
595525 final File arbFile = fileSystem.file (fileSystem.path.join ('lib' , 'l10n' , 'app_en.arb' ))
596526 ..createSync (recursive: true );
@@ -636,7 +566,7 @@ format: false
636566 );
637567
638568 testUsingContext (
639- 'throw when generate: false and uses synthetic package when run via commandline options' ,
569+ 'throw when generate: false when run via commandline options' ,
640570 () async {
641571 final File arbFile = fileSystem.file (fileSystem.path.join ('lib' , 'l10n' , 'app_en.arb' ))
642572 ..createSync (recursive: true );
@@ -667,8 +597,7 @@ format: false
667597 processManager: processManager,
668598 );
669599 expect (
670- () async =>
671- createTestCommandRunner (command).run (< String > ['gen-l10n' , '--synthetic-package' ]),
600+ () async => createTestCommandRunner (command).run (< String > ['gen-l10n' ]),
672601 throwsToolExit (
673602 message:
674603 'Attempted to generate localizations code without having the flutter: generate flag turned on.' ,
@@ -689,13 +618,44 @@ format: false
689618 processManager: processManager,
690619 );
691620 expect (
692- () async => createTestCommandRunner (
693- command,
694- ).run (< String > ['gen-l10n' , '--synthetic-package' , 'false' ]),
621+ () async => createTestCommandRunner (command).run (< String > ['gen-l10n' , 'false' ]),
695622 throwsToolExit (message: 'Unexpected positional argument "false".' ),
696623 );
697624 });
698625
626+ testUsingContext ('throws error when synthetic-package is provided' , () async {
627+ final GenerateLocalizationsCommand command = GenerateLocalizationsCommand (
628+ fileSystem: fileSystem,
629+ logger: logger,
630+ artifacts: artifacts,
631+ processManager: processManager,
632+ );
633+ await expectLater (
634+ () async => createTestCommandRunner (command).run (< String > ['gen-l10n' , '--synthetic-package' ]),
635+ throwsToolExit (message: 'synthetic-package' ),
636+ );
637+ });
638+
639+ testUsingContext (
640+ 'prints warning when --no-synthetic-package is provided' ,
641+ () async {
642+ final GenerateLocalizationsCommand command = GenerateLocalizationsCommand (
643+ fileSystem: fileSystem,
644+ logger: logger,
645+ artifacts: artifacts,
646+ processManager: processManager,
647+ );
648+ fileSystem
649+ .file (fileSystem.path.join ('lib' , 'l10n' , 'app_en.arb' ))
650+ .createSync (recursive: true );
651+ final File pubspecFile = fileSystem.file ('pubspec.yaml' )..createSync ();
652+ pubspecFile.writeAsStringSync (BasicProjectWithFlutterGen ().pubspec);
653+ await createTestCommandRunner (command).run (< String > ['gen-l10n' , '--no-synthetic-package' ]);
654+ expect (logger.warningText, contains ('synthetic-package' ));
655+ },
656+ overrides: < Type , Generator > {Logger : () => logger},
657+ );
658+
699659 group (AppResourceBundle , () {
700660 testWithoutContext ("can be parsed without FormatException when it's content is empty" , () {
701661 final File arbFile = fileSystem.file (fileSystem.path.join ('lib' , 'l10n' , 'app_en.arb' ))
0 commit comments