Unverified Commit 0f5cd785 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

[flutter_tools] fix flutter create -t skeleton (#141233)

Fixes https://github.com/flutter/flutter/issues/139138

This had been broken since https://github.com/flutter/flutter/pull/130090 merged, however, the test happened run with flutter_tools/pubspec.yaml in the current working directory.
parent 1f11f13e
......@@ -48,7 +48,7 @@ Future<LocalizationsGenerator> generateLocalizations({
precacheLanguageAndRegionTags();
// Use \r\n if project's pubspec file contains \r\n.
final bool useCRLF = fileSystem.file('pubspec.yaml').readAsStringSync().contains('\r\n');
final bool useCRLF = projectDir.childFile('pubspec.yaml').readAsStringSync().contains('\r\n');
LocalizationsGenerator generator;
try {
......
......@@ -687,7 +687,41 @@ void main() {
});
group('generateLocalizations', () {
// Regression test for https://github.com/flutter/flutter/issues/119593
testWithoutContext('works even if CWD does not have a pubspec.yaml', () async {
final Directory projectDir = fs.currentDirectory.childDirectory('project')..createSync(recursive: true);
final Directory l10nDirectory = projectDir.childDirectory('lib').childDirectory('l10n')
..createSync(recursive: true);
l10nDirectory.childFile(defaultTemplateArbFileName)
.writeAsStringSync(singleMessageArbFileString);
l10nDirectory.childFile(esArbFileName)
.writeAsStringSync(singleEsMessageArbFileString);
projectDir.childFile('pubspec.yaml')
..createSync(recursive: true)
..writeAsStringSync('''
flutter:
generate: true
''');
final Logger logger = BufferLogger.test();
logger.printError('An error output from a different tool in flutter_tools');
// Should run without error.
await generateLocalizations(
fileSystem: fs,
options: LocalizationOptions(
arbDir: Uri.directory(defaultL10nPathString).path,
outputDir: Uri.directory(defaultL10nPathString, windows: false).path,
templateArbFile: Uri.file(defaultTemplateArbFileName, windows: false).path,
syntheticPackage: false,
),
logger: logger,
projectDir: projectDir,
dependenciesDir: fs.currentDirectory,
artifacts: artifacts,
processManager: processManager,
);
});
testWithoutContext('other logs from flutter_tools does not affect gen-l10n', () async {
_standardFlutterDirectoryL10nSetup(fs);
......
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