clean up --dart-define-from-file option tests (#135980)

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

Changes:
* Moves all tests of `--dart-define-from-file` behavior from `build_bundle_test.dart` and `assemble_test.dart` to `flutter_command_test.dart`.
* Deletes a duplicate test of malformed JSON detection behavior.
* Renames the `useDartDefineFromFileOption` method of `FlutterCommand` to `_usesDartDefineFromFileOption`. This 1) makes the name more consistent with the other `uses*Option` methods and 2) hides the method since it is not used outside of the file.
* Renames several tests to better articulate what is under test and what the expected result is.
* Adds a test for the case where a `.env` file with a malformed line is provided to `--dart-define-from-file`.
This commit is contained in:
Andrew Kolos
2023-10-17 15:31:38 -07:00
committed by GitHub
parent 22f593e578
commit cdc40b5226
4 changed files with 371 additions and 390 deletions

View File

@@ -656,10 +656,10 @@ abstract class FlutterCommand extends Command<void> {
valueHelp: 'foo=bar',
splitCommas: false,
);
useDartDefineFromFileOption();
_usesDartDefineFromFileOption();
}
void useDartDefineFromFileOption() {
void _usesDartDefineFromFileOption() {
argParser.addMultiOption(
FlutterOptions.kDartDefineFromFileOption,
help:
@@ -1441,9 +1441,10 @@ abstract class FlutterCommand extends Command<void> {
dartDefineConfigJsonMap[key] = value;
});
} on FormatException catch (err) {
throwToolExit('Json config define file "--${FlutterOptions
.kDartDefineFromFileOption}=$path" format err, '
'please fix first! format err:\n$err');
throwToolExit('Unable to parse the file at path "$path" due to a formatting error. '
'Ensure that the file contains valid JSON.\n'
'Error details: $err'
);
}
}
}