Unverified Commit 646666f8 authored by Tae Hyung Kim's avatar Tae Hyung Kim Committed by GitHub

[gen_l10n] Add option to format generated localizations files (#109171)

* init

* fix

* fix 2

* fix 3

* tests

* fix tests

* clarify help text

* fix all tests

* fix formatting?

* add second test

* unused import

* remove print

* trailing spaces

* artifacts is never null

* fix
parent d2597ef7
...@@ -178,6 +178,8 @@ List<FlutterCommand> generateCommands({ ...@@ -178,6 +178,8 @@ List<FlutterCommand> generateCommands({
GenerateLocalizationsCommand( GenerateLocalizationsCommand(
fileSystem: globals.fs, fileSystem: globals.fs,
logger: globals.logger, logger: globals.logger,
artifacts: globals.artifacts!,
processManager: globals.processManager,
), ),
InstallCommand(), InstallCommand(),
LogsCommand(), LogsCommand(),
......
...@@ -2,8 +2,12 @@ ...@@ -2,8 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:process/process.dart';
import '../artifacts.dart';
import '../base/common.dart'; import '../base/common.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
import '../globals.dart' as globals; import '../globals.dart' as globals;
import '../localizations/gen_l10n.dart'; import '../localizations/gen_l10n.dart';
...@@ -21,9 +25,13 @@ class GenerateLocalizationsCommand extends FlutterCommand { ...@@ -21,9 +25,13 @@ class GenerateLocalizationsCommand extends FlutterCommand {
GenerateLocalizationsCommand({ GenerateLocalizationsCommand({
required FileSystem fileSystem, required FileSystem fileSystem,
required Logger logger, required Logger logger,
required Artifacts artifacts,
required ProcessManager processManager,
}) : }) :
_fileSystem = fileSystem, _fileSystem = fileSystem,
_logger = logger { _logger = logger,
_artifacts = artifacts,
_processManager = processManager {
argParser.addOption( argParser.addOption(
'arb-dir', 'arb-dir',
defaultsTo: globals.fs.path.join('lib', 'l10n'), defaultsTo: globals.fs.path.join('lib', 'l10n'),
...@@ -180,10 +188,16 @@ class GenerateLocalizationsCommand extends FlutterCommand { ...@@ -180,10 +188,16 @@ class GenerateLocalizationsCommand extends FlutterCommand {
'Localizations.of(context), removing the need for null checking in ' 'Localizations.of(context), removing the need for null checking in '
'user code.' 'user code.'
); );
argParser.addFlag(
'format',
help: 'When specified, the "dart format" command is run after generating the localization files.'
);
} }
final FileSystem _fileSystem; final FileSystem _fileSystem;
final Logger _logger; final Logger _logger;
final Artifacts _artifacts;
final ProcessManager _processManager;
@override @override
String get description => 'Generate localizations for the current project.'; String get description => 'Generate localizations for the current project.';
...@@ -196,6 +210,10 @@ class GenerateLocalizationsCommand extends FlutterCommand { ...@@ -196,6 +210,10 @@ class GenerateLocalizationsCommand extends FlutterCommand {
@override @override
Future<FlutterCommandResult> runCommand() async { Future<FlutterCommandResult> runCommand() async {
List<String> outputFileList;
bool format = boolArg('format') ?? false;
if (_fileSystem.file('l10n.yaml').existsSync()) { if (_fileSystem.file('l10n.yaml').existsSync()) {
final LocalizationOptions options = parseLocalizationsOptions( final LocalizationOptions options = parseLocalizationsOptions(
file: _fileSystem.file('l10n.yaml'), file: _fileSystem.file('l10n.yaml'),
...@@ -207,15 +225,14 @@ class GenerateLocalizationsCommand extends FlutterCommand { ...@@ -207,15 +225,14 @@ class GenerateLocalizationsCommand extends FlutterCommand {
'To use the command line arguments, delete the l10n.yaml file in the ' 'To use the command line arguments, delete the l10n.yaml file in the '
'Flutter project.\n\n' 'Flutter project.\n\n'
); );
generateLocalizations( outputFileList = generateLocalizations(
logger: _logger, logger: _logger,
options: options, options: options,
projectDir: _fileSystem.currentDirectory, projectDir: _fileSystem.currentDirectory,
fileSystem: _fileSystem, fileSystem: _fileSystem,
); ).outputFileList;
return FlutterCommandResult.success(); format = format || options.format;
} } else {
final String inputPathString = stringArgDeprecated('arb-dir')!; // Has default value, cannot be null. final String inputPathString = stringArgDeprecated('arb-dir')!; // Has default value, cannot be null.
final String? outputPathString = stringArgDeprecated('output-dir'); final String? outputPathString = stringArgDeprecated('output-dir');
final String outputFileString = stringArgDeprecated('output-localization-file')!; // Has default value, cannot be null. final String outputFileString = stringArgDeprecated('output-localization-file')!; // Has default value, cannot be null.
...@@ -235,7 +252,7 @@ class GenerateLocalizationsCommand extends FlutterCommand { ...@@ -235,7 +252,7 @@ class GenerateLocalizationsCommand extends FlutterCommand {
precacheLanguageAndRegionTags(); precacheLanguageAndRegionTags();
try { try {
LocalizationsGenerator( outputFileList = (LocalizationsGenerator(
fileSystem: _fileSystem, fileSystem: _fileSystem,
inputPathString: inputPathString, inputPathString: inputPathString,
outputPathString: outputPathString, outputPathString: outputPathString,
...@@ -255,10 +272,25 @@ class GenerateLocalizationsCommand extends FlutterCommand { ...@@ -255,10 +272,25 @@ class GenerateLocalizationsCommand extends FlutterCommand {
logger: _logger, logger: _logger,
) )
..loadResources() ..loadResources()
..writeOutputFiles(); ..writeOutputFiles())
.outputFileList;
} on L10nException catch (e) { } on L10nException catch (e) {
throwToolExit(e.message); throwToolExit(e.message);
} }
}
// All other post processing.
if (format) {
if (outputFileList.isEmpty) {
return FlutterCommandResult.success();
}
final String dartBinary = _artifacts.getHostArtifact(HostArtifact.engineDartBinary).path;
final List<String> command = <String>[dartBinary, 'format', ...outputFileList];
final ProcessResult result = await _processManager.run(command);
if (result.exitCode != 0) {
throwToolExit('Formatting failed: $result', exitCode: result.exitCode);
}
}
return FlutterCommandResult.success(); return FlutterCommandResult.success();
} }
......
...@@ -811,6 +811,10 @@ class LocalizationsGenerator { ...@@ -811,6 +811,10 @@ class LocalizationsGenerator {
return _allBundles.bundles.map((AppResourceBundle bundle) => bundle.file.path).toList(); return _allBundles.bundles.map((AppResourceBundle bundle) => bundle.file.path).toList();
} }
List<String> get outputFileList {
return _outputFileList;
}
/// The supported language codes as found in the arb files located in /// The supported language codes as found in the arb files located in
/// [inputDirectory]. /// [inputDirectory].
final Set<String> supportedLanguageCodes = <String>{}; final Set<String> supportedLanguageCodes = <String>{};
...@@ -1339,7 +1343,7 @@ class LocalizationsGenerator { ...@@ -1339,7 +1343,7 @@ class LocalizationsGenerator {
|| message.placeholdersRequireFormatting; || message.placeholdersRequireFormatting;
}); });
void writeOutputFiles({ bool isFromYaml = false }) { List<String> writeOutputFiles({ bool isFromYaml = false }) {
// First, generate the string contents of all necessary files. // First, generate the string contents of all necessary files.
final String generatedLocalizationsFile = _generateCode(); final String generatedLocalizationsFile = _generateCode();
...@@ -1372,9 +1376,7 @@ class LocalizationsGenerator { ...@@ -1372,9 +1376,7 @@ class LocalizationsGenerator {
// Generate the required files for localizations. // Generate the required files for localizations.
_languageFileMap.forEach((File file, String contents) { _languageFileMap.forEach((File file, String contents) {
file.writeAsStringSync(contents); file.writeAsStringSync(contents);
if (inputsAndOutputsListFile != null) {
_outputFileList.add(file.absolute.path); _outputFileList.add(file.absolute.path);
}
}); });
baseOutputFile.writeAsStringSync(generatedLocalizationsFile); baseOutputFile.writeAsStringSync(generatedLocalizationsFile);
...@@ -1407,9 +1409,8 @@ class LocalizationsGenerator { ...@@ -1407,9 +1409,8 @@ class LocalizationsGenerator {
); );
} }
final File? inputsAndOutputsListFileLocal = inputsAndOutputsListFile; final File? inputsAndOutputsListFileLocal = inputsAndOutputsListFile;
if (inputsAndOutputsListFileLocal != null) {
_outputFileList.add(baseOutputFile.absolute.path); _outputFileList.add(baseOutputFile.absolute.path);
if (inputsAndOutputsListFileLocal != null) {
// Generate a JSON file containing the inputs and outputs of the gen_l10n script. // Generate a JSON file containing the inputs and outputs of the gen_l10n script.
if (!inputsAndOutputsListFileLocal.existsSync()) { if (!inputsAndOutputsListFileLocal.existsSync()) {
inputsAndOutputsListFileLocal.createSync(recursive: true); inputsAndOutputsListFileLocal.createSync(recursive: true);
...@@ -1422,14 +1423,14 @@ class LocalizationsGenerator { ...@@ -1422,14 +1423,14 @@ class LocalizationsGenerator {
}), }),
); );
} }
return _outputFileList;
} }
void _generateUntranslatedMessagesFile(Logger logger, File untranslatedMessagesFile) { void _generateUntranslatedMessagesFile(Logger logger, File untranslatedMessagesFile) {
if (_unimplementedMessages.isEmpty) { if (_unimplementedMessages.isEmpty) {
untranslatedMessagesFile.writeAsStringSync('{}'); untranslatedMessagesFile.writeAsStringSync('{}');
if (inputsAndOutputsListFile != null) {
_outputFileList.add(untranslatedMessagesFile.absolute.path); _outputFileList.add(untranslatedMessagesFile.absolute.path);
}
return; return;
} }
...@@ -1457,8 +1458,6 @@ class LocalizationsGenerator { ...@@ -1457,8 +1458,6 @@ class LocalizationsGenerator {
resultingFile += '}\n'; resultingFile += '}\n';
untranslatedMessagesFile.writeAsStringSync(resultingFile); untranslatedMessagesFile.writeAsStringSync(resultingFile);
if (inputsAndOutputsListFile != null) {
_outputFileList.add(untranslatedMessagesFile.absolute.path); _outputFileList.add(untranslatedMessagesFile.absolute.path);
} }
}
} }
...@@ -311,6 +311,7 @@ class LocalizationOptions { ...@@ -311,6 +311,7 @@ class LocalizationOptions {
this.useSyntheticPackage = true, this.useSyntheticPackage = true,
this.areResourceAttributesRequired = false, this.areResourceAttributesRequired = false,
this.usesNullableGetter = true, this.usesNullableGetter = true,
this.format = false,
}) : assert(useSyntheticPackage != null); }) : assert(useSyntheticPackage != null);
/// The `--arb-dir` argument. /// The `--arb-dir` argument.
...@@ -377,6 +378,11 @@ class LocalizationOptions { ...@@ -377,6 +378,11 @@ class LocalizationOptions {
/// ///
/// Whether or not the localizations class getter is nullable. /// Whether or not the localizations class getter is nullable.
final bool usesNullableGetter; final bool usesNullableGetter;
/// The `format` argument.
///
/// Whether or not to format the generated files.
final bool format;
} }
/// Parse the localizations configuration options from [file]. /// Parse the localizations configuration options from [file].
...@@ -411,6 +417,7 @@ LocalizationOptions parseLocalizationsOptions({ ...@@ -411,6 +417,7 @@ LocalizationOptions parseLocalizationsOptions({
useSyntheticPackage: _tryReadBool(yamlNode, 'synthetic-package', logger) ?? true, useSyntheticPackage: _tryReadBool(yamlNode, 'synthetic-package', logger) ?? true,
areResourceAttributesRequired: _tryReadBool(yamlNode, 'required-resource-attributes', logger) ?? false, areResourceAttributesRequired: _tryReadBool(yamlNode, 'required-resource-attributes', logger) ?? false,
usesNullableGetter: _tryReadBool(yamlNode, 'nullable-getter', logger) ?? true, usesNullableGetter: _tryReadBool(yamlNode, 'nullable-getter', logger) ?? true,
format: _tryReadBool(yamlNode, 'format', logger) ?? true,
); );
} }
......
...@@ -5,19 +5,23 @@ ...@@ -5,19 +5,23 @@
// @dart = 2.8 // @dart = 2.8
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/commands/generate_localizations.dart'; import 'package:flutter_tools/src/commands/generate_localizations.dart';
import 'package:flutter_tools/src/runner/flutter_command.dart';
import '../../integration.shard/test_data/basic_project.dart'; import '../../integration.shard/test_data/basic_project.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
import '../../src/fake_process_manager.dart';
import '../../src/test_flutter_command_runner.dart'; import '../../src/test_flutter_command_runner.dart';
void main() { void main() {
FileSystem fileSystem; FileSystem fileSystem;
BufferLogger logger;
Artifacts artifacts;
FakeProcessManager processManager;
setUpAll(() { setUpAll(() {
Cache.disableLocking(); Cache.disableLocking();
...@@ -25,10 +29,12 @@ void main() { ...@@ -25,10 +29,12 @@ void main() {
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
logger = BufferLogger.test();
artifacts = Artifacts.test();
processManager = FakeProcessManager.empty();
}); });
testUsingContext('default l10n settings', () async { testUsingContext('default l10n settings', () async {
final BufferLogger logger = BufferLogger.test();
final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb')) final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb'))
..createSync(recursive: true); ..createSync(recursive: true);
arbFile.writeAsStringSync(''' arbFile.writeAsStringSync('''
...@@ -41,11 +47,11 @@ void main() { ...@@ -41,11 +47,11 @@ void main() {
final GenerateLocalizationsCommand command = GenerateLocalizationsCommand( final GenerateLocalizationsCommand command = GenerateLocalizationsCommand(
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
artifacts: artifacts,
processManager: processManager,
); );
await createTestCommandRunner(command).run(<String>['gen-l10n']); await createTestCommandRunner(command).run(<String>['gen-l10n']);
final FlutterCommandResult result = await command.runCommand();
expect(result.exitStatus, ExitStatus.success);
final Directory outputDirectory = fileSystem.directory(fileSystem.path.join('.dart_tool', 'flutter_gen', 'gen_l10n')); final Directory outputDirectory = fileSystem.directory(fileSystem.path.join('.dart_tool', 'flutter_gen', 'gen_l10n'));
expect(outputDirectory.existsSync(), true); expect(outputDirectory.existsSync(), true);
expect(outputDirectory.childFile('app_localizations_en.dart').existsSync(), true); expect(outputDirectory.childFile('app_localizations_en.dart').existsSync(), true);
...@@ -56,7 +62,6 @@ void main() { ...@@ -56,7 +62,6 @@ void main() {
}); });
testUsingContext('not using synthetic packages', () async { testUsingContext('not using synthetic packages', () async {
final BufferLogger logger = BufferLogger.test();
final Directory l10nDirectory = fileSystem.directory( final Directory l10nDirectory = fileSystem.directory(
fileSystem.path.join('lib', 'l10n'), fileSystem.path.join('lib', 'l10n'),
); );
...@@ -75,14 +80,14 @@ void main() { ...@@ -75,14 +80,14 @@ void main() {
final GenerateLocalizationsCommand command = GenerateLocalizationsCommand( final GenerateLocalizationsCommand command = GenerateLocalizationsCommand(
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
artifacts: artifacts,
processManager: processManager,
); );
await createTestCommandRunner(command).run(<String>[ await createTestCommandRunner(command).run(<String>[
'gen-l10n', 'gen-l10n',
'--no-synthetic-package', '--no-synthetic-package',
]); ]);
final FlutterCommandResult result = await command.runCommand();
expect(result.exitStatus, ExitStatus.success);
expect(l10nDirectory.existsSync(), true); expect(l10nDirectory.existsSync(), true);
expect(l10nDirectory.childFile('app_localizations_en.dart').existsSync(), true); expect(l10nDirectory.childFile('app_localizations_en.dart').existsSync(), true);
expect(l10nDirectory.childFile('app_localizations.dart').existsSync(), true); expect(l10nDirectory.childFile('app_localizations.dart').existsSync(), true);
...@@ -92,7 +97,6 @@ void main() { ...@@ -92,7 +97,6 @@ void main() {
}); });
testUsingContext('throws error when arguments are invalid', () async { testUsingContext('throws error when arguments are invalid', () async {
final BufferLogger logger = BufferLogger.test();
final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb')) final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb'))
..createSync(recursive: true); ..createSync(recursive: true);
arbFile.writeAsStringSync(''' arbFile.writeAsStringSync('''
...@@ -107,6 +111,8 @@ void main() { ...@@ -107,6 +111,8 @@ void main() {
final GenerateLocalizationsCommand command = GenerateLocalizationsCommand( final GenerateLocalizationsCommand command = GenerateLocalizationsCommand(
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
artifacts: artifacts,
processManager: processManager,
); );
expect( expect(
() => createTestCommandRunner(command).run(<String>[ () => createTestCommandRunner(command).run(<String>[
...@@ -122,7 +128,6 @@ void main() { ...@@ -122,7 +128,6 @@ void main() {
}); });
testUsingContext('l10n yaml file takes precedence over command line arguments', () async { testUsingContext('l10n yaml file takes precedence over command line arguments', () async {
final BufferLogger logger = BufferLogger.test();
final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb')) final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb'))
..createSync(recursive: true); ..createSync(recursive: true);
arbFile.writeAsStringSync(''' arbFile.writeAsStringSync('''
...@@ -138,11 +143,11 @@ void main() { ...@@ -138,11 +143,11 @@ void main() {
final GenerateLocalizationsCommand command = GenerateLocalizationsCommand( final GenerateLocalizationsCommand command = GenerateLocalizationsCommand(
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
artifacts: artifacts,
processManager: processManager,
); );
await createTestCommandRunner(command).run(<String>['gen-l10n']); await createTestCommandRunner(command).run(<String>['gen-l10n']);
final FlutterCommandResult result = await command.runCommand();
expect(result.exitStatus, ExitStatus.success);
expect(logger.statusText, contains('Because l10n.yaml exists, the options defined there will be used instead.')); expect(logger.statusText, contains('Because l10n.yaml exists, the options defined there will be used instead.'));
final Directory outputDirectory = fileSystem.directory(fileSystem.path.join('.dart_tool', 'flutter_gen', 'gen_l10n')); final Directory outputDirectory = fileSystem.directory(fileSystem.path.join('.dart_tool', 'flutter_gen', 'gen_l10n'));
expect(outputDirectory.existsSync(), true); expect(outputDirectory.existsSync(), true);
...@@ -154,7 +159,6 @@ void main() { ...@@ -154,7 +159,6 @@ void main() {
}); });
testUsingContext('nullable-getter help message is expected string', () async { testUsingContext('nullable-getter help message is expected string', () async {
final BufferLogger logger = BufferLogger.test();
final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb')) final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb'))
..createSync(recursive: true); ..createSync(recursive: true);
arbFile.writeAsStringSync(''' arbFile.writeAsStringSync('''
...@@ -170,6 +174,8 @@ void main() { ...@@ -170,6 +174,8 @@ void main() {
final GenerateLocalizationsCommand command = GenerateLocalizationsCommand( final GenerateLocalizationsCommand command = GenerateLocalizationsCommand(
fileSystem: fileSystem, fileSystem: fileSystem,
logger: logger, logger: logger,
artifacts: artifacts,
processManager: processManager,
); );
await createTestCommandRunner(command).run(<String>['gen-l10n']); await createTestCommandRunner(command).run(<String>['gen-l10n']);
expect(command.usage, contains(' If this value is set to false, then ')); expect(command.usage, contains(' If this value is set to false, then '));
...@@ -177,4 +183,88 @@ void main() { ...@@ -177,4 +183,88 @@ void main() {
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
}); });
testUsingContext('dart format is run when --format is passed', () async {
final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb'))
..createSync(recursive: true);
arbFile.writeAsStringSync('''
{
"helloWorld": "Hello, World!",
"@helloWorld": {
"description": "Sample description"
}
}''');
processManager.addCommand(
const FakeCommand(
command: <String>[
'HostArtifact.engineDartBinary',
'format',
'/.dart_tool/flutter_gen/gen_l10n/app_localizations_en.dart',
'/.dart_tool/flutter_gen/gen_l10n/app_localizations.dart',
]
)
);
final GenerateLocalizationsCommand command = GenerateLocalizationsCommand(
fileSystem: fileSystem,
logger: logger,
artifacts: artifacts,
processManager: processManager,
);
await createTestCommandRunner(command).run(<String>['gen-l10n', '--format']);
final Directory outputDirectory = fileSystem.directory(fileSystem.path.join('.dart_tool', 'flutter_gen', 'gen_l10n'));
expect(outputDirectory.existsSync(), true);
expect(outputDirectory.childFile('app_localizations_en.dart').existsSync(), true);
expect(outputDirectory.childFile('app_localizations.dart').existsSync(), true);
expect(processManager, hasNoRemainingExpectations);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('dart format is run when format: true is passed into l10n.yaml', () async {
final File arbFile = fileSystem.file(fileSystem.path.join('lib', 'l10n', 'app_en.arb'))
..createSync(recursive: true);
arbFile.writeAsStringSync('''
{
"helloWorld": "Hello, World!",
"@helloWorld": {
"description": "Sample description"
}
}''');
final File configFile = fileSystem.file('l10n.yaml')..createSync();
configFile.writeAsStringSync('''
format: true
''');
final File pubspecFile = fileSystem.file('pubspec.yaml')..createSync();
pubspecFile.writeAsStringSync(BasicProjectWithFlutterGen().pubspec);
processManager.addCommand(
const FakeCommand(
command: <String>[
'HostArtifact.engineDartBinary',
'format',
'/.dart_tool/flutter_gen/gen_l10n/app_localizations_en.dart',
'/.dart_tool/flutter_gen/gen_l10n/app_localizations.dart',
]
)
);
final GenerateLocalizationsCommand command = GenerateLocalizationsCommand(
fileSystem: fileSystem,
logger: logger,
artifacts: artifacts,
processManager: processManager,
);
await createTestCommandRunner(command).run(<String>['gen-l10n']);
final Directory outputDirectory = fileSystem.directory(fileSystem.path.join('.dart_tool', 'flutter_gen', 'gen_l10n'));
expect(outputDirectory.existsSync(), true);
expect(outputDirectory.childFile('app_localizations_en.dart').existsSync(), true);
expect(outputDirectory.childFile('app_localizations.dart').existsSync(), true);
expect(processManager, hasNoRemainingExpectations);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
});
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment