Unverified Commit e9bd2ef0 authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tool] Some additional input validation for 'version' (#39136)

parent 7f5540fa
......@@ -65,6 +65,10 @@ class VersionCommand extends FlutterCommand {
// check min supported version
final Version targetVersion = Version.parse(version);
if (targetVersion == null) {
throwToolExit('Failed to parse version "$version"');
}
bool withForce = false;
if (targetVersion < minSupportedVersion) {
if (!argResults['force']) {
......
......@@ -62,6 +62,16 @@ void main() {
ProcessManager: () => MockProcessManager(),
});
testUsingContext('tool exit on confusing version', () async {
const String version = 'master';
final VersionCommand command = VersionCommand();
final Future<void> runCommand = createTestCommandRunner(command).run(<String>['version', version]);
expect(() async => await Future.wait<void>(<Future<void>>[runCommand]),
throwsA(isInstanceOf<ToolExit>()));
}, overrides: <Type, Generator>{
ProcessManager: () => MockProcessManager(),
});
testUsingContext('exit tool if can\'t get the tags', () async {
final VersionCommand command = VersionCommand();
......
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